public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Reisner <d@falconindy.com>
To: Sami Kerola <kerolasa@iki.fi>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH 14/15] hexdump: remove unnecessary global variables
Date: Mon, 2 Sep 2013 19:22:39 -0400	[thread overview]
Message-ID: <20130902232239.GA6888@rampage> (raw)
In-Reply-To: <1371408836-16663-15-git-send-email-kerolasa@iki.fi>

On Sun, Jun 16, 2013 at 07:53:55PM +0100, Sami Kerola wrote:
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
> ---
>  text-utils/display.c | 6 +++---
>  text-utils/hexdump.c | 4 ++--
>  text-utils/hexdump.h | 2 --
>  3 files changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/text-utils/display.c b/text-utils/display.c
> index 1f9a11b..41ddd8d 100644
> --- a/text-utils/display.c
> +++ b/text-utils/display.c
> @@ -295,7 +295,7 @@ get(void)
>  int next(char **argv)
>  {
>  	static int done;
> -	int statok;
> +	int statok, exitval = 0;
>  
>  	if (argv) {
>  		_argv = argv;
> @@ -305,14 +305,14 @@ int next(char **argv)
>  		if (*_argv) {
>  			if (!(freopen(*_argv, "r", stdin))) {
>  				warn("%s", *_argv);
> -				exitval = EXIT_FAILURE;
> +				exitval = 1;
>  				++_argv;
>  				continue;
>  			}
>  			statok = done = 1;
>  		} else {
>  			if (done++)
> -				return(0);
> +				return(exitval);
>  			statok = 0;
>  		}
>  		if (skip)
> diff --git a/text-utils/hexdump.c b/text-utils/hexdump.c
> index e966cc3..411d809 100644
> --- a/text-utils/hexdump.c
> +++ b/text-utils/hexdump.c
> @@ -47,11 +47,11 @@
>  
>  FS *fshead;				/* head of format strings */
>  ssize_t blocksize;			/* data block size */
> -int exitval;				/* final exit value */
>  ssize_t length = -1;			/* max bytes to read */
>  
>  int main(int argc, char **argv)
>  {
> +	int exitval;			/* final exit value */
>  	FS *tfs;
>  	char *p;
>  
> @@ -76,7 +76,7 @@ int main(int argc, char **argv)
>  	for (tfs = fshead; tfs; tfs = tfs->nextfs)
>  		rewrite(tfs);
>  
> -	(void)next(argv);
> +	exitval = next(argv);

A little late to the game, but this commit breaks the return value of
hexdump and causes it to always return 1, even on successful invocation.
next(char**) will always return 1 for the usual (non-NULL) values of argv.

d

>  	display();
>  	return exitval;
>  }
> diff --git a/text-utils/hexdump.h b/text-utils/hexdump.h
> index b9e67a1..b2ea1f1 100644
> --- a/text-utils/hexdump.h
> +++ b/text-utils/hexdump.h
> @@ -73,8 +73,6 @@ typedef struct _fs {			/* format strings */
>  extern FU *endfu;
>  extern FS *fshead;			/* head of format strings list */
>  extern ssize_t blocksize;		/* data block size */
> -extern int deprecated;			/* od compatibility */
> -extern int exitval;			/* final exit value */
>  extern ssize_t length;			/* max bytes to read */
>  extern off_t skip;                      /* bytes to skip */
>  
> -- 
> 1.8.3.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2013-09-02 23:22 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-16 18:53 [PATCH 00/15] pull: sfdisk and dmesg resubmission, plus bits and bobs Sami Kerola
2013-06-16 18:53 ` [PATCH 01/15] renice: exit with non-zero value when arguments cause warnings Sami Kerola
2013-06-16 18:53 ` [PATCH 02/15] sfdisk: use libc error printing function, and symbolic exit values Sami Kerola
2013-06-16 18:53 ` [PATCH 03/15] sfdisk: clean up usage() functions Sami Kerola
2013-06-16 18:53 ` [PATCH 04/15] sfdisk: use program_invocation_short_name to determine program name Sami Kerola
2013-06-16 18:53 ` [PATCH 05/15] docs: correct sfdisk --activate instructions Sami Kerola
2013-06-16 18:53 ` [PATCH 06/15] sfdisk: remove --unhide and related functions Sami Kerola
2013-06-16 18:53 ` [PATCH 07/15] sfdisk: replace my_warn() with warnx() Sami Kerola
2013-06-16 18:53 ` [PATCH 08/15] dmesg: convert time format bitfield to enum Sami Kerola
2013-07-01  9:36   ` Karel Zak
2013-06-16 18:53 ` [PATCH 09/15] dmesg: add --time-format option Sami Kerola
2013-06-16 18:53 ` [PATCH 10/15] dmesg: add iso-8601 time format Sami Kerola
2013-07-01  9:25   ` Karel Zak
2013-07-01 10:54     ` Sami Kerola
2013-06-16 18:53 ` [PATCH 11/15] docs: add --time-format option and ISO-8601 format to manual Sami Kerola
2013-06-16 18:53 ` [PATCH 12/15] dmesg: regroup time related options close to each other Sami Kerola
2013-06-16 18:53 ` [PATCH 13/15] sd-daemon: update files taken from systemd project Sami Kerola
2013-06-16 18:53 ` [PATCH 14/15] hexdump: remove unnecessary global variables Sami Kerola
2013-09-02 23:22   ` Dave Reisner [this message]
2013-09-03  7:15     ` Sami Kerola
2013-09-03  8:29       ` Karel Zak
2013-06-16 18:53 ` [PATCH 15/15] hexdump: use simple printing functions when possible Sami Kerola
2013-07-01  9:01   ` Karel Zak
2013-07-01 10:58     ` Sami Kerola
2013-06-17 12:31 ` [PATCH 00/15] pull: sfdisk and dmesg resubmission, plus bits and bobs Karel Zak
2013-06-17 20:14   ` Sami Kerola
2013-07-01  9:39 ` Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130902232239.GA6888@rampage \
    --to=d@falconindy.com \
    --cc=kerolasa@iki.fi \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox