Skip to content

Commit

Permalink
Fix compiler warnings. (jordansissel#344)
Browse files Browse the repository at this point in the history
As of this commit, this project will build successfully even if
`-Werror` is given. Nice!
  • Loading branch information
jordansissel authored Aug 4, 2021
1 parent 32e99f4 commit c3a3bf2
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 63 deletions.
4 changes: 1 addition & 3 deletions cmd_behave.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ int cmd_behave(context_t *context) {
char *cmd = *context->argv;

int c;
typedef enum {
opt_unused, opt_help
} optlist_t;
enum { opt_unused, opt_help };
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ 0, 0, 0, 0 },
Expand Down
4 changes: 1 addition & 3 deletions cmd_behave_screen_edge.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ int cmd_behave_screen_edge(context_t *context) {
enum { quiesce_start, quiesce_ing, quiesce_done } quiesce_state = quiesce_start;

int c;
typedef enum {
opt_unused, opt_help, opt_delay, opt_quiesce
} optlist_t;
enum { opt_unused, opt_help, opt_delay, opt_quiesce };
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ "delay", required_argument, NULL, opt_delay },
Expand Down
4 changes: 2 additions & 2 deletions cmd_click.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ int cmd_click(context_t *context) {
int repeat = 1;

int c;
typedef enum {
enum {
opt_unused, opt_help, opt_clearmodifiers, opt_window, opt_delay,
opt_repeat
} optlist_t;
};
static struct option longopts[] = {
{ "clearmodifiers", no_argument, NULL, opt_clearmodifiers },
{ "help", no_argument, NULL, opt_help },
Expand Down
4 changes: 1 addition & 3 deletions cmd_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ int cmd_exec(context_t *context) {
char *terminator = NULL;
int c, i;

typedef enum {
opt_unused, opt_help, opt_sync, opt_args, opt_terminator
} optlist_t;
enum { opt_unused, opt_help, opt_sync, opt_args, opt_terminator };
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ "sync", no_argument, NULL, opt_sync },
Expand Down
4 changes: 1 addition & 3 deletions cmd_get_display_geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ int cmd_get_display_geometry(context_t *context) {
int screen = DefaultScreen(context->xdo->xdpy);
int shell_output = False;

typedef enum {
opt_unused, opt_help, opt_screen, opt_shell
} optlist_t;
enum { opt_unused, opt_help, opt_screen, opt_shell };
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ "screen", required_argument, NULL, opt_screen },
Expand Down
4 changes: 2 additions & 2 deletions cmd_mousemove.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ int cmd_mousemove(context_t *context) {
mousemove.step = 0;

int c;
typedef enum {
enum {
opt_unused, opt_help, opt_sync, opt_clearmodifiers, opt_polar,
opt_screen, opt_step, opt_delay, opt_window
} optlist_t;
};
static struct option longopts[] = {
{ "clearmodifiers", no_argument, NULL, opt_clearmodifiers },
{ "help", no_argument, NULL, opt_help},
Expand Down
4 changes: 2 additions & 2 deletions cmd_mousemove_relative.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ int cmd_mousemove_relative(context_t *context) {
charcodemap_t *active_mods = NULL;
int active_mods_n;
int c;
typedef enum {
enum {
opt_unused, opt_help, opt_sync, opt_clearmodifiers, opt_polar
} optlist_t;
};
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ "sync", no_argument, NULL, opt_sync },
Expand Down
7 changes: 3 additions & 4 deletions cmd_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ int cmd_search(context_t *context) {
int search_class = 0;
int search_classname = 0;
int search_role = 0;
typedef enum {
enum {
opt_unused, opt_title, opt_onlyvisible, opt_name, opt_shell, opt_prefix, opt_class, opt_maxdepth,
opt_pid, opt_help, opt_any, opt_all, opt_screen, opt_classname, opt_desktop,
opt_limit, opt_sync
,opt_role
} optlist_t;
opt_limit, opt_sync, opt_role
};
struct option longopts[] = {
{ "all", no_argument, NULL, opt_all },
{ "any", no_argument, NULL, opt_any },
Expand Down
4 changes: 1 addition & 3 deletions cmd_set_desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ int cmd_set_desktop(context_t *context) {
int relative = False;

int c;
typedef enum {
opt_unused, opt_help, opt_relative
} optlist_t;
enum { opt_unused, opt_help, opt_relative };

static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
Expand Down
4 changes: 1 addition & 3 deletions cmd_sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ int cmd_sleep(context_t *context) {
int c;
double duration_usec;

typedef enum {
opt_unused, opt_help
} optlist_t;
enum { opt_unused, opt_help };
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ 0, 0, 0, 0 },
Expand Down
4 changes: 2 additions & 2 deletions cmd_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ int cmd_type(context_t *context) {
int clear_modifiers = 0;
useconds_t delay = 12000; /* 12ms between keystrokes default */

typedef enum {
enum {
opt_unused, opt_clearmodifiers, opt_delay, opt_help, opt_window, opt_args,
opt_terminator, opt_file
} optlist_t;
};

struct option longopts[] = {
{ "clearmodifiers", no_argument, NULL, opt_clearmodifiers },
Expand Down
4 changes: 1 addition & 3 deletions cmd_windowactivate.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ int cmd_windowactivate(context_t *context) {
int opsync = 0;

int c;
typedef enum {
opt_unused, opt_help, opt_sync
} optlist_t;
enum { opt_unused, opt_help, opt_sync };
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ "sync", no_argument, NULL, opt_sync },
Expand Down
4 changes: 1 addition & 3 deletions cmd_windowfocus.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ int cmd_windowfocus(context_t *context) {
int opsync = 0;

int c;
typedef enum {
opt_unused, opt_help, opt_sync
} optlist_t;
enum { opt_unused, opt_help, opt_sync };
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ "sync", no_argument, NULL, opt_sync },
Expand Down
4 changes: 1 addition & 3 deletions cmd_windowmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ int cmd_windowmap(context_t *context) {
int opsync = 0;

int c;
typedef enum {
opt_unused, opt_help, opt_sync
} optlist_t;
enum { opt_unused, opt_help, opt_sync };
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ "sync", no_argument, NULL, opt_sync },
Expand Down
4 changes: 1 addition & 3 deletions cmd_windowminimize.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ int cmd_windowminimize(context_t *context) {
int opsync = 0;

int c;
typedef enum {
opt_unused, opt_help, opt_sync
} optlist_t;
enum { opt_unused, opt_help, opt_sync };
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ "sync", no_argument, NULL, opt_sync },
Expand Down
5 changes: 1 addition & 4 deletions cmd_windowmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ int cmd_windowmove(context_t *context) {
windowmove.flags = 0;

int c;
typedef enum {
opt_unused, opt_help, opt_sync, opt_relative
} optlist_t;
enum { opt_unused, opt_help, opt_sync, opt_relative };
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ "sync", no_argument, NULL, opt_sync },
Expand Down Expand Up @@ -106,7 +104,6 @@ int cmd_windowmove(context_t *context) {
consume_args(context, 2);

XWindowAttributes wattr;
unsigned int original_w, original_h;
unsigned int root_w, root_h; /* for percent */

window_each(context, window_arg, {
Expand Down
4 changes: 1 addition & 3 deletions cmd_windowreparent.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ int cmd_windowreparent(context_t *context) {
const char *window_arg = "%1";

int c;
typedef enum {
opt_unused, opt_help
} optlist_t;
enum { opt_unused, opt_help };
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ 0, 0, 0, 0 },
Expand Down
4 changes: 1 addition & 3 deletions cmd_windowsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ int cmd_windowsize(context_t *context) {
int opsync = 0;

int use_hints = 0;
typedef enum {
opt_unused, opt_help, opt_usehints, opt_sync
} optlist_t;
enum { opt_unused, opt_help, opt_usehints, opt_sync };
struct option longopts[] = {
{ "usehints", 0, NULL, opt_usehints },
{ "help", no_argument, NULL, opt_help },
Expand Down
4 changes: 1 addition & 3 deletions cmd_windowstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ int cmd_windowstate(context_t *context) {
"property can be one of \n"
"MODAL, STICKY, MAXIMIZED_VERT, MAXIMIZED_HORZ, SHADED, SKIP_TASKBAR, \n"
"SKIP_PAGER, HIDDEN, FULLSCREEN, ABOVE, BELOW, DEMANDS_ATTENTION\n";
static int *errno_ptr;
errno_ptr = &errno;
while ((c = getopt_long_only(context->argc, context->argv, "+ha:r:t:",
longopts, &option_index)) != -1) {
switch (c) {
Expand Down Expand Up @@ -81,7 +79,7 @@ int cmd_windowstate(context_t *context) {

consume_args(context, optind);

if (action == -1 || arg_property == NULL) {
if (action == (unsigned long)-1 || arg_property == NULL) {
fprintf(stderr, usage, cmd);
return 1;
}
Expand Down
4 changes: 1 addition & 3 deletions cmd_windowunmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ int cmd_windowunmap(context_t *context) {
int opsync;

int c;
typedef enum {
opt_unused, opt_help, opt_sync, opt_verbose
} optlist_t;
enum { opt_unused, opt_help, opt_sync, opt_verbose };
static struct option longopts[] = {
{ "help", no_argument, NULL, opt_help },
{ "sync", no_argument, NULL, opt_sync },
Expand Down
7 changes: 4 additions & 3 deletions xdo.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ static int _xdo_mousebutton(const xdo_t *xdo, Window window, int button, int is_
static int _is_success(const char *funcname, int code, const xdo_t *xdo);
static void _xdo_debug(const xdo_t *xdo, const char *format, ...);
static void _xdo_eprintf(const xdo_t *xdo, int hushable, const char *format, ...);
static int appears_to_be_wayland(Display *xdpy);

/* context-free functions */
static wchar_t _keysym_to_char(KeySym keysym);
Expand Down Expand Up @@ -388,7 +389,7 @@ int xdo_set_window_property(const xdo_t *xdo, Window wid, const char *property,

char netwm_property[256] = "_NET_";
int ret = 0;
strncat(netwm_property, property, strlen(property));
strcat(netwm_property, property);

// Change the property
ret = XChangeProperty(xdo->xdpy, wid,
Expand Down Expand Up @@ -1937,7 +1938,7 @@ int xdo_get_window_classname(const xdo_t *xdo, Window window, unsigned char **na
XClassHint classhint;
XGetClassHint(xdo->xdpy, window, &classhint);
XFree(classhint.res_name);
*name_ret = (char*) classhint.res_class;
*name_ret = (unsigned char*) classhint.res_class;
return 0;
}

Expand Down Expand Up @@ -2036,7 +2037,7 @@ int xdo_get_viewport_dimensions(xdo_t *xdo, unsigned int *width,
}
}

int appears_to_be_wayland(Display *xdpy) {
static int appears_to_be_wayland(Display *xdpy) {
// XWayland leaks its presence in two extensions (at time of writing, August 2021)
// First: the name of input devices "xwayland-pointer"
// Second: in the Vendor string of XFree86-VidModeExtension
Expand Down
7 changes: 7 additions & 0 deletions xdo.h
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,15 @@ int xdo_has_feature(xdo_t *xdo, int feature);
int xdo_get_viewport_dimensions(xdo_t *xdo, unsigned int *width,
unsigned int *height, int screen);


/**
* Get the classname of a given Window.
*/
int xdo_get_window_classname(const xdo_t *xdo, Window window, unsigned char **name_ret);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* ifndef _XDO_H_ */

4 changes: 2 additions & 2 deletions xdotool.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ int script_main(int argc, char **argv) {
/* read input... */
int pos;
char *token;
int result;
int result = XDO_SUCCESS;

while (fgets(buffer, 4096, input) != NULL) {
char *line = buffer;
Expand Down Expand Up @@ -451,7 +451,7 @@ int script_main(int argc, char **argv) {
script_argv[script_argc] = (char *) calloc(strlen(token) + 1, sizeof(char));

//printf("arg %d: %s\n", script_argc, token);
strncpy(script_argv[script_argc], token, strlen(token)+1);
strcpy(script_argv[script_argc], token);
script_argc++;
}

Expand Down

0 comments on commit c3a3bf2

Please sign in to comment.