WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] tools/xenstat/xentop/xentop.c -- fix xentop so it re

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] tools/xenstat/xentop/xentop.c -- fix xentop so it returns the correct exit code on invalid argument
From: ShaunR <mailinglists@xxxxxxxxxxxxxxxx>
Date: Fri, 22 Oct 2010 15:27:04 -0700
Delivery-date: Fri, 22 Oct 2010 15:29:32 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2
This patch fixes the problem with xentop where it returns an exit code of 0 when passing it invalid options when it should return 1. The issue comes from getopt() returning '?' and the case from switch matching it. The solution was to remove the case '?' so that the default match could be triggered.

Quote from `man 3 getopt`
"If getopt() does not recognize an option character, it prints an error message to stderr, stores the character in optopt, and returns '?'."





--- tools/xenstat/xentop/xentop.c-orig  2010-10-22 15:20:13.000000000 -0700
+++ tools/xenstat/xentop/xentop.c       2010-10-22 15:20:21.000000000 -0700
@@ -1135,7 +1135,6 @@
                default:
                        usage(argv[0]);
                        exit(1);
-               case '?':
                case 'h':
                        usage(argv[0]);
                        exit(0);


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] tools/xenstat/xentop/xentop.c -- fix xentop so it returns the correct exit code on invalid argument, ShaunR <=