svn commit: r286102 - head/usr.bin/wall
Pedro Giffuni
pfg at FreeBSD.org
Fri Jul 31 16:13:11 UTC 2015
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.
More information about the svn-src-all
mailing list