Skip to content

Commit ac92574

Browse files
committed
utils: make some messages only appear in non-silent mode when parsing cmdline location
Signed-off-by: Brice Goglin <[email protected]>
1 parent 94b5141 commit ac92574

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

utils/hwloc/hwloc-calc.h

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ hwloc_calc_parse_depth_prefix(struct hwloc_calc_location_context_s *lcontext,
195195
static __hwloc_inline int
196196
hwloc_calc_parse_range(const char *_string,
197197
int *firstp, int *amountp, int *stepp, int *wrapp,
198-
const char **dotp)
198+
const char **dotp,
199+
int verbose)
199200
{
200201
char string[65];
201202
size_t len;
@@ -211,7 +212,8 @@ hwloc_calc_parse_range(const char *_string,
211212
len = strlen(_string);
212213
}
213214
if (len >= sizeof(string)) {
214-
fprintf(stderr, "invalid range `%s', too long\n", _string);
215+
if (verbose >= 0)
216+
fprintf(stderr, "invalid range `%s', too long\n", _string);
215217
return -1;
216218
}
217219
memcpy(string, _string, len);
@@ -237,7 +239,8 @@ hwloc_calc_parse_range(const char *_string,
237239
*wrapp = 0;
238240
return 0;
239241
} else {
240-
fprintf(stderr, "unrecognized range keyword `%s'\n", string);
242+
if (verbose >= 0)
243+
fprintf(stderr, "unrecognized range keyword `%s'\n", string);
241244
return -1;
242245
}
243246
}
@@ -249,7 +252,8 @@ hwloc_calc_parse_range(const char *_string,
249252
if (*end == '-') {
250253
last = strtol(end+1, &end2, 10);
251254
if (*end2) {
252-
fprintf(stderr, "invalid character at `%s' after range at `%s'\n", end2, string);
255+
if (verbose >= 0)
256+
fprintf(stderr, "invalid character at `%s' after range at `%s'\n", end2, string);
253257
return -1;
254258
} else if (end2 == end+1) {
255259
/* X- */
@@ -264,15 +268,18 @@ hwloc_calc_parse_range(const char *_string,
264268
wrap = 1;
265269
amount = strtol(end+1, &end2, 10);
266270
if (*end2) {
267-
fprintf(stderr, "invalid character at `%s' after range at `%s'\n", end2, string);
271+
if (verbose >= 0)
272+
fprintf(stderr, "invalid character at `%s' after range at `%s'\n", end2, string);
268273
return -1;
269274
} else if (end2 == end+1) {
270-
fprintf(stderr, "missing width at `%s' in range at `%s'\n", end2, string);
275+
if (verbose >= 0)
276+
fprintf(stderr, "missing width at `%s' in range at `%s'\n", end2, string);
271277
return -1;
272278
}
273279

274280
} else if (*end) {
275-
fprintf(stderr, "invalid character at `%s' after index at `%s'\n", end, string);
281+
if (verbose >= 0)
282+
fprintf(stderr, "invalid character at `%s' after index at `%s'\n", end, string);
276283
return -1;
277284
}
278285

@@ -300,7 +307,8 @@ hwloc_calc_append_object_range(struct hwloc_calc_location_context_s *lcontext,
300307

301308
err = hwloc_calc_parse_range(string,
302309
&first, &amount, &step, &wrap,
303-
&dot);
310+
&dot,
311+
verbose);
304312
if (err < 0)
305313
return -1;
306314
assert(amount != -1 || !wrap);
@@ -466,7 +474,8 @@ hwloc_calc_append_iodev_by_index(struct hwloc_calc_location_context_s *lcontext,
466474
current++;
467475
err = hwloc_calc_parse_range(current,
468476
&first, &amount, &step, &wrap,
469-
&dot);
477+
&dot,
478+
verbose);
470479
if (dot) {
471480
fprintf(stderr, "hierarchical location %s only supported with normal object types\n", string);
472481
return -1;

0 commit comments

Comments
 (0)