Skip to content

Commit e14ab70

Browse files
kv2019ilgirdwood
authored andcommitted
tools: logger: fix parsing of -s argument
Fix logic for saving the snapshot file argument. getopt() is called at least once after snapshot option is parsed and getopt() will erase the optarg value when exiting the while loop. Without this patch, argument is always NULL and snapshot cannot be taken. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 5341ca1 commit e14ab70

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tools/logger/logger.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ int main(int argc, char *argv[])
132132
{
133133
struct convert_config config;
134134
unsigned int baud = 0;
135-
bool do_snapshot = false;
135+
const char *snapshot_file = 0;
136136
int opt, ret = 0;
137137

138138
config.trace = 0;
@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
167167
config.clock = atof(optarg);
168168
break;
169169
case 's':
170-
do_snapshot = true;
170+
snapshot_file = optarg;
171171
break;
172172
case 'l':
173173
config.ldc_file = optarg;
@@ -199,9 +199,9 @@ int main(int argc, char *argv[])
199199
}
200200
}
201201

202-
if (do_snapshot)
203-
return baud ? EINVAL : -snapshot(optarg);
204-
202+
if (snapshot_file)
203+
return baud ? EINVAL : -snapshot(snapshot_file);
204+
205205
if (!config.ldc_file) {
206206
fprintf(stderr, "error: Missing ldc file\n");
207207
usage();

0 commit comments

Comments
 (0)