On Sun, 20 Jul 2008 00:22:24 +0900 (JST), Atsushi Nemoto <anemo@xxxxxxxxxxxxx> wrote: > I got this error when running sparse on mips kernel with gcc 4.3: > > builtin:272:1: warning: Newline in string or character constant > > The linux-mips kernel uses '$(CC) -dM -E' to generates arguments for > sparse. With gcc 4.3, it generates lot of '-D' options and causes > pre_buffer overflow. The linux-mips kernel can filter unused symbols > out to avoid overflow, but sparse should be fixed anyway. > > This patch make pre_buffer dynamically increasable and add extra > checking for overflow instead of silently truncating. > > Signed-off-by: Atsushi Nemoto <anemo@xxxxxxxxxxxxx> Ping? > --- > diff --git a/lib.c b/lib.c > index 0abcc9a..6e8d09b 100644 > --- a/lib.c > +++ b/lib.c > @@ -186,7 +186,8 @@ void die(const char *fmt, ...) > } > > static unsigned int pre_buffer_size; > -static char pre_buffer[8192]; > +static unsigned int pre_buffer_alloc_size; > +static char *pre_buffer; > > int Waddress_space = 1; > int Wbitwise = 0; > @@ -232,12 +233,20 @@ void add_pre_buffer(const char *fmt, ...) > unsigned int size; > > va_start(args, fmt); > + if (pre_buffer_alloc_size < pre_buffer_size + getpagesize()) { > + pre_buffer_alloc_size += getpagesize(); > + pre_buffer = realloc(pre_buffer, pre_buffer_alloc_size); > + if (!pre_buffer) > + die("Unable to allocate more pre_buffer space"); > + } > size = pre_buffer_size; > size += vsnprintf(pre_buffer + size, > - sizeof(pre_buffer) - size, > + pre_buffer_alloc_size - size, > fmt, args); > pre_buffer_size = size; > va_end(args); > + if (pre_buffer_size >= pre_buffer_alloc_size - 1) > + die("pre_buffer overflow"); > } > > static char **handle_switch_D(char *arg, char **next) -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html