commit: f2a432050b30d96115b461a355862b970988d810
parent 66161caafde656d8c4075d6250b327cbabc9c851
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 20 Sep 2024 03:52:04 +0200
cmd/renice: unify error message formatting
Diffstat:
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/cmd/renice.c b/cmd/renice.c
@@ -36,7 +36,7 @@ renice(int which, id_t who, int adj)
int prio = getpriority(which, who);
if(errno != 0)
{
- fprintf(stderr, "renice: getpriority(%s, %d): %s\n", which_s, who, strerror(errno));
+ fprintf(stderr, "renice: error: getpriority(%s, %d): %s\n", which_s, who, strerror(errno));
return -1;
}
@@ -44,7 +44,12 @@ renice(int which, id_t who, int adj)
if(setpriority(which, who, prio) != 0)
{
- fprintf(stderr, "renice: setpriority(%s, %d, %d): %s\n", which_s, who, prio, strerror(errno));
+ fprintf(stderr,
+ "renice: error: setpriority(%s, %d, %d): %s\n",
+ which_s,
+ who,
+ prio,
+ strerror(errno));
return -1;
}
@@ -91,7 +96,7 @@ main(int argc, char *argv[])
if(errno != 0)
{
fprintf(stderr,
- "renice: Error: Failed parsing '%s' as a number: %s\n",
+ "renice: error: Failed parsing '%s' as a number: %s\n",
optarg,
strerror(errno));
usage();
@@ -99,26 +104,26 @@ main(int argc, char *argv[])
}
if(adj < PRIO_MIN)
{
- fprintf(stderr, "renice: Error: '-n %ld' is lower than PRIO_MIN(%d)\n", adj, PRIO_MIN);
+ fprintf(stderr, "renice: error: '-n %ld' is lower than PRIO_MIN(%d)\n", adj, PRIO_MIN);
return 1;
}
if(adj > PRIO_MAX)
{
- fprintf(stderr, "renice: Error: '-n %ld' is greater than PRIO_MAX(%d)\n", adj, PRIO_MAX);
+ fprintf(stderr, "renice: error: '-n %ld' is greater than PRIO_MAX(%d)\n", adj, PRIO_MAX);
return 1;
}
if(adj == 0)
{
- fprintf(stderr, "renice: Error: '-n 0' makes no sense\n");
+ fprintf(stderr, "renice: error: '-n 0' makes no sense\n");
return 1;
}
break;
case ':':
- fprintf(stderr, "renice: Error: Missing operand for option: '-%c'\n", optopt);
+ fprintf(stderr, "renice: error: Missing operand for option: '-%c'\n", optopt);
usage();
return 1;
case '?':
- fprintf(stderr, "renice: Error: Unrecognised option: '-%c'\n", optopt);
+ fprintf(stderr, "renice: error: Unrecognised option: '-%c'\n", optopt);
usage();
return 1;
default:
@@ -131,14 +136,14 @@ main(int argc, char *argv[])
if(argc == 0)
{
- fprintf(stderr, "renice: Error: No IDs passed\n");
+ fprintf(stderr, "renice: error: No IDs passed\n");
usage();
return 1;
}
if(adj == 0)
{
- fprintf(stderr, "renice: Mandatory option '-n adj' not passed\n");
+ fprintf(stderr, "renice: error: Mandatory option '-n adj' not passed\n");
usage();
return 1;
}
@@ -154,7 +159,7 @@ main(int argc, char *argv[])
if(errno != 0)
{
fprintf(stderr,
- "renice: Error: Failed parsing argument '%s' as a number: %s\n",
+ "renice: error: Failed parsing argument '%s' as a number: %s\n",
arg,
strerror(errno));
usage();