svn commit: r336028 - head/usr.bin/top

Sean Bruno sbruno at freebsd.org
Fri Jul 6 13:04:28 UTC 2018



On 07/06/18 06:07, Daichi GOTO wrote:
> -static char next_msg[MAX_COLS + 5];
> +static char *next_msg = NULL;
>  static int msglen = 0;
>  /* Invariant: msglen is always the length of the message currently displayed
>     on the screen (even when next_msg doesn't contain that message). */

gcc noticed that a later call to vsnprintf() now has some problems.
/home/sbruno/bsd/wifi/fbsd_head/usr.bin/top/display.c: In function
'new_message':
/home/sbruno/bsd/wifi/fbsd_head/usr.bin/top/display.c:963:31: error:
argument to 'sizeof' in 'vsnprintf' call is the same expression as the
destination; did you mean to provide an explicit length?
[-Werror=sizeof-pointer-memaccess]
     vsnprintf(next_msg, sizeof(next_msg), msgfmt, args);


I think this needs to be changed

Index: usr.bin/top/display.c
===================================================================
--- usr.bin/top/display.c       (revision 336029)
+++ usr.bin/top/display.c       (working copy)
@@ -960,7 +960,7 @@
     va_start(args, msgfmt);

     /* first, format the message */
-    vsnprintf(next_msg, sizeof(next_msg), msgfmt, args);
+    vsnprintf(next_msg, strlen(next_msg), msgfmt, args);

     va_end(args);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 618 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20180706/3df6e90e/attachment.sig>


More information about the svn-src-all mailing list