summaryrefslogtreecommitdiff
path: root/tools/intel_reg_spec.c
diff options
context:
space:
mode:
authorPetri Latvala <petri.latvala@intel.com>2018-10-29 16:30:52 +0200
committerPetri Latvala <petri.latvala@intel.com>2018-11-05 14:12:53 +0200
commit9e0df467091490f5d4b6fd6282d5a4f17e338718 (patch)
treee88a7d59f003b84b56c5f89f91a95672fe2edfe1 /tools/intel_reg_spec.c
parentf797c395bf13d06e67448e9c4d459fc996eb3cc1 (diff)
runner: const-correct the unit tests
const where possible, and cast away const when passing argv to parse_options, which expects non-const strings, because it passes them to getopt_long, which expects non-const strings... getopt and getopt_long take the argv array as char * const *, or in other words, as pointer-to-const-pointer-to-char. In C, pointer-to-T implicitly converts to pointer-to-const-T and for a char **, the T is char* and "const T" is char * const, ergo char ** converts to char * const *, not const char **. The only const-correctness getopt and getopt_long can really do is char * const * or they lose the ability to directly pass in main()'s arguments, which are an array of non-const pointers to non-const char for legacy reasons. For testing the argument handling, it's very convenient to use an array of string literals, which are of type const char[N], convertible to const char *. To get such an array into getopt, the choices are: 1) Cast away the const in the pointer-to-pointer 2) Cast away the const in the string literal 3) Don't cast anything and eat the compiler warning Option 1 looked cleanest out of all those. tl;dr: Choices made in 1972 force our hand. v2: - Augment commit message Signed-off-by: Petri Latvala <petri.latvala@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'tools/intel_reg_spec.c')
0 files changed, 0 insertions, 0 deletions