From: Zdenek Kabelac <zkabelac@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH 6/6] Exit status 0 for 'dmsetup -c -o help'
Date: Thu, 08 Jul 2010 17:46:55 +0200 [thread overview]
Message-ID: <4C35F2EF.1080608@redhat.com> (raw)
In-Reply-To: <20100707181602.GC22664@agk-dp.fab.redhat.com>
Dne 7.7.2010 20:16, Alasdair G Kergon napsal(a):
> On Wed, Jul 07, 2010 at 02:29:36PM +0200, Zdenek Kabelac wrote:
>> diff --git a/tools/dmsetup.c b/tools/dmsetup.c
>> index 5e71542..479cbb0 100644
>> --- a/tools/dmsetup.c
>> +++ b/tools/dmsetup.c
>> @@ -3340,6 +3340,7 @@ int main(int argc, char **argv)
>> }
>>
>> if (argc == 0) {
>> + r = 0;
>> _usage(stderr);
>> goto out;
>
> How does that work?
>
> # dmsetup
>
> Should give failure status.
> (It already does.)
>
> # dmsetup help
>
> Should give success.
> (It already does.)
>
> # dmsetup -c -o help
>
> Should give success.
> (It doesn't.)
>
Here is second try to address only this explicit problem:
_report_init() is able to return 1 for 'help'/'?'
(same check is in libdm-report.c)
Following checks detects that 'info' invoked it.
What still looks weird is 'dmsetup ls -c -o help' - which returns 1 - but
displays meaningless help message for this command, (but this is not
influenced by this patch).
Zdenek
Index: tools/dmsetup.c
===================================================================
RCS file: /cvs/lvm2/LVM2/tools/dmsetup.c,v
retrieving revision 1.141
diff -u -p -r1.141 dmsetup.c
--- tools/dmsetup.c 8 Jul 2010 14:29:28 -0000 1.141
+++ tools/dmsetup.c 8 Jul 2010 15:40:35 -0000
@@ -2652,6 +2652,9 @@ static int _report_init(struct command *
r = 1;
out:
+ if (!strcasecmp(options, "help") || !strcmp(options, "?"))
+ r = 1;
+
if (len)
dm_free(options);
@@ -3360,8 +3363,15 @@ int main(int argc, char **argv)
if (!_switches[COLS_ARG] && !strcmp(c->name, "splitname"))
_switches[COLS_ARG]++;
- if (_switches[COLS_ARG] && !_report_init(c))
- goto out;
+ if (_switches[COLS_ARG]) {
+ if (!_report_init(c))
+ goto out;
+ if (!_report) {
+ if (!strcmp(c->name, "info"))
+ r = 0; /* info -c -o help */
+ goto out;
+ }
+ }
#ifdef UDEV_SYNC_SUPPORT
if (!_set_up_udev_support(dev_dir))
prev parent reply other threads:[~2010-07-08 15:46 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-07 12:29 [PATCH 0/6] Misc code updates Zdenek Kabelac
2010-07-07 12:29 ` [PATCH 1/6] Fix compiler warning about strict-aliasing break Zdenek Kabelac
2010-10-06 15:04 ` Petr Rockai
2010-07-07 12:29 ` [PATCH 2/6] configure changes - AC_HELP_STRING, AH_TEMPLATE Zdenek Kabelac
2010-07-07 18:10 ` Alasdair G Kergon
2010-07-07 12:29 ` [PATCH 3/6] nextbit Zdenek Kabelac
2010-07-07 18:49 ` Alasdair G Kergon
2010-07-07 12:29 ` [PATCH 4/6] Do not show backtrace Zdenek Kabelac
2010-07-07 18:54 ` Alasdair G Kergon
2010-07-07 12:29 ` [PATCH 5/6] Better alligned debug message - memlock Zdenek Kabelac
2010-07-07 18:19 ` Alasdair G Kergon
2010-07-07 12:29 ` [PATCH 6/6] Exit status 0 for 'dmsetup -c -o help' Zdenek Kabelac
2010-07-07 18:16 ` Alasdair G Kergon
2010-07-08 15:46 ` Zdenek Kabelac [this message]
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=4C35F2EF.1080608@redhat.com \
--to=zkabelac@redhat.com \
--cc=lvm-devel@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.