diff options
author | Thomas Wood <thomas.wood@intel.com> | 2014-10-31 12:32:22 +0000 |
---|---|---|
committer | Thomas Wood <thomas.wood@intel.com> | 2014-11-06 11:41:34 +0000 |
commit | db425d69f62690a95048fde6d5dc515686bfa9ac (patch) | |
tree | 01ceae8464c7b5894aeacbb21c12a13d69b580e3 /tests/testdisplay.c | |
parent | b441e6ac2ac98ee2f365683f339c8802d238043f (diff) |
testdisplay: ensure invalid long option exit status is non-zero
The optopt variable is not set if an invalid long option is used, so
check the current option character instead.
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
Diffstat (limited to 'tests/testdisplay.c')
-rw-r--r-- | tests/testdisplay.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/testdisplay.c b/tests/testdisplay.c index 09e07f0f..8c6bc62c 100644 --- a/tests/testdisplay.c +++ b/tests/testdisplay.c @@ -545,7 +545,7 @@ int update_display(void) static char optstr[] = "3hiaf:s:d:p:mrto:j:"; -static void __attribute__((noreturn)) usage(char *name) +static void __attribute__((noreturn)) usage(char *name, char opt) { igt_info("usage: %s [-hiasdpmtf]\n", name); igt_info("\t-i\tdump info\n"); @@ -563,7 +563,7 @@ static void __attribute__((noreturn)) usage(char *name) igt_info("\t\t<vdisp>,<vsync-start>,<vsync-end>,<vtotal>\n"); igt_info("\t\ttest force mode\n"); igt_info("\tDefault is to test all modes.\n"); - exit((optopt) ? -1 : 0); + exit((opt != 'h') ? -1 : 0); } #define dump_resource(res) if (res) dump_##res() @@ -665,7 +665,7 @@ int main(int argc, char **argv) if(sscanf(optarg,"%f,%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu", &force_clock,&force_timing.hdisplay, &force_timing.hsync_start,&force_timing.hsync_end,&force_timing.htotal, &force_timing.vdisplay, &force_timing.vsync_start, &force_timing.vsync_end, &force_timing.vtotal)!= 9) - usage(argv[0]); + usage(argv[0], c); force_timing.clock = force_clock*1000; break; @@ -685,7 +685,7 @@ int main(int argc, char **argv) if (sscanf(optarg, "%d,%d,%d,%d,%d,%d", &plane_width, &plane_height, &crtc_x, &crtc_y, &crtc_w, &crtc_h) != 6) - usage(argv[0]); + usage(argv[0], c); test_plane = 1; break; case 'm': @@ -707,7 +707,7 @@ int main(int argc, char **argv) default: /* fall through */ case 'h': - usage(argv[0]); + usage(argv[0], c); break; } } |