From: Eric Blake Date: Tue, 21 Jun 2011 16:10:06 +0000 (-0600) Subject: perror: adjust array size X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8681e553d88b3ea891c98792fcc6675dc05e4b2c;p=pspp perror: adjust array size If we ever adjust strerror-override.h to have a larger size for STACKBUF_LEN, then perror should also pick up the adjustment. * modules/perror (Depends-on): Add strerror-override. * lib/perror.c (perror): Use it to avoid magic number. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index df519bc65e..d9e6fc0458 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2011-06-21 Eric Blake + perror: adjust array size + * modules/perror (Depends-on): Add strerror-override. + * lib/perror.c (perror): Use it to avoid magic number. + strerror-override: reduce size * lib/strerror-override.c (strerror_override): Use fewer lines. diff --git a/lib/perror.c b/lib/perror.c index 6e4aab7fe6..af4b56cd40 100644 --- a/lib/perror.c +++ b/lib/perror.c @@ -24,13 +24,15 @@ #include #include +#include "strerror-override.h" + /* Use the system functions, not the gnulib overrides in this file. */ #undef fprintf void perror (const char *string) { - char stackbuf[256]; + char stackbuf[STACKBUF_LEN]; int ret; /* Our implementation guarantees that this will be a non-empty diff --git a/modules/perror b/modules/perror index e74300220a..8bc9d46b9f 100644 --- a/modules/perror +++ b/modules/perror @@ -8,6 +8,7 @@ m4/perror.m4 Depends-on: stdio errno [test $REPLACE_PERROR = 1] +strerror-override [test $REPLACE_PERROR = 1] strerror_r-posix [test $REPLACE_PERROR = 1] configure.ac: