]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Provide strlcpy declaration
authorChristian Göttsche <cgzones@googlemail.com>
Tue, 24 Jan 2023 15:31:23 +0000 (16:31 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Wed, 25 Jan 2023 11:31:17 +0000 (12:31 +0100)
strlcpy(3) might not be visible since it is declared in <bsd/string.h>.
This can lead to warnings, like:

    fields.c: In function 'change_field':
    fields.c:103:17: warning: implicit declaration of function 'strlcpy'; did you mean 'strncpy'? [-Wimplicit-function-declaration]
      103 |                 strlcpy (buf, cp, maxsize);
          |                 ^~~~~~~
          |                 strncpy

    ../lib/fields.c:103:17: warning: type of 'strlcpy' does not match original declaration [-Wlto-type-mismatch]
      103 |                 strlcpy (buf, cp, maxsize);
          |                 ^
    /usr/include/bsd/string.h:44:8: note: return value type mismatch
       44 | size_t strlcpy(char *dst, const char *src, size_t siz);
          |        ^
    /usr/include/bsd/string.h:44:8: note: type 'size_t' should match type 'int'
    /usr/include/bsd/string.h:44:8: note: 'strlcpy' was previously declared here
    /usr/include/bsd/string.h:44:8: note: code may be misoptimized unless '-fno-strict-aliasing' is used

lib/Makefile.am
src/Makefile.am

index 3a50b465b2de87975a0346bf170d6c6770a1268d..b677697a2688824ca82556d6f92772cb6611666f 100644 (file)
@@ -11,6 +11,7 @@ libshadow_la_CPPFLAGS += -DVENDORDIR=\"$(VENDORDIR)\"
 endif
 
 libshadow_la_CPPFLAGS += -I$(top_srcdir)
+libshadow_la_CFLAGS = $(LIBBSD_CFLAGS)
 
 libshadow_la_SOURCES = \
        commonio.c \
index a1a2e4e31011bcb6159d06126f38df61ec9d8ed7..d86a37581f2f6cc27a7667485724db91411d2ae8 100644 (file)
@@ -13,6 +13,8 @@ AM_CPPFLAGS = \
        -I$(top_srcdir) \
        -DLOCALEDIR=\"$(datadir)/locale\"
 
+AM_CFLAGS = $(LIBBSD_CFLAGS)
+
 # XXX why are login and su in /bin anyway (other than for
 # historical reasons)?
 #