[Toybox] [PATCH] logger.c was failing to properly log local0-local6 facilities, due to a string parsing error. This patch enables proper local facility handling.
Rob Landley
rob at landley.net
Wed Sep 9 01:06:39 PDT 2020
On 9/9/20 12:30 AM, Rob Landley wrote:
> On 9/8/20 2:16 PM, Chris Sarra via Toybox wrote:
>> ---
>> toys/posix/logger.c | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/toys/posix/logger.c b/toys/posix/logger.c
>> index 3bcfb174..d1cc7291 100644
>> --- a/toys/posix/logger.c
>> +++ b/toys/posix/logger.c
>> @@ -64,9 +64,10 @@ void logger_main(void)
>> else {
>> *s1++ = len = 0;
>> facility = arrayfind(TT.p, facilities, ARRAY_LEN(facilities));
>> - if (facility == -1 && strncasecmp(TT.p, "local", 5)) {
>> - facility = s1[5]-'0';
>> - if (facility>7 || s1[6]) facility = -1;
>> + if (facility == -1 && strncasecmp(TT.p, "local", 5) == 0) {
>> + s2 = TT.p;
>> + facility = s2[5]-'0';
>> + if (facility>7 || s2[6]) facility = -1;
>
> Sigh, why did I promote this out of pending? arrayfind() initializes matchlen to
> 0 and then never sets it to anything ELSE, so it ONLY returns exact matches not
> longest unambiguous match (which is the point of the function I think?)
>
> Applied your patch, but I have some cleanup to do to this command...
I did the cleanup but I have no tests/logger.test, so I dunno if I broke it. (It
survived obvious smoketesting, but...?)
Could you try the attached and see if it works for you?
Thanks,
Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logger.c
Type: text/x-csrc
Size: 2486 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20200909/41c7e6d6/attachment-0003.c>
More information about the Toybox
mailing list