On 07/31/15 02:12, Bruce Evans wrote: > On Fri, 31 Jul 2015, Pedro F. Giffuni wrote: > ...
> >> static char errbuf[1024]; > > Another static buffer. The function is obviously not reentrant. This > large static buffer mainly wastes space all the time instead of only > when the function is called. > But if I drop that static I get a bunch of errors: /usr/src/usr.bin/wall/ttymsg.c:82:11: error: address of stack memory associated with local variable 'errbuf' returned [-Werror,-Wreturn-stack-address] return (errbuf); ^~~~~~ /usr/src/usr.bin/wall/ttymsg.c:94:11: error: address of stack memory associated with local variable 'errbuf' returned [-Werror,-Wreturn-stack-address] return (errbuf); ^~~~~~ /usr/src/usr.bin/wall/ttymsg.c:134:13: error: address of stack memory associated with local variable 'errbuf' returned [-Werror,-Wreturn-stack-address] return (errbuf); ^~~~~~ /usr/src/usr.bin/wall/ttymsg.c:160:11: error: address of stack memory associated with local variable 'errbuf' returned [-Werror,-Wreturn-stack-address] return (errbuf); ^~~~~~ ... >> char *p; >> int forked; >> @@ -71,8 +71,8 @@ ttymsg(struct iovec *iov, int iovcnt, co >> if (iovcnt > (int)(sizeof(localiov) / sizeof(localiov[0]))) >> return ("too many iov's (change code in wall/ttymsg.c)"); >> >> + strlcat(device, line, sizeof(device)); > > This depends on the slow reinitialization on every entry. The combined > initialization (initializer + strlcat) is an obfuscated way of > concatenating 2 strings. The clearest way is snprintf with %s%s format. > I will do that, thanks. Pedro. _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"