== SYNOPSIS
-*bits* [*-h*] [*-V*] [*-w* _number_] [_mode_] [_mask_|_list_]...
+*bits* [*-h*] [*-V*] [*-w* _number_] [*-f*] [_mode_] [_mask_|_list_]...
== DESCRIPTION
*-w* _number_, *--width* _number_::
The maximum number of bits in the masks handled by *bits*.
-The default is *8192*. Any bit larger than this number will be truncated.
+The default is *8192*. Any bit larger than this number will be truncated
+unless *--fail-width* is specified.
+
+*-f*, *--fail-width*::
+Fail with an error if the bit list contains values larger than the
+*--width* limit. By default, such values are silently ignored.
include::man-common/help-version.adoc[]
#include "xalloc.h"
static void parse_mask_or_list(const char *cmdline_arg,
- cpu_set_t *all_bits, size_t width)
+ cpu_set_t *all_bits, size_t width, int fail_width)
{
cpu_set_t *bits, *copy;
char bitwise_op = '|';
if (cpumask_parse(arg, bits, size) < 0)
errx(EXIT_FAILURE, _("error: invalid bit mask: %s"), cmdline_arg);
} else {
- int rc = cpulist_parse(arg, bits, size, 1);
+ int rc = cpulist_parse(arg, bits, size, fail_width);
if (rc == 1)
errx(EXIT_FAILURE, _("error: invalid bit list: %s"), cmdline_arg);
else if (rc == 2)
fputsln(_(" -w <num>, --width <num>\n"
" maximum width of bit masks (default 8192)"),
stdout);
+ fputsln(_(" -f, --fail-width fail if bit list contains values wider than width"),
+ stdout);
fputs(_("\nOutput modes:\n"), stdout);
fputsln(_(" -m, --mask display bits as a hex mask value (default)"),
cpu_set_t *bits = NULL;
size_t width = 8192;
size_t alloc_size;
+ int fail_width = 0;
int c;
-#define FLAGS "Vhw:mgble"
+#define FLAGS "Vhw:mgblef"
static const struct option longopts[] = {
{ "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' },
{ "binary", no_argument, NULL, 'b' },
{ "expand", no_argument, NULL, 'e' },
{ "list", no_argument, NULL, 'l' },
+ { "fail-width", no_argument, NULL, 'f' },
{ NULL, 0, NULL, 0 }
};
if (width == 0)
errx(EXIT_FAILURE, _("invalid --width"));
break;
+ case 'f':
+ fail_width = 1;
+ break;
case 'V':
print_version(EXIT_SUCCESS);
case 'h':
memset(bits, 0, alloc_size);
for (; argc > 0; argc--, argv++)
- parse_mask_or_list(*argv, bits, width);
+ parse_mask_or_list(*argv, bits, width, fail_width);
ul_strv_free(stdin_lines);