]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: port to GCC 8
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 3 May 2018 20:03:34 +0000 (13:03 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 3 May 2018 20:04:15 +0000 (13:04 -0700)
* src/chown-core.h (chopt_free, gid_to_name, uid_to_name):
No longer const.
* src/make-prime-list.c (xalloc): Add malloc attribute.
* src/who.c (make_id_equals_comment): Work around GCC bug 85602
by using mempcpy rather than strncat.  Although the old code
was correct, strncat raises so many hackles that it’s not
worth maintaining its use here.

src/chown-core.h
src/make-prime-list.c
src/who.c

index 26d702e2c7154d2b102f1373a75d44ef6f87f420..346b1cea4ae4e27e0c7248c5128bd170139e581c 100644 (file)
@@ -68,14 +68,11 @@ struct Chown_option
 void
 chopt_init (struct Chown_option *);
 
-void _GL_ATTRIBUTE_PURE _GL_ATTRIBUTE_CONST
-chopt_free (struct Chown_option *);
+void chopt_free (struct Chown_option *);
 
-char *
-gid_to_name (gid_t);
+char *gid_to_name (gid_t) _GL_ATTRIBUTE_MALLOC;
 
-char * _GL_ATTRIBUTE_PURE
-uid_to_name (uid_t);
+char *uid_to_name (uid_t) _GL_ATTRIBUTE_MALLOC;
 
 bool
 chown_files (char **files, int bit_flags,
index b41f9837c94e9c221ad6754f477cb88d8dad42b9..1fb1677bf3cffd532aa0fc4e38b2b19a82951890 100644 (file)
@@ -157,7 +157,7 @@ output_primes (const struct prime *primes, unsigned nprimes)
   printf ("#define FIRST_OMITTED_PRIME %u\n", p);
 }
 
-static void *
+static void * _GL_ATTRIBUTE_MALLOC
 xalloc (size_t s)
 {
   void *p = malloc (s);
index 6d9e267d934a6287b417e099842fc2f788ea41e4..3719baec589d5302d1da4d1afce6c1cb7361304a 100644 (file)
--- a/src/who.c
+++ b/src/who.c
@@ -447,10 +447,14 @@ print_boottime (const STRUCT_UTMP *utmp_ent)
 static char *
 make_id_equals_comment (STRUCT_UTMP const *utmp_ent)
 {
-  char *comment = xmalloc (strlen (_("id=")) + sizeof UT_ID (utmp_ent) + 1);
-
-  strcpy (comment, _("id="));
-  strncat (comment, UT_ID (utmp_ent), sizeof UT_ID (utmp_ent));
+  char const *ideq = _("id=");
+  char const *ut_id = UT_ID (utmp_ent);
+  size_t ideqlen = strlen (ideq);
+  size_t ut_idlen = strnlen (ut_id, sizeof UT_ID (utmp_ent));
+  char *comment = xmalloc (ideqlen + ut_idlen + 1);
+  char *rhs = mempcpy (comment, ideq, ideqlen);
+  char *z = mempcpy (rhs, ut_id, ut_idlen);
+  *z = '\0';
   return comment;
 }