From: Kristian Høgsberg Date: Wed, 20 Feb 2013 20:27:49 +0000 (-0500) Subject: Pass argc pointer to parse_options() X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4172f668e7838a0e89d09b569d99745228c1c9c0;p=profile%2Fivi%2Fweston-ivi-shell.git Pass argc pointer to parse_options() This lets us keep argc up to date as the backend picks out arguments from the argv array. --- diff --git a/clients/calibrator.c b/clients/calibrator.c index 3b9f2fc..cc6f4ed 100644 --- a/clients/calibrator.c +++ b/clients/calibrator.c @@ -238,7 +238,7 @@ main(int argc, char *argv[]) struct display *display; struct calibrator *calibrator; - display = display_create(argc, argv); + display = display_create(&argc, argv); if (display == NULL) { fprintf(stderr, "failed to create display: %m\n"); diff --git a/clients/clickdot.c b/clients/clickdot.c index c74bc91..714b4b9 100644 --- a/clients/clickdot.c +++ b/clients/clickdot.c @@ -297,7 +297,7 @@ main(int argc, char *argv[]) struct display *display; struct clickdot *clickdot; - display = display_create(argc, argv); + display = display_create(&argc, argv); if (display == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/cliptest.c b/clients/cliptest.c index 4dd4380..b824715 100644 --- a/clients/cliptest.c +++ b/clients/cliptest.c @@ -890,7 +890,7 @@ main(int argc, char *argv[]) if (argc > 1) return benchmark(); - d = display_create(argc, argv); + d = display_create(&argc, argv); if (d == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c index 1cae789..41e7daa 100644 --- a/clients/desktop-shell.c +++ b/clients/desktop-shell.c @@ -1094,7 +1094,7 @@ int main(int argc, char *argv[]) desktop.unlock_task.run = unlock_dialog_finish; wl_list_init(&desktop.outputs); - desktop.display = display_create(argc, argv); + desktop.display = display_create(&argc, argv); if (desktop.display == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/dnd.c b/clients/dnd.c index 4aad070..140f3f4 100644 --- a/clients/dnd.c +++ b/clients/dnd.c @@ -614,7 +614,7 @@ main(int argc, char *argv[]) struct dnd *dnd; int i; - d = display_create(argc, argv); + d = display_create(&argc, argv); if (d == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/editor.c b/clients/editor.c index 32c3f9b..0de2500 100644 --- a/clients/editor.c +++ b/clients/editor.c @@ -1056,7 +1056,7 @@ main(int argc, char *argv[]) g_type_init(); #endif - editor.display = display_create(argc, argv); + editor.display = display_create(&argc, argv); if (editor.display == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/eventdemo.c b/clients/eventdemo.c index e59b076..05ad5dc 100644 --- a/clients/eventdemo.c +++ b/clients/eventdemo.c @@ -390,11 +390,11 @@ main(int argc, char *argv[]) struct display *d; struct eventdemo *e; - argc = parse_options(eventdemo_options, - ARRAY_LENGTH(eventdemo_options), argc, argv); + parse_options(eventdemo_options, + ARRAY_LENGTH(eventdemo_options), &argc, argv); /* Connect to the display and have the arguments parsed */ - d = display_create(argc, argv); + d = display_create(&argc, argv); if (d == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/flower.c b/clients/flower.c index 21c38bf..87a1a00 100644 --- a/clients/flower.c +++ b/clients/flower.c @@ -159,7 +159,7 @@ int main(int argc, char *argv[]) struct display *d; struct timeval tv; - d = display_create(argc, argv); + d = display_create(&argc, argv); if (d == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/gears.c b/clients/gears.c index a622cda..e7249eb 100644 --- a/clients/gears.c +++ b/clients/gears.c @@ -474,7 +474,7 @@ int main(int argc, char *argv[]) { struct display *d; - d = display_create(argc, argv); + d = display_create(&argc, argv); if (d == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/image.c b/clients/image.c index e25a665..cbd466c 100644 --- a/clients/image.c +++ b/clients/image.c @@ -410,7 +410,7 @@ main(int argc, char *argv[]) int i; int image_counter = 0; - d = display_create(argc, argv); + d = display_create(&argc, argv); if (d == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/keyboard.c b/clients/keyboard.c index 3760ff7..ad34b85 100644 --- a/clients/keyboard.c +++ b/clients/keyboard.c @@ -706,7 +706,7 @@ main(int argc, char *argv[]) memset(&virtual_keyboard, 0, sizeof virtual_keyboard); - virtual_keyboard.display = display_create(argc, argv); + virtual_keyboard.display = display_create(&argc, argv); if (virtual_keyboard.display == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/resizor.c b/clients/resizor.c index d02ab29..27879a0 100644 --- a/clients/resizor.c +++ b/clients/resizor.c @@ -281,7 +281,7 @@ main(int argc, char *argv[]) struct display *display; struct resizor *resizor; - display = display_create(argc, argv); + display = display_create(&argc, argv); if (display == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/smoke.c b/clients/smoke.c index 80b8c58..5d7333d 100644 --- a/clients/smoke.c +++ b/clients/smoke.c @@ -279,7 +279,7 @@ int main(int argc, char *argv[]) struct display *d; int size; - d = display_create(argc, argv); + d = display_create(&argc, argv); if (d == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/tablet-shell.c b/clients/tablet-shell.c index 993da7c..f756cbc 100644 --- a/clients/tablet-shell.c +++ b/clients/tablet-shell.c @@ -459,7 +459,7 @@ int main(int argc, char *argv[]) char *config_file; struct output *output; - display = display_create(argc, argv); + display = display_create(&argc, argv); if (display == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/terminal.c b/clients/terminal.c index 664df5d..e80e0e5 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -2683,10 +2683,10 @@ int main(int argc, char *argv[]) NULL); free(config_file); - argc = parse_options(terminal_options, - ARRAY_LENGTH(terminal_options), argc, argv); + parse_options(terminal_options, + ARRAY_LENGTH(terminal_options), &argc, argv); - d = display_create(argc, argv); + d = display_create(&argc, argv); if (d == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/transformed.c b/clients/transformed.c index 75c1250..8983bb5 100644 --- a/clients/transformed.c +++ b/clients/transformed.c @@ -264,7 +264,7 @@ int main(int argc, char *argv[]) usage(EXIT_FAILURE); } - d = display_create(argc, argv); + d = display_create(&argc, argv); if (d == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/view.c b/clients/view.c index 1bb9b9b..c8ced15 100644 --- a/clients/view.c +++ b/clients/view.c @@ -295,10 +295,9 @@ main(int argc, char *argv[]) g_type_init(); - argc = parse_options(view_options, - ARRAY_LENGTH(view_options), argc, argv); + parse_options(view_options, ARRAY_LENGTH(view_options), &argc, argv); - d = display_create(argc, argv); + d = display_create(&argc, argv); if (d == NULL) { fprintf(stderr, "failed to create display: %m\n"); return -1; diff --git a/clients/window.c b/clients/window.c index d917550..249ba6f 100644 --- a/clients/window.c +++ b/clients/window.c @@ -4329,7 +4329,7 @@ handle_display_data(struct task *task, uint32_t events) } struct display * -display_create(int argc, char *argv[]) +display_create(int *argc, char *argv[]) { struct display *d; diff --git a/clients/window.h b/clients/window.h index 646b3dd..c2946d8 100644 --- a/clients/window.h +++ b/clients/window.h @@ -53,7 +53,7 @@ struct rectangle { }; struct display * -display_create(int argc, char *argv[]); +display_create(int *argc, char *argv[]); void display_destroy(struct display *display); diff --git a/clients/wscreensaver.c b/clients/wscreensaver.c index e0c165a..9a2c47a 100644 --- a/clients/wscreensaver.c +++ b/clients/wscreensaver.c @@ -310,10 +310,10 @@ int main(int argc, char *argv[]) init_frand(); - argc = parse_options(wscreensaver_options, - ARRAY_LENGTH(wscreensaver_options), argc, argv); + parse_options(wscreensaver_options, + ARRAY_LENGTH(wscreensaver_options), &argc, argv); - d = display_create(argc, argv); + d = display_create(&argc, argv); if (d == NULL) { fprintf(stderr, "failed to create display: %m\n"); return EXIT_FAILURE; diff --git a/shared/config-parser.h b/shared/config-parser.h index 7fa9c3f..314057a 100644 --- a/shared/config-parser.h +++ b/shared/config-parser.h @@ -67,7 +67,7 @@ struct weston_option { int parse_options(const struct weston_option *options, - int count, int argc, char *argv[]); + int count, int *argc, char *argv[]); #endif /* CONFIGPARSER_H */ diff --git a/shared/option-parser.c b/shared/option-parser.c index 600f110..a7e497f 100644 --- a/shared/option-parser.c +++ b/shared/option-parser.c @@ -51,11 +51,11 @@ handle_option(const struct weston_option *option, char *value) int parse_options(const struct weston_option *options, - int count, int argc, char *argv[]) + int count, int *argc, char *argv[]) { int i, j, k, len = 0; - for (i = 1, j = 1; i < argc; i++) { + for (i = 1, j = 1; i < *argc; i++) { for (k = 0; k < count; k++) { if (options[k].name) len = strlen(options[k].name); @@ -77,6 +77,7 @@ parse_options(const struct weston_option *options, argv[j++] = argv[i]; } argv[j] = NULL; + *argc = j; return j; } diff --git a/src/compositor-drm.c b/src/compositor-drm.c index c170f97..a824324 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -2134,7 +2134,7 @@ planes_binding(struct wl_seat *seat, uint32_t time, uint32_t key, void *data) static struct weston_compositor * drm_compositor_create(struct wl_display *display, int connector, const char *seat, int tty, int pixman, - int argc, char *argv[], const char *config_file) + int *argc, char *argv[], const char *config_file) { struct drm_compositor *ec; struct udev_device *drm_device; @@ -2430,7 +2430,7 @@ output_section_done(void *data) } WL_EXPORT struct weston_compositor * -backend_init(struct wl_display *display, int argc, char *argv[], +backend_init(struct wl_display *display, int *argc, char *argv[], const char *config_file) { int connector = 0, tty = 0, use_pixman = 0; diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c index 1df3bbc..070d187 100644 --- a/src/compositor-fbdev.c +++ b/src/compositor-fbdev.c @@ -826,7 +826,7 @@ switch_vt_binding(struct wl_seat *seat, uint32_t time, uint32_t key, void *data) } static struct weston_compositor * -fbdev_compositor_create(struct wl_display *display, int argc, char *argv[], +fbdev_compositor_create(struct wl_display *display, int *argc, char *argv[], const char *config_file, struct fbdev_parameters *param) { struct fbdev_compositor *compositor; @@ -897,7 +897,7 @@ out_free: } WL_EXPORT struct weston_compositor * -backend_init(struct wl_display *display, int argc, char *argv[], +backend_init(struct wl_display *display, int *argc, char *argv[], const char *config_file) { /* TODO: Ideally, available frame buffers should be enumerated using diff --git a/src/compositor-headless.c b/src/compositor-headless.c index 03bd0a4..1e286fa 100644 --- a/src/compositor-headless.c +++ b/src/compositor-headless.c @@ -152,7 +152,7 @@ headless_destroy(struct weston_compositor *ec) static struct weston_compositor * headless_compositor_create(struct wl_display *display, int width, int height, const char *display_name, - int argc, char *argv[], const char *config_file) + int *argc, char *argv[], const char *config_file) { struct headless_compositor *c; @@ -187,7 +187,7 @@ err_free: } WL_EXPORT struct weston_compositor * -backend_init(struct wl_display *display, int argc, char *argv[], +backend_init(struct wl_display *display, int *argc, char *argv[], const char *config_file) { int width = 1024, height = 640; diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c index 208271f..d3767b9 100644 --- a/src/compositor-rpi.c +++ b/src/compositor-rpi.c @@ -1423,7 +1423,7 @@ struct rpi_parameters { }; static struct weston_compositor * -rpi_compositor_create(struct wl_display *display, int argc, char *argv[], +rpi_compositor_create(struct wl_display *display, int *argc, char *argv[], const char *config_file, struct rpi_parameters *param) { struct rpi_compositor *compositor; @@ -1536,7 +1536,7 @@ out_free: #define DEFAULT_MAX_PLANES 80 WL_EXPORT struct weston_compositor * -backend_init(struct wl_display *display, int argc, char *argv[], +backend_init(struct wl_display *display, int *argc, char *argv[], const char *config_file) { struct rpi_parameters param = { diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c index af493e7..66e9695 100644 --- a/src/compositor-wayland.c +++ b/src/compositor-wayland.c @@ -622,7 +622,7 @@ wayland_destroy(struct weston_compositor *ec) static struct weston_compositor * wayland_compositor_create(struct wl_display *display, int width, int height, const char *display_name, - int argc, char *argv[], const char *config_file) + int *argc, char *argv[], const char *config_file) { struct wayland_compositor *c; struct wl_event_loop *loop; @@ -697,7 +697,7 @@ err_free: } WL_EXPORT struct weston_compositor * -backend_init(struct wl_display *display, int argc, char *argv[], +backend_init(struct wl_display *display, int *argc, char *argv[], const char *config_file) { int width = 1024, height = 640; diff --git a/src/compositor-x11.c b/src/compositor-x11.c index 9cc41fd..1119934 100644 --- a/src/compositor-x11.c +++ b/src/compositor-x11.c @@ -1366,7 +1366,7 @@ x11_compositor_create(struct wl_display *display, int fullscreen, int no_input, int use_pixman, - int argc, char *argv[], const char *config_file) + int *argc, char *argv[], const char *config_file) { struct x11_compositor *c; struct x11_configured_output *o; @@ -1556,7 +1556,7 @@ err_free: } WL_EXPORT struct weston_compositor * -backend_init(struct wl_display *display, int argc, char *argv[], +backend_init(struct wl_display *display, int *argc, char *argv[], const char *config_file) { int fullscreen = 0; diff --git a/src/compositor.c b/src/compositor.c index 64d0830..fb5cb2c 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -2951,8 +2951,7 @@ log_uname(void) WL_EXPORT int weston_compositor_init(struct weston_compositor *ec, struct wl_display *display, - int argc, - char *argv[], + int *argc, char *argv[], const char *config_file) { struct wl_event_loop *loop; @@ -3336,7 +3335,7 @@ int main(int argc, char *argv[]) struct sigaction segv_action; struct weston_compositor *(*backend_init)(struct wl_display *display, - int argc, char *argv[], const char *config_file); + int *argc, char *argv[], const char *config_file); int i; char *backend = NULL; const char *modules = "desktop-shell.so", *option_modules = NULL; @@ -3366,8 +3365,7 @@ int main(int argc, char *argv[]) { WESTON_OPTION_BOOLEAN, "version", 0, &version }, }; - argc = parse_options(core_options, - ARRAY_LENGTH(core_options), argc, argv); + parse_options(core_options, ARRAY_LENGTH(core_options), &argc, argv); if (help) usage(EXIT_SUCCESS); @@ -3419,7 +3417,7 @@ int main(int argc, char *argv[]) if (!backend_init) exit(EXIT_FAILURE); - ec = backend_init(display, argc, argv, config_file); + ec = backend_init(display, &argc, argv, config_file); if (ec == NULL) { weston_log("fatal: failed to create compositor\n"); exit(EXIT_FAILURE); @@ -3431,9 +3429,10 @@ int main(int argc, char *argv[]) sigaction(SIGSEGV, &segv_action, NULL); segv_compositor = ec; - for (i = 1; argv[i]; i++) + + for (i = 1; i < argc; i++) weston_log("fatal: unhandled option: %s\n", argv[i]); - if (argv[1]) { + if (argc > 1) { ret = EXIT_FAILURE; goto out; } diff --git a/src/compositor.h b/src/compositor.h index fdde762..11afbb9 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -714,7 +714,7 @@ weston_compositor_get_time(void); int weston_compositor_init(struct weston_compositor *ec, struct wl_display *display, - int argc, char *argv[], const char *config_file); + int *argc, char *argv[], const char *config_file); void weston_compositor_shutdown(struct weston_compositor *ec); void @@ -839,8 +839,8 @@ int noop_renderer_init(struct weston_compositor *ec); struct weston_compositor * -backend_init(struct wl_display *display, int argc, char *argv[], - const char *config_file); +backend_init(struct wl_display *display, int *argc, char *argv[], + const char *config_file); int module_init(struct weston_compositor *compositor);