[PATCH] Fix compilation error due to new glibc implemented the strlcpy function

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

 



Crash-utility implemented its own strlcpy(), but for now the latest
glibc has added the strlcpy function to POSIX version(which is derived
from OpenBSD). Eventually this caused the follow compilation error:

  # make -j8 lzo
  ...
  gcc -c -g -DX86_64 -DLZO -DGDB_10_2 -g -O2 kernel.c -I./gdb-10.2/bfd -I./gdb-10.2/include
  In file included from global_data.c:18:
  defs.h:5556:8: error: conflicting types for ‘strlcpy’; have ‘size_t(char *, char *, size_t)’ {aka ‘long unsigned int(char *, char *, long unsigned int)’}
   5556 | size_t strlcpy(char *, char *, size_t);
        |        ^~~~~~~
  In file included from memory.c:19:
  defs.h:5556:8: error: conflicting types for ‘strlcpy’; have ‘size_t(char *, char *, size_t)’ {aka ‘long unsigned int(char *, char *, long unsigned int)’}
   5556 | size_t strlcpy(char *, char *, size_t);
        |        ^~~~~~~
  ...

Related glibc commits:
[1] 454a20c8756c ("Implement strlcpy and strlcat [BZ #178]")
[2] d2fda60e7c40 ("manual: Manual update for strlcat, strlcpy, wcslcat, wclscpy")
[3] 388ae538ddcb ("hurd: Add strlcpy, strlcat, wcslcpy, wcslcat to libc.abilist")

To fix the current issues, let's declare the strlcpy() as a weak
function, and keep the same parameter types with the latest glibc
function.

Signed-off-by: Lianbo Jiang <lijiang@xxxxxxxxxx>
---
 defs.h  | 2 +-
 tools.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/defs.h b/defs.h
index 8f7d1fa0aba6..26afe232cc3e 100644
--- a/defs.h
+++ b/defs.h
@@ -5553,7 +5553,7 @@ uint32_t swap32(uint32_t, int);
 uint64_t swap64(uint64_t, int);
 ulong *get_cpumask_buf(void);
 int make_cpumask(char *, ulong *, int, int *);
-size_t strlcpy(char *, char *, size_t);
+size_t strlcpy(char *, const char *, size_t) __attribute__ ((__weak__));
 struct rb_node *rb_first(struct rb_root *);
 struct rb_node *rb_parent(struct rb_node *, struct rb_node *);
 struct rb_node *rb_right(struct rb_node *, struct rb_node *);
diff --git a/tools.c b/tools.c
index 392a79707e61..0f2db108838a 100644
--- a/tools.c
+++ b/tools.c
@@ -6795,7 +6795,7 @@ make_cpumask_error:
  * always be NULL-terminated.
  */
 size_t 
-strlcpy(char *dest, char *src, size_t size)
+strlcpy(char *dest, const char *src, size_t size)
 {
 	size_t ret = strlen(src);
 
-- 
2.37.1

--
Crash-utility mailing list
Crash-utility@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/crash-utility
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux