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 <ebl...@redhat.com> --- I'm pushing these two cleanups. This change shouldn't add any more files to perror, since strerror-override.h was already being implicitly pulled in by the strerror_r-posix dependency. ChangeLog | 6 ++++++ lib/perror.c | 4 +++- modules/perror | 1 + 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index df519bc..2b04c66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2011-06-21 Eric Blake <ebl...@redhat.com> + perror: adjust array size + * modules/perror (Depends-on): Add strerror-override. + * lib/perror.c (perror): Use it to avoid magic number. + +2011-06-21 Eric Blake <ebl...@redhat.com> + strerror-override: reduce size * lib/strerror-override.c (strerror_override): Use fewer lines. diff --git a/lib/perror.c b/lib/perror.c index 6e4aab7..af4b56c 100644 --- a/lib/perror.c +++ b/lib/perror.c @@ -24,13 +24,15 @@ #include <stdlib.h> #include <string.h> +#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 e743002..8bc9d46 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: -- 1.7.4.4