From 0edb6a86fbccece05b3399d94112952e350b7f5c Mon Sep 17 00:00:00 2001 From: albert <> Date: Wed, 5 Jan 2005 21:21:58 +0000 Subject: [PATCH] better error messages --- NEWS | 1 + sysctl.c | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index 338010c2..6cf94c55 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ procps-3.2.4 --> procps-3.2.5 display problem on 64-bit systems fixed +sysctl: better error messages ps: security labels can contain any printable ASCII top: help and version message on stdout, with exit(0) #283541 ps: SIGTSTP from ^Z shouldn't print bug email address diff --git a/sysctl.c b/sysctl.c index 06dd56f6..e25aeb91 100644 --- a/sysctl.c +++ b/sysctl.c @@ -52,15 +52,15 @@ static bool IgnoreError; static bool Quiet; /* error messages */ -static const char ERR_UNKNOWN_PARAMETER[] = "error: Unknown parameter '%s'\n"; -static const char ERR_MALFORMED_SETTING[] = "error: Malformed setting '%s'\n"; -static const char ERR_NO_EQUALS[] = "error: '%s' must be of the form name=value\n"; -static const char ERR_INVALID_KEY[] = "error: '%s' is an unknown key\n"; -static const char ERR_UNKNOWN_WRITING[] = "error: unknown error %d setting key '%s'\n"; -static const char ERR_UNKNOWN_READING[] = "error: unknown error %d reading key '%s'\n"; +static const char ERR_UNKNOWN_PARAMETER[] = "error: Unknown parameter \"%s\"\n"; +static const char ERR_MALFORMED_SETTING[] = "error: Malformed setting \"%s\"\n"; +static const char ERR_NO_EQUALS[] = "error: \"%s\" must be of the form name=value\n"; +static const char ERR_INVALID_KEY[] = "error: \"%s\" is an unknown key\n"; +static const char ERR_UNKNOWN_WRITING[] = "error: \"%s\" setting key \"%s\"\n"; +static const char ERR_UNKNOWN_READING[] = "error: \"%s\" reading key \"%s\"\n"; static const char ERR_PERMISSION_DENIED[] = "error: permission denied on key '%s'\n"; -static const char ERR_OPENING_DIR[] = "error: unable to open directory '%s'\n"; -static const char ERR_PRELOAD_FILE[] = "error: unable to open preload file '%s'\n"; +static const char ERR_OPENING_DIR[] = "error: unable to open directory \"%s\"\n"; +static const char ERR_PRELOAD_FILE[] = "error: unable to open preload file \"%s\"\n"; static const char WARN_BAD_LINE[] = "warning: %s(%d): invalid syntax, continuing...\n"; @@ -159,7 +159,7 @@ static int ReadSetting(const char *restrict const name) { rc = -1; break; default: - fprintf(stderr, ERR_UNKNOWN_READING, errno, outname); + fprintf(stderr, ERR_UNKNOWN_READING, strerror(errno), outname); rc = -1; break; } @@ -198,7 +198,7 @@ static int ReadSetting(const char *restrict const name) { break; } default: - fprintf(stderr, ERR_UNKNOWN_READING, errno, outname); + fprintf(stderr, ERR_UNKNOWN_READING, strerror(errno), outname); rc = -1; break; } @@ -314,19 +314,19 @@ static int WriteSetting(const char *setting) { rc = -1; break; default: - fprintf(stderr, ERR_UNKNOWN_WRITING, errno, outname); + fprintf(stderr, ERR_UNKNOWN_WRITING, strerror(errno), outname); rc = -1; break; } } else { rc = fprintf(fp, "%s\n", value); if (rc < 0) { - fprintf(stderr, ERR_UNKNOWN_WRITING, errno, outname); + fprintf(stderr, ERR_UNKNOWN_WRITING, strerror(errno), outname); fclose(fp); } else { rc=fclose(fp); if (rc != 0) - fprintf(stderr, ERR_UNKNOWN_WRITING, errno, outname); + fprintf(stderr, ERR_UNKNOWN_WRITING, strerror(errno), outname); } if (rc==0 && !Quiet) { if (NameOnly) {