Page MenuHomeFreeBSD

makefs: warning cleanup
ClosedPublic

Authored by emaste on May 8 2017, 7:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
May 9 2024, 4:59 PM
Unknown Object (File)
May 5 2024, 3:31 AM
Unknown Object (File)
May 3 2024, 6:55 AM
Unknown Object (File)
May 3 2024, 6:55 AM
Unknown Object (File)
May 3 2024, 6:55 AM
Unknown Object (File)
May 3 2024, 1:28 AM
Unknown Object (File)
Apr 5 2024, 8:29 AM
Unknown Object (File)
Dec 20 2023, 3:19 AM
Subscribers

Details

Summary
  • address signedness warnings with casts or type changes
  • include header for function declarations

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

usr.sbin/makefs/Makefile
17 ↗(On Diff #28158)

WARNS higher than 3 produces a number of "cast ... increases required alignment", with one example below. Will revisit that later on.

usr.sbin/makefs/ffs.c
993 ↗(On Diff #28158)

WARNS higher than 3 produces:

/usr/home/emaste/src/freebsd/usr.sbin/makefs/ffs.c:993:8: error: cast from
      'u_char *' (aka 'unsigned char *') to 'struct direct *' increases required
      alignment from 1 to 4 [-Werror,-Wcast-align]
                de = (struct direct *)(dbuf->buf + i);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
usr.sbin/makefs/ffs.c
993 ↗(On Diff #28158)

I suspect that you need to cast through uintptr_t. Like

de = (struct direct *)(uintptr_t)(buf + 1);
usr.sbin/makefs/ffs/ffs_alloc.c
67 ↗(On Diff #28158)

Note that in-kernel ffs_hashalloc() uses the following prototype:

static ufs2_daddr_t	ffs_hashalloc
		(struct inode *, u_int, ufs2_daddr_t, int, int, allocfcn_t *);
155 ↗(On Diff #28158)

Kernel uses u_int for cg and startcg.

usr.sbin/makefs/ffs.c
993 ↗(On Diff #28158)

Yes, as long as we know that it must have the correct alignment (which is probably straightforward to demonstrate, but I haven't yet looked).

I wonder though if the warning is just overly aggressive, and if we should just disable it.

usr.sbin/makefs/ffs/ffs_alloc.c
155 ↗(On Diff #28158)

Ok. I think I based this on fs_ncg being u_int32_t, but if kernel uses u_int it probably makes sense to follow here.

This revision was automatically updated to reflect the committed changes.