mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Mirko Damiani <mirko@develer.com>
To: barebox@lists.infradead.org
Subject: [PATCH] net: ping: return an error exit code when connection fails
Date: Mon, 16 Mar 2015 16:02:41 +0100	[thread overview]
Message-ID: <5506F091.2040009@develer.com> (raw)

Hi,
ping command does not always returns 1 as exit code when connection to 
host fails.
In particular it returns the exit code of the previous run.
This patch fixes this issue.


Signed-off-by: Mirko Damiani <mirko@develer.com>
---
  net/ping.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ping.c b/net/ping.c
index 2349f4b..4eb77cb 100644
--- a/net/ping.c
+++ b/net/ping.c
@@ -67,6 +67,9 @@ static int do_ping(int argc, char *argv[])
          return 1;
      }

+    ping_state = PING_STATE_INIT;
+    ping_sequence_number = 0;
+
      ping_con = net_icmp_new(net_ping_ip, ping_handler, NULL);
      if (IS_ERR(ping_con)) {
          ret = PTR_ERR(ping_con);
@@ -78,9 +81,6 @@ static int do_ping(int argc, char *argv[])
      if (ret)
          goto out_unreg;

-    ping_state = PING_STATE_INIT;
-    ping_sequence_number = 0;
-
      while (ping_state == PING_STATE_INIT) {
          if (ctrlc()) {
              ret = -EINTR;
-- 
1.9.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2015-03-16 15:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-16 15:02 Mirko Damiani [this message]
2015-03-16 16:09 ` mirko
2015-03-17  7:11   ` Sascha Hauer

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=5506F091.2040009@develer.com \
    --to=mirko@develer.com \
    --cc=barebox@lists.infradead.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