On Thu, Jul 22, 2021 at 12:11:17PM +0200, Vincent Lefevre wrote:
   Silence strfcpy() warning in dotlock_deference_symlink().

Yeah, I thought about this commit for a while, because I wasn't joyful about making the change just to silence the compiler in this case.

The other warning-fix commits I made, prior to this commit, were at least not-nonsensical, but this last one did not make me happy.

The strfcpy definition seems wrong:

# define strfcpy(A,B,C) strncpy (A,B,C), *(A+(C)-1)=0

Funnily enough I noticed this too, before I started fixing the warnings. But when I made this change it produced even more warnings. I think because of the logic Ian described in his reply.

I would say that it is better to silence the warning with -Wno-stringop-truncation rather than trying to avoid it in the code.

I was sorely tempted. However, I'll note that this warning DID produce some bug fixes I made in the stable branch.

What do you think of using memccpy in the strfcpy macro, if it's available, as Ian suggested?

--
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA

Attachment: signature.asc
Description: PGP signature

Reply via email to