Re: seperator error in __mask_snprintf_len

From: Paul Jackson
Date: Wed Jan 07 2004 - 20:07:11 EST


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,

Oops.

In the abstract, the separator is _not_ a trailing punctutator to each
word, but is rather used to separate each word from the _preceding_ word
(if any).

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@xxxxxxx> 1.650.933.1373
-
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/