Skip to content

Commit 06d4ef0

Browse files
committed
Simplify the handling and documentation of mutually exclusive output
format options.
1 parent 6543db2 commit 06d4ef0

File tree

2 files changed

+13
-26
lines changed

2 files changed

+13
-26
lines changed

dmiopt.c

+6-18
Original file line numberDiff line numberDiff line change
@@ -280,28 +280,16 @@ int parse_command_line(int argc, char * const argv[])
280280
return -1;
281281
}
282282

283-
if(opt.type!=NULL && opt.string!=NULL)
283+
/* Check for mutually exclusive output format options */
284+
if((opt.string!=NULL)+(opt.type!=NULL)
285+
+!!(opt.flags & FLAG_DUMP)+!!(opt.flags & FLAG_DUMP_BIN)>1)
284286
{
285-
fprintf(stderr, "Options --string and --type are mutually exclusive\n");
287+
fprintf(stderr, "Options --string, --type, --dump and --dump-bin are mutually exclusive\n");
286288
return -1;
287289
}
290+
if(opt.flags & (FLAG_DUMP | FLAG_DUMP_BIN))
291+
opt.flags&=~FLAG_QUIET;
288292

289-
if((opt.flags & FLAG_DUMP) && opt.string!=NULL)
290-
{
291-
fprintf(stderr, "Options --string and --dump are mutually exclusive\n");
292-
return -1;
293-
}
294-
295-
if((opt.flags & FLAG_DUMP) && (opt.flags & FLAG_QUIET))
296-
{
297-
fprintf(stderr, "Options --quiet and --dump are mutually exclusive\n");
298-
return -1;
299-
}
300-
if((opt.flags & FLAG_DUMP_BIN) && (opt.type!=NULL || opt.string!=NULL))
301-
{
302-
fprintf(stderr, "Options --dump-bin, --string and --type are mutually exclusive\n");
303-
return -1;
304-
}
305293
if((opt.flags & FLAG_FROM_DUMP) && (opt.flags & FLAG_DUMP_BIN))
306294
{
307295
fprintf(stderr, "Options --from-dump and --dump-bin are mutually exclusive\n");

man/dmidecode.8

+7-8
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ Read memory from device \fBFILE\fR (default: \fB/dev/mem\fR)
6262
.TP
6363
.BR "-q" ", " "--quiet"
6464
Be less verbose. Unknown, inactive and \s-1OEM\s0-specific entries are not
65-
displayed. Meta-data and handle references are hidden. Mutually exclusive
66-
with \fB--dump\fR.
65+
displayed. Meta-data and handle references are hidden.
6766
.TP
6867
.BR "-s" ", " "--string KEYWORD"
6968
Only display the value of the \s-1DMI\s0 string identified by \fBKEYWORD\fR.
@@ -89,8 +88,7 @@ If \fBKEYWORD\fR is not provided or not valid, a list of all valid
8988
keywords is printed and
9089
.B dmidecode
9190
exits with an error.
92-
This option cannot be used more than once, and implies \fB--quiet\fR.
93-
Mutually exclusive with \fB--type\fR and \fB--dump\fR.
91+
This option cannot be used more than once.
9492
.TP
9593
.BR "-t" ", " "--type TYPE"
9694
Only display the entries of type \fBTYPE\fR. \fBTYPE\fR can be either a
@@ -105,29 +103,30 @@ If \fBTYPE\fR is not provided or not valid, a list of all valid keywords
105103
is printed and
106104
.B dmidecode
107105
exits with an error.
108-
Mutually exclusive with \fB--string\fR.
109106
.TP
110107
.BR "-u" ", " "--dump"
111108
Do not decode the entries, dump their contents as hexadecimal instead.
112109
Note that this is still a text output, no binary data will be thrown upon
113110
you. The strings attached to each entry are displayed as both
114111
hexadecimal and \s-1ASCII\s0. This option is mainly useful for debugging.
115-
Mutually exclusive with \fB--quiet\fR and \fB--string\fR.
116112
.TP
117113
.BR " " " " "--dump-bin FILE"
118114
Do not decode the entries, instead dump the DMI data to a file in binary
119115
form. The generated file is suitable to pass to \fB--from-dump\fR
120-
later. Mutually exclusive with \fB--type\fR and \fB--string\fR.
116+
later.
121117
.TP
122118
.BR " " " " "--from-dump FILE"
123119
Read the DMI data from a binary file previously generated using
124-
\fB--dump-bin\fR. Mutually exclusive with \fB--dump-bin\fR.
120+
\fB--dump-bin\fR.
125121
.TP
126122
.BR "-h" ", " "--help"
127123
Display usage information and exit
128124
.TP
129125
.BR "-V" ", " "--version"
130126
Display the version and exit
127+
.P
128+
Options --string, --type, --dump and --dump-bin
129+
determine the output format and are mutually exclusive.
131130

132131
.SH "DMI TYPES"
133132
The \s-1SMBIOS\s0 specification defines the following \s-1DMI\s0 types:

0 commit comments

Comments
 (0)