Re: seperator error in __mask_snprintf_len

From: Joe Korty
Date: Wed Jan 07 2004 - 22:35:28 EST


On Wed, Jan 07, 2004 at 05:06:50PM -0800, Paul Jackson wrote:
> Joe proposed this change to the loop displaying masks:
> - len += snprintf(buf+len, buflen-len, "%s%x", sep, wordp[i]);
> + len += snprintf(buf+len, buflen-len, "%x%s", wordp[i], sep);
>
>
> I doubt that your patch is correct, Joe.
>
> Consider for example the case that exactly three words are displayed.
>
> Before your patch, the code would output one hex word, then (after
> looping around once) the "," separator and the second word, then on the
> final loop another separator and word, resulting in something such as:
>
> deadbeef,12345678,87654321
>
> After your patch, it would output the first word, then the second word,
> then a trailing separator, and then the third word and separator,
> resulting in something such as:
>
> deadbeef12345678,87654321,

Sorry about the bit of conceptual dylexia on my part.

Paul, there might be a problem with __mask_snprintf_len. Won't a
value that should be displayed as:

d,00abcdef be displayed as
d,abcdef

Joe
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/