Page MenuHomeFreeBSD

makefs: clean up warnings
ClosedPublic

Authored by tsoome on Mon, Jul 28, 12:23 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Aug 17, 9:56 AM
Unknown Object (File)
Thu, Aug 14, 8:50 AM
Unknown Object (File)
Mon, Aug 11, 3:42 AM
Unknown Object (File)
Sat, Aug 2, 6:47 AM
Unknown Object (File)
Fri, Aug 1, 3:27 PM
Unknown Object (File)
Fri, Aug 1, 11:08 AM
Unknown Object (File)
Thu, Jul 31, 10:07 PM
Unknown Object (File)
Tue, Jul 29, 9:07 PM
Subscribers

Details

Summary

zfs/fs.c:
zfs/objset.c:
zfs/vdev.c:
zfs/zap.c:
Add include sys/param.h

dsl_dir_alloc() needs to set parent = NULL to silence warning
about 'parent' may be used uninitialized. Warning is given because
we break the loop when nextdir == NULL and parent was not previously set.
(it should not happen, but compiler does not know that).

zap_add() and zap_fat_write_array_chunk() takes uint8_t *, use type
cast.

zap_fat_write_array_chunk() should check sz for 0 to avoid
use of uninitialized pointer.

unchecked function returns.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 65814
Build 62697: arc lint + arc unit

Event Timeline

usr.sbin/makefs/zfs/dsl.c
122

In style(9) there is no space after the cast. Same comment below.

434

Which compiler is generating this warning? It seems pretty clear that this initialization isn't needed.

usr.sbin/makefs/zfs/objset.c
35

sys/param.h should be included first, per style(9).

usr.sbin/makefs/zfs/vdev.c
37

Same here.

usr.sbin/makefs/zfs/zap.c
32

When including sys/param.h, do not also include sys/types.h per style(9).

254

It would be better to assert sz > 0.

usr.sbin/makefs/zfs/dsl.c
122

In style(9) there is no space after the cast. Same comment below.

Ah, its one of those small annoying differences between illumos and FreeBSD styles:D will fix it.

434

Which compiler is generating this warning? It seems pretty clear that this initialization isn't needed.

gcc-14.

zfs/dsl.c: In function 'dsl_dir_alloc':
zfs/dsl.c:423:42: error: 'parent' may be used uninitialized [-Werror=maybe-uninitialized]
  423 |         dir->phys->dd_parent_obj = parent->dirid;
      |                                    ~~~~~~^~~~~~~
zfs/dsl.c:354:30: note: 'parent' was declared here
  354 |         zfs_dsl_dir_t *dir, *parent;
      |                              ^~~~~~
cc1: all warnings being treated as errors

Without discussing if thats possible scenario or not (static analyzers are only so good), we can hit it on first iteration if nextdir does not contain '/' - in which case strsep() will set nextdir to NULL, we break out of the loop and have parent with random content from the stack. I'd rather blow up with NULL pointer dereference if thats the case;)

tsoome marked 5 inline comments as done.

style fixes per review.

usr.sbin/makefs/zfs/zap.c
254

maybe. I personally do not really like it because:

#ifdef NDEBUG
#define assert(e)       ((void)0)
markj added inline comments.
usr.sbin/makefs/zfs/dsl.c
434

Ah, I misunderstood. Ok.

This revision is now accepted and ready to land.Tue, Jul 29, 7:31 PM
This revision was automatically updated to reflect the committed changes.