Skip to content

Commit

Permalink
GCC: Fixes for gcc 14 on Fedora 40
Browse files Browse the repository at this point in the history
- Workaround dangling pointer in uu_list.c (#16124)
- Fix calloc() transposed arguments in zpool_vdev_os.c
- Make some temp variables unsigned to prevent triggering a
  '-Werror=alloc-size-larger-than' error.

Signed-off-by: Tony Hutter <[email protected]>
Issue: #16124
  • Loading branch information
tonyhutter committed Apr 24, 2024
1 parent 1f940de commit 925a1e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/zpool/os/linux/zpool_vdev_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ static char *zpool_sysfs_gets(char *path)
return (NULL);
}

buf = calloc(sizeof (*buf), statbuf.st_size + 1);
buf = calloc(statbuf.st_size + 1, sizeof (*buf));
if (buf == NULL) {
close(fd);
return (NULL);
Expand Down
14 changes: 10 additions & 4 deletions lib/libuutil/uu_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,14 +505,20 @@ uu_list_walk(uu_list_t *lp, uu_walk_fn_t *func, void *private, uint32_t flags)
}

if (lp->ul_debug || robust) {
uu_list_walk_t my_walk;
uu_list_walk_t *my_walk;
void *e;

list_walk_init(&my_walk, lp, flags);
my_walk = calloc(1, sizeof(*my_walk));

Check failure on line 511 in lib/libuutil/uu_list.c

View workflow job for this annotation

GitHub Actions / checkstyle

missing space between keyword and paren
if (my_walk == NULL)
return -1;

Check failure on line 513 in lib/libuutil/uu_list.c

View workflow job for this annotation

GitHub Actions / checkstyle

unparenthesized return expression

list_walk_init(my_walk, lp, flags);
while (status == UU_WALK_NEXT &&
(e = uu_list_walk_next(&my_walk)) != NULL)
(e = uu_list_walk_next(my_walk)) != NULL)
status = (*func)(e, private);
list_walk_fini(&my_walk);
list_walk_fini(my_walk);

free(my_walk);
} else {
if (!reverse) {
for (np = lp->ul_null_node.uln_next;
Expand Down
5 changes: 3 additions & 2 deletions module/zfs/vdev_raidz.c
Original file line number Diff line number Diff line change
Expand Up @@ -1891,8 +1891,9 @@ vdev_raidz_matrix_reconstruct(raidz_row_t *rr, int n, int nmissing,
static void
vdev_raidz_reconstruct_general(raidz_row_t *rr, int *tgts, int ntgts)
{
int n, i, c, t, tt;
int nmissing_rows;
int i, c, t, tt;
unsigned int n;
unsigned int nmissing_rows;
int missing_rows[VDEV_RAIDZ_MAXPARITY];
int parity_map[VDEV_RAIDZ_MAXPARITY];
uint8_t *p, *pp;
Expand Down

0 comments on commit 925a1e8

Please sign in to comment.