On Thu, Feb 9, 2012 at 22:03, Sami Kerola <kerolasa@xxxxxx> wrote: > I took a look of debian bug reports and decided to fix this one. > > http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=656508 > > Issue with reported 'w' command is (quite likely) fixed in commit > 6241e9d545520defd6ceb5db4de55042927967d6 but that was not all. Both > vmstat and pwdx where failing as well. Attached patch will attempt to > fix both of unreported issues, and makes whole of the test suite to > work (at least on for me). +2 patches. Another bug, caused by me, is fixed, see attacment 0001 which takes care of: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=659038 Plus indentation clean up in patch 0002. -- Sami Kerola http://www.iki.fi/kerolasa/
From 4c3dbcf659363a5571c3a4c84280ce4e95c56ce5 Mon Sep 17 00:00:00 2001 From: Sami Kerola <kerolasa@xxxxxx> Date: Thu, 9 Feb 2012 22:53:29 +0100 Subject: [PATCH 1/2] skill: fix argument parsing regression Command skill accepted earlier command name as argument. This did not work since commit 991b8a94f0354a128085c7411713e17282c4e04a. Reference: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=659038 Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- skill.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/skill.c b/skill.c index 6802542..0ea21ca 100644 --- a/skill.c +++ b/skill.c @@ -594,9 +594,16 @@ static void skillsnice_parse(int argc, argv += optind; for (i = 0; i < argc; i++) { - ENLIST(pid, strtol_or_err(argv[0], - _("failed to parse argument"))); - pid_count++; + long num; + char *end = NULL; + errno = 0; + num = strtol(argv[0], &end, 10); + if (errno == 0 && argv[0] != end && end != NULL && *end == '\0') { + ENLIST(pid, num); + pid_count++; + } else { + ENLIST(cmd, argv[0]); + } argv++; } -- 1.7.9
From 0f189ee13ed1489568d511e98b35f617a25fef39 Mon Sep 17 00:00:00 2001 From: Sami Kerola <kerolasa@xxxxxx> Date: Thu, 9 Feb 2012 22:57:13 +0100 Subject: [PATCH 2/2] strutils: reindent the file Signed-off-by: Sami Kerola <kerolasa@xxxxxx> --- lib/strutils.c | 27 ++++++++++++++------------- 1 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/strutils.c b/lib/strutils.c index 14d4de7..bfe2cd0 100644 --- a/lib/strutils.c +++ b/lib/strutils.c @@ -15,15 +15,16 @@ long strtol_or_err(const char *str, const char *errmesg) long num; char *end = NULL; - if (str != NULL && *str != '\0') { - errno = 0; - num = strtol(str, &end, 10); - if (errno == 0 && str != end && end != NULL && *end == '\0') - return num; - } + if (str != NULL && *str != '\0') { + errno = 0; + num = strtol(str, &end, 10); + if (errno == 0 && str != end && end != NULL && *end == '\0') + return num; + } error(EXIT_FAILURE, errno, "%s: '%s'", errmesg, str); - return 0; + return 0; } + /* * same as strtod(3) but exit on failure instead of returning crap */ @@ -32,12 +33,12 @@ double strtod_or_err(const char *str, const char *errmesg) double num; char *end = NULL; - if (str != NULL && *str != '\0') { - errno = 0; - num = strtod(str, &end); - if (errno == 0 && str != end && end != NULL && *end == '\0') - return num; - } + if (str != NULL && *str != '\0') { + errno = 0; + num = strtod(str, &end); + if (errno == 0 && str != end && end != NULL && *end == '\0') + return num; + } error(EXIT_FAILURE, errno, "%s: '%s'", errmesg, str); return 0; } -- 1.7.9