On Oct 24, 2007, at 15:59:49, Matthew Wilcox wrote:
+static void sb_vprintf(struct stringbuf *sb, gfp_t gfp, const char
*format, va_list args)
+{
[...]
+ s = sb->buf + sb->len;
+ size = vsnprintf(s, sb->alloc - sb->len, format, args);
[...]
+ /* Point to the end of the old string since we already updated -
>len */
+ s += sb->len - size;
+ vsprintf(s, format, args);
[...]
+void sb_printf(struct stringbuf *sb, gfp_t gfp, const char
*format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ sb_vprintf(sb, gfp, format, args);
+ va_end(args);
+}
This seems unlikely to work reliably as the various "v*printf"
functions modify the va_list argument they are passed. It may happen
to work on your particular architecture depending on how that
argument data is passed and stored, but you probably actually want to
make a copy of the varargs list for the first vsnprintf call.
Example below:
va_list argscopy;
va_copy(argscopy, args);
[...]
size = vsnprintf(s, sb->alloc - sb->len, format, argscopy)
[...]
s += sb->len - size;
vsprintf(s, format, args);
[...]
va_end(argscopy);
Cheers,
Kyle Moffett
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]