Re: [PATCH] config.mak.dev: enable -Wunreachable-code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 07, 2025 at 10:23:09PM -0500, Jeff King wrote:
> On Fri, Mar 07, 2025 at 05:54:45PM -0500, Jeff King wrote:
> 
> > However, clang does implement this option, and it finds the case
> > mentioned above (and no other cases within the code base). And since we
> > run clang in several of our CI jobs, that's enough to get an early
> > warning of breakage.
> 
> Hmph, this might be more trouble than it is worth.
> 
> After correcting the problem in the refs code, the osx CI builds (and
> only those) now fail with:
> 
>   run-command.c:519:3: error: code will never be executed [-Werror,-Wunreachable-code]
>                   die_errno("sigfillset");
>                   ^~~~~~~~~
> 
> The code in question is just:
> 
>   if (sigfillset(&all))
> 	die_errno("sigfillset");
> 
> So I have to imagine that the issue is that sigfillset() on that
> platform is an inline or macro that will never return an error, and the
> compiler can see that. But since POSIX says this can fail (though I'd
> imagine it's unlikely on most platforms), we should check in the general
> case.
> 
> So I don't see how to solve it short of:
> 
> #ifdef SIGFILLSET_CANNOT_FAIL
> 	sigfillset(&all);
> #else
> 	if (sigfillset(&all))
> 		die_errno("sigfillset");
> #endif

There is a similar problem with this code in refs/files-backend.c:

			if (!create_ref_symlink(lock, update->new_target))
				continue;

Where create_ref_symlink is defined as such:

#ifdef NO_SYMLINK_HEAD
#define create_ref_symlink(a, b) (-1)
#else
static int create_ref_symlink(struct ref_lock *lock, const char *target)
{
...
#endif

And NO_SYMLINK_HEAD is defined on Windows.

Mike




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux