From 97c83f014dcfca212328968526ff72a3f5ccfce6 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Thu, 13 Dec 2012 14:52:51 +0000 Subject: [PATCH 1/5] Sort includes. --- commands.h | 4 ++-- compat.h | 6 +++--- meta_info.h | 2 +- paint.h | 2 +- player.h | 4 ++-- players/mplayer.h | 2 +- players/player_utils.h | 4 ++-- playlist.h | 2 +- socket.c | 7 ++++--- uinterface.h | 2 +- vitunes.h | 7 +++---- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/commands.h b/commands.h index 521efe7..0f9aede 100644 --- a/commands.h +++ b/commands.h @@ -19,12 +19,12 @@ #include "compat.h" +#include "debug.h" #include "enums.h" +#include "keybindings.h" #include "paint.h" #include "str2argv.h" #include "vitunes.h" -#include "debug.h" -#include "keybindings.h" /**************************************************************************** * Toggle-list handling stuff diff --git a/compat.h b/compat.h index ac349c6..0123b8b 100644 --- a/compat.h +++ b/compat.h @@ -39,16 +39,16 @@ /* OpenBSD has fparseln(3), but it must be included thusly */ #if defined(__OpenBSD__) # include -# include # include +# include #endif /* FreeBSD has fparseln(3), but it must be included thusly */ #if defined(__FreeBSD__) -# include # include -# include +# include # include +# include #endif /* Mac OS X has fparseln(3), but it must be included thusly */ diff --git a/meta_info.h b/meta_info.h index 19c04d7..d9addeb 100644 --- a/meta_info.h +++ b/meta_info.h @@ -20,9 +20,9 @@ #include "compat.h" #include -#include #include #include +#include #include #include #include diff --git a/paint.h b/paint.h index b8c8643..362827a 100644 --- a/paint.h +++ b/paint.h @@ -21,9 +21,9 @@ #include #include -#include #include #include +#include #include #include "enums.h" diff --git a/player.h b/player.h index 029fb43..e5bad7a 100644 --- a/player.h +++ b/player.h @@ -21,9 +21,9 @@ #include -#include "playlist.h" -#include "paint.h" #include "debug.h" +#include "paint.h" +#include "playlist.h" /* "static" backends (those that aren't dynamically loaded) */ #include "players/mplayer.h" diff --git a/players/mplayer.h b/players/mplayer.h index 03700cd..d3ee2cf 100644 --- a/players/mplayer.h +++ b/players/mplayer.h @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -31,6 +30,7 @@ #include #include #include +#include #include #include "player_utils.h" diff --git a/players/player_utils.h b/players/player_utils.h index f54b72e..5b8bbc4 100644 --- a/players/player_utils.h +++ b/players/player_utils.h @@ -19,12 +19,12 @@ #include "../compat.h" +#include #include #include +#include #include #include -#include -#include bool exe_in_path(const char *e); diff --git a/playlist.h b/playlist.h index 60c06a0..947be4e 100644 --- a/playlist.h +++ b/playlist.h @@ -25,8 +25,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/socket.c b/socket.c index af4dcfb..31b858b 100644 --- a/socket.c +++ b/socket.c @@ -13,15 +13,16 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include #include #include #include + +#include +#include #include -#include "socket.h" #include "commands.h" +#include "socket.h" #define VITUNES_SOCK "/tmp/.vitunes" diff --git a/uinterface.h b/uinterface.h index e28e15a..0c6c02e 100644 --- a/uinterface.h +++ b/uinterface.h @@ -25,8 +25,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/vitunes.h b/vitunes.h index 8348da0..acd07f8 100644 --- a/vitunes.h +++ b/vitunes.h @@ -21,22 +21,21 @@ #include -#include #include #include #include -#include #include #include +#include +#include "commands.h" #include "debug.h" +#include "ecmd.h" #include "enums.h" -#include "commands.h" #include "keybindings.h" #include "medialib.h" #include "player.h" #include "uinterface.h" -#include "ecmd.h" /* for unused arguments */ #if defined(__GNUC__) || defined(__clang__) From 4a2352af3f839c54009491d854f2ac9086f8685b Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Thu, 13 Dec 2012 14:54:29 +0000 Subject: [PATCH 2/5] Fix style nits by using a space after a keyword. --- commands.c | 18 +++++++++--------- keybindings.c | 6 +++--- socket.c | 16 ++++++++-------- vitunes.c | 18 +++++++++--------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/commands.c b/commands.c index e310fca..c67b6c5 100644 --- a/commands.c +++ b/commands.c @@ -542,7 +542,7 @@ cmd_display(int argc, char *argv[]) return 1; } - if(ui_is_init()) + if (ui_is_init()) paint_playlist(); return 0; @@ -655,7 +655,7 @@ cmd_set(int argc, char *argv[]) /* resize & redraw (if we're past setup & curses is running) */ ui.lwidth = new_width; ui_resize(); - if(player_is_setup && ui_is_init()) { + if (player_is_setup && ui_is_init()) { ui_clear(); paint_all(); } @@ -886,19 +886,19 @@ cmd_playlist(int argc, char *argv[]) return 1; } - for(x = 0; x < mdb.nplaylists; x++) { - if(!strncmp(argv[1], mdb.playlists[x]->name, strlen(argv[1]))) { - if(idx > -1) { + for (x = 0; x < mdb.nplaylists; x++) { + if (!strncmp(argv[1], mdb.playlists[x]->name, strlen(argv[1]))) { + if (idx > -1) { idx = -2; break; } - if(idx == -1) + if (idx == -1) idx = x; } } - if(idx > -1) { + if (idx > -1) { setup_viewing_playlist(mdb.playlists[idx]); ui.active = ui.playlist; paint_all(); @@ -906,12 +906,12 @@ cmd_playlist(int argc, char *argv[]) return 0; } - if(idx == -1) { + if (idx == -1) { paint_error("no match for: %s", argv[1]); return 0; } - if(idx == -2) + if (idx == -2) paint_error("no unique match for: %s", argv[1]); return 0; diff --git a/keybindings.c b/keybindings.c index 242e868..5a3fdd9 100644 --- a/keybindings.c +++ b/keybindings.c @@ -448,8 +448,8 @@ kb_execute_by_name(const char *name) if (!kb_str2action(name, &a)) return false; - for(x = 0; x < KeyActionHandlersSize; x++) { - if(a == KeyActionHandlers[x].action) { + for (x = 0; x < KeyActionHandlersSize; x++) { + if (a == KeyActionHandlers[x].action) { KeyActionHandlers[x].handler(KeyActionHandlers[x].args); return true; } @@ -1762,7 +1762,7 @@ execute_external_command(const char *cmd) printf("\nPress ENTER or type command to continue"); fflush(stdout); raw(); - while(!VSIG_QUIT) { + while (!VSIG_QUIT) { if ((input = getch()) && input != ERR) { if (input != '\r') ungetch(input); diff --git a/socket.c b/socket.c index 31b858b..c83aefe 100644 --- a/socket.c +++ b/socket.c @@ -35,14 +35,14 @@ sock_send_msg(const char *msg) socklen_t addr_len; - if((ret = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) + if ((ret = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) return -1; addr.sun_family = AF_UNIX; strcpy(addr.sun_path, VITUNES_SOCK); addr_len = sizeof(addr.sun_family) + strlen(VITUNES_SOCK) + 1; - if(sendto(ret, msg, strlen(msg), 0, (struct sockaddr *) &addr, addr_len) == -1) { + if (sendto(ret, msg, strlen(msg), 0, (struct sockaddr *) &addr, addr_len) == -1) { close(ret); return -1; } @@ -61,14 +61,14 @@ sock_listen(void) unlink(VITUNES_SOCK); - if((ret = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) + if ((ret = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1) return -1; addr.sun_family = AF_UNIX; strcpy(addr.sun_path, VITUNES_SOCK); addr_len = sizeof(addr.sun_family) + strlen(VITUNES_SOCK) + 1; - if(bind(ret, (struct sockaddr *) &addr, addr_len) == -1) + if (bind(ret, (struct sockaddr *) &addr, addr_len) == -1) return -1; fcntl(ret, F_SETFD, FD_CLOEXEC, &coe); @@ -86,7 +86,7 @@ sock_recv_msg(int sock, char *msg, size_t msg_len) ret = recvfrom(sock, msg, msg_len, 0, (struct sockaddr *) &addr, &addr_len); - if(ret > -1) + if (ret > -1) msg[ret] = '\0'; return ret; @@ -98,12 +98,12 @@ sock_recv_and_exec(int sock) { char msg[64]; - if(sock_recv_msg(sock, msg, sizeof(msg)) == -1) + if (sock_recv_msg(sock, msg, sizeof(msg)) == -1) return; - if(!strcmp(msg, VITUNES_RUNNING)) + if (!strcmp(msg, VITUNES_RUNNING)) return; - if(!kb_execute_by_name(msg)) + if (!kb_execute_by_name(msg)) cmd_execute(msg); } diff --git a/vitunes.c b/vitunes.c index 7d1abbb..e65db99 100644 --- a/vitunes.c +++ b/vitunes.c @@ -126,10 +126,10 @@ main(int argc, char *argv[]) /* handle command-line switches & e-commands */ handle_switches(argc, argv); - if(sock_send_msg(VITUNES_RUNNING) != -1) { + if (sock_send_msg(VITUNES_RUNNING) != -1) { printf("Vitunes appears to be running already. Won't open socket."); } else { - if((sock = sock_listen()) == -1) + if ((sock = sock_listen()) == -1) errx(1, "failed to open socket."); } @@ -209,21 +209,21 @@ main(int argc, char *argv[]) FD_ZERO(&fds); FD_SET(0, &fds); - if(sock > 0) + if (sock > 0) FD_SET(sock, &fds); errno = 0; - if(select((sock > 0 ? sock : 0) + 1, &fds, NULL, NULL, &tv) == -1) { - if(errno == 0 || errno == EINTR) + if (select((sock > 0 ? sock : 0) + 1, &fds, NULL, NULL, &tv) == -1) { + if (errno == 0 || errno == EINTR) continue; break; } - if(sock > 0) { - if(FD_ISSET(sock, &fds)) + if (sock > 0) { + if (FD_ISSET(sock, &fds)) sock_recv_and_exec(sock); } - if(FD_ISSET(0, &fds)) { + if (FD_ISSET(0, &fds)) { /* handle any available input */ if ((input = getch()) && input != ERR) { if (isdigit(input) && (input != '0' || gnum_get() > 0)) @@ -475,7 +475,7 @@ handle_switches(int argc, char *argv[]) while ((ch = getopt(argc, argv, "he:f:d:p:m:c:")) != -1) { switch (ch) { case 'c': - if(sock_send_msg(optarg) == -1) + if (sock_send_msg(optarg) == -1) errx(1, "Failed to send message. Vitunes not running?"); exit(0); From 9ed7005a831e1d044cdd659bafba4ec11b0d081a Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Thu, 13 Dec 2012 17:52:42 +0000 Subject: [PATCH 3/5] Use void on functions with no parameters. Otherwise, when using functions with no parameter specification, nothing is assumed about its arguments (ie all checks are turned off). --- commands.c | 4 ++-- commands.h | 4 ++-- keybindings.c | 26 +++++++++++++------------- keybindings.h | 22 +++++++++++----------- medialib.c | 2 +- medialib.h | 2 +- meta_info.c | 20 ++++++++++---------- meta_info.h | 20 ++++++++++---------- paint.c | 14 +++++++------- paint.h | 14 +++++++------- player.c | 10 +++++----- player.h | 10 +++++----- players/gstplayer.c | 14 +++++++------- players/gstplayer.h | 18 +++++++++--------- players/mplayer.c | 20 ++++++++++---------- players/mplayer.h | 20 ++++++++++---------- playlist.h | 2 +- uinterface.c | 12 ++++++------ uinterface.h | 12 ++++++------ vitunes.c | 8 ++++---- vitunes.h | 4 ++-- 21 files changed, 129 insertions(+), 129 deletions(-) diff --git a/commands.c b/commands.c index c67b6c5..2dedef9 100644 --- a/commands.c +++ b/commands.c @@ -54,7 +54,7 @@ toggle_list **toggleset; size_t toggleset_size; void -toggleset_init() +toggleset_init(void) { const int max_size = 52; /* since we only have registers a-z and A-Z */ if ((toggleset = calloc(max_size, sizeof(toggle_list*))) == NULL) @@ -64,7 +64,7 @@ toggleset_init() } void -toggleset_free() +toggleset_free(void) { size_t i; for (i = 0; i < toggleset_size; i++) diff --git a/commands.h b/commands.h index 0f9aede..8c8e6f4 100644 --- a/commands.h +++ b/commands.h @@ -76,8 +76,8 @@ extern toggle_list **toggleset; extern size_t toggleset_size; /* initialize and free the toggleset */ -void toggleset_init(); -void toggleset_free(); +void toggleset_init(void); +void toggleset_free(void); toggle_list *toggle_list_create(int registr, int argc, char *argv[]); void toggle_list_add_command(toggle_list *t, char *cmd); diff --git a/keybindings.c b/keybindings.c index 5a3fdd9..ca678d8 100644 --- a/keybindings.c +++ b/keybindings.c @@ -253,7 +253,7 @@ size_t KeyBindingsSize; size_t KeyBindingsCapacity; void -kb_increase_capacity() +kb_increase_capacity(void) { KeyBinding *new_buffer; size_t nbytes; @@ -275,7 +275,7 @@ kb_increase_capacity() ****************************************************************************/ void -kb_init() +kb_init(void) { size_t i; @@ -290,7 +290,7 @@ kb_init() } void -kb_free() +kb_free(void) { free(KeyBindings); KeyBindingsSize = 0; @@ -340,7 +340,7 @@ kb_unbind_key(KeyCode key) } void -kb_unbind_all() +kb_unbind_all(void) { KeyBindingsSize = 0; } @@ -465,7 +465,7 @@ kb_execute_by_name(const char *name) ****************************************************************************/ KbaArgs -get_dummy_args() +get_dummy_args(void) { KbaArgs dummy = { .direction = -1, .scale = -1, .amount = -1, .placement = -1, .num = -1 }; @@ -1605,10 +1605,10 @@ kba_toggle(KbaArgs a) int _global_input_num = 0; -void gnum_clear() +void gnum_clear(void) { _global_input_num = 0; } -int gnum_get() +int gnum_get(void) { return _global_input_num; } void gnum_set(int x) @@ -1620,7 +1620,7 @@ void gnum_add(int x) } int -gnum_retrieve() +gnum_retrieve(void) { int n = 1; if (gnum_get() > 0) { @@ -1639,7 +1639,7 @@ gnum_retrieve() Direction _global_search_dir = FORWARDS; -Direction search_dir_get() +Direction search_dir_get(void) { return _global_search_dir; } void search_dir_set(Direction dir) @@ -1655,7 +1655,7 @@ void search_dir_set(Direction dir) yank_buffer _yank_buffer; void -ybuffer_init() +ybuffer_init(void) { _yank_buffer.files = calloc(YANK_BUFFER_CHUNK_SIZE, sizeof(meta_info*)); if (_yank_buffer.files == NULL) @@ -1666,13 +1666,13 @@ ybuffer_init() } void -ybuffer_clear() +ybuffer_clear(void) { _yank_buffer.nfiles = 0; } void -ybuffer_free() +ybuffer_free(void) { free(_yank_buffer.files); _yank_buffer.capacity = 0; @@ -1706,7 +1706,7 @@ ybuffer_add(meta_info *f) ****************************************************************************/ void -redraw_active() +redraw_active(void) { if (ui.active == ui.library) paint_library(); diff --git a/keybindings.h b/keybindings.h index 4ad5ccb..844ce6c 100644 --- a/keybindings.h +++ b/keybindings.h @@ -92,12 +92,12 @@ typedef int KeyCode; /* Keybinding initializing and binding routines */ -void kb_init(); -void kb_free(); +void kb_init(void); +void kb_free(void); void kb_bind(KeyAction, KeyCode); void kb_unbind_action(KeyAction); void kb_unbind_key(KeyCode); -void kb_unbind_all(); +void kb_unbind_all(void); bool kb_execute(KeyCode); bool kb_execute_by_name(const char *); @@ -162,15 +162,15 @@ void kba_toggle(KbaArgs a); * how the sequence "15j" will move down 15 lines. "15" is the gnum here. * These are the routines used to init/set/clear the gnum. */ -void gnum_clear(); +void gnum_clear(void); void gnum_set(int x); void gnum_add(int x); -int gnum_get(); /* Return current gnum. */ -int gnum_retrieve(); /* Return current gnum and then clear it. */ +int gnum_get(void); /* Return current gnum. */ +int gnum_retrieve(void); /* Return current gnum and then clear it. */ /* These are used to set/use the search direction */ -Direction search_dir_get(); +Direction search_dir_get(void); void search_dir_set(Direction d); @@ -183,14 +183,14 @@ typedef struct { } yank_buffer; extern yank_buffer _yank_buffer; -void ybuffer_init(); -void ybuffer_clear(); -void ybuffer_free(); +void ybuffer_init(void); +void ybuffer_clear(void); +void ybuffer_free(void); void ybuffer_add(meta_info *f); /* Misc. handy functions used frequently */ -void redraw_active(); +void redraw_active(void); bool match_command_name(const char *s, const char *cmd); void execute_external_command(const char *cmd); diff --git a/medialib.c b/medialib.c index 35cfd2e..eebc82b 100644 --- a/medialib.c +++ b/medialib.c @@ -80,7 +80,7 @@ medialib_load(const char *db_file, const char *playlist_dir) /* free() all memory associated with global media library */ void -medialib_destroy() +medialib_destroy(void) { int i; diff --git a/medialib.h b/medialib.h index 5f6e3af..0d8cc75 100644 --- a/medialib.h +++ b/medialib.h @@ -75,7 +75,7 @@ extern medialib mdb; /* load/free the global media library */ void medialib_load(const char *db_file, const char *playlist_dir); -void medialib_destroy(); +void medialib_destroy(void); /* add/remove playlists to/from the global media library */ void medialib_playlist_add(playlist *p); diff --git a/meta_info.c b/meta_info.c index b2c81d2..7c664de 100644 --- a/meta_info.c +++ b/meta_info.c @@ -291,7 +291,7 @@ bool mi_query_match_filename; /* initialize the query structures */ void -mi_query_init() +mi_query_init(void) { int i; @@ -305,14 +305,14 @@ mi_query_init() /* determine if a query has been set */ bool -mi_query_isset() +mi_query_isset(void) { return _mi_query.ntokens != 0; } /* free the query structures */ void -mi_query_clear() +mi_query_clear(void) { int i; @@ -361,7 +361,7 @@ mi_query_setraw(const char *query) } const char * -mi_query_getraw() +mi_query_getraw(void) { return _mi_query.raw; } @@ -434,7 +434,7 @@ mi_sort_description _mi_sort; /* initialize the sort ordering to what i like */ void -mi_sort_init() +mi_sort_init(void) { _mi_sort.order[0] = MI_CINFO_ARTIST; _mi_sort.order[1] = MI_CINFO_ALBUM; @@ -451,7 +451,7 @@ mi_sort_init() /* clear the current sort */ void -mi_sort_clear() +mi_sort_clear(void) { _mi_sort.nfields = 0; } @@ -590,7 +590,7 @@ mi_display_description mi_display; /* initialize global display description to what i like */ void -mi_display_init() +mi_display_init(void) { mi_display.nfields = 6; @@ -618,14 +618,14 @@ mi_display_init() /* reset the display to what i like */ void -mi_display_reset() +mi_display_reset(void) { mi_display_init(); } /* return the total width of the current display description */ int -mi_display_getwidth() +mi_display_getwidth(void) { int sum; int i; @@ -639,7 +639,7 @@ mi_display_getwidth() /* convert current display to a string for showing elsewhere */ char * -mi_display_tostr() +mi_display_tostr(void) { /* * NOTE: for the below "dirty hack" ... it would require some *huge* diff --git a/meta_info.h b/meta_info.h index d9addeb..a39b773 100644 --- a/meta_info.h +++ b/meta_info.h @@ -118,13 +118,13 @@ typedef struct { extern bool mi_query_match_filename; /* initialize, set, and clear global query description */ -void mi_query_init(); -bool mi_query_isset(); -void mi_query_clear(); +void mi_query_init(void); +bool mi_query_isset(void); +void mi_query_clear(void); void mi_query_add_token(const char *token); void mi_query_setraw(const char *query); -const char *mi_query_getraw(); +const char *mi_query_getraw(void); /* match a given meta_info/string against the global query description */ bool mi_match(const meta_info *mi); @@ -149,8 +149,8 @@ typedef struct { } mi_sort_description; /* initialize, set, and clear global sort description */ -void mi_sort_init(); -void mi_sort_clear(); +void mi_sort_init(void); +void mi_sort_clear(void); int mi_sort_set(const char *str, const char **errmsg); /* compare two meta_info's using the global sort description */ @@ -173,14 +173,14 @@ typedef struct { extern mi_display_description mi_display; /* initialize and set the global display description */ -void mi_display_init(); +void mi_display_init(void); int mi_display_set(const char *str, const char **errmsg); -void mi_display_reset(); +void mi_display_reset(void); /* convert current display to a string */ -char *mi_display_tostr(); +char *mi_display_tostr(void); /* get total width of display */ -int mi_display_getwidth(); +int mi_display_getwidth(void); #endif diff --git a/paint.c b/paint.c index e0b4a8f..993e086 100644 --- a/paint.c +++ b/paint.c @@ -80,7 +80,7 @@ num2fmt(int n, Direction d) /* paint the status bar */ void -paint_status_bar() +paint_status_bar(void) { static char scratchpad[500]; char *focusName; @@ -127,7 +127,7 @@ paint_status_bar() /* paint the player */ void -paint_player() +paint_player(void) { static char *playmode; static char *finfo; @@ -194,7 +194,7 @@ paint_player() /* paint the library window */ void -paint_library() +paint_library(void) { char *str; int row, hoff, index, x; @@ -286,7 +286,7 @@ paint_library() /* paint the playlist window */ void -paint_playlist() +paint_playlist(void) { playlist *plist; bool hasinfo; @@ -470,7 +470,7 @@ paint_playlist() /* paint borders between windows */ void -paint_borders() +paint_borders(void) { int w, h; getmaxyx(stdscr, h, w); @@ -538,7 +538,7 @@ paint_playlist_file_info(const meta_info *m) /* paint all windows */ void -paint_all() +paint_all(void) { paint_borders(); paint_player(); @@ -595,7 +595,7 @@ paint_message(char *fmt, ...) * run through init_pair(3) */ void -paint_setup_colors() +paint_setup_colors(void) { int i; diff --git a/paint.h b/paint.h index 362827a..d4a412c 100644 --- a/paint.h +++ b/paint.h @@ -70,12 +70,12 @@ typedef struct { extern _colors colors; /* routines for painting each window */ -void paint_status_bar(); -void paint_player(); -void paint_library(); -void paint_playlist(); -void paint_borders(); -void paint_all(); +void paint_status_bar(void); +void paint_player(void); +void paint_library(void); +void paint_playlist(void); +void paint_borders(void); +void paint_all(void); extern bool showing_file_info; void paint_playlist_file_info(const meta_info *m); @@ -85,7 +85,7 @@ void paint_error(char *fmt, ...); void paint_message(char *fmt, ...); /* for setting up and working with the colors */ -void paint_setup_colors(); +void paint_setup_colors(void); int paint_str2item(const char *str); int paint_str2color(const char *str); diff --git a/player.c b/player.c index 37bf637..f507c7b 100644 --- a/player.c +++ b/player.c @@ -22,7 +22,7 @@ player_info_t player_info; /* callbacks */ -static void callback_playnext() { player_skip_song(1); } +static void callback_playnext(void) { player_skip_song(1); } static void callback_fatal(char *fmt, ...) @@ -134,7 +134,7 @@ player_init(const char *backend) } void -player_destroy() +player_destroy(void) { player.finish(); } @@ -147,7 +147,7 @@ player_set_queue(playlist *queue, int pos) } void -player_play() +player_play(void) { if (player_info.queue == NULL) errx(1, "player_play: bad queue/qidx"); @@ -160,13 +160,13 @@ player_play() } void -player_stop() +player_stop(void) { player.stop(); } void -player_pause() +player_pause(void) { if (!player.playing()) return; diff --git a/player.h b/player.h index e5bad7a..a615380 100644 --- a/player.h +++ b/player.h @@ -46,20 +46,20 @@ typedef enum { /* player setup/destroy functions */ void player_init(const char *backend); -void player_destroy(); +void player_destroy(void); void player_set_queue(playlist *queue, int position); /* player control functions */ -void player_play(); -void player_stop(); -void player_pause(); +void player_play(void); +void player_stop(void); +void player_pause(void); void player_seek(int seconds); void player_skip_song(int num); void player_volume_step(float percent); /* This is called periodically to monitor the backend player */ -void player_monitor(); +void player_monitor(void); /* Available back-end players */ diff --git a/players/gstplayer.c b/players/gstplayer.c index 01f77a7..7c12c8b 100644 --- a/players/gstplayer.c +++ b/players/gstplayer.c @@ -38,7 +38,7 @@ gstplayer_handle_about_to_finish(GstElement *obj UNUSED, gpointer userdata UNUSE } void -gstplayer_init() +gstplayer_init(void) { /* * - init gstreamer @@ -109,7 +109,7 @@ gstplayer_play(const char *filename) /* pause / unpause playback */ void -gstplayer_pause() +gstplayer_pause(void) { /* assertions */ if (!gplayer.player) @@ -131,7 +131,7 @@ gstplayer_pause() /* stop playback */ void -gstplayer_stop() +gstplayer_stop(void) { if (!gplayer.player) gplayer.fatal_cb("gstplayer_pause: player not initialized\n"); @@ -144,7 +144,7 @@ gstplayer_stop() } void -gstplayer_cleanup() +gstplayer_cleanup(void) { if (! gplayer.player) return; @@ -171,7 +171,7 @@ gstplayer_seek(int seconds) void -gstplayer_monitor() +gstplayer_monitor(void) { GstMessage *msg; if (!gplayer.bus) @@ -205,7 +205,7 @@ gstplayer_monitor() } bool -gstplayer_is_playing() +gstplayer_is_playing(void) { if (!gplayer.player) return false; @@ -213,7 +213,7 @@ gstplayer_is_playing() } bool -gstplayer_is_paused() +gstplayer_is_paused(void) { if (!gplayer.player) return false; diff --git a/players/gstplayer.h b/players/gstplayer.h index b23c8f7..3340e32 100644 --- a/players/gstplayer.h +++ b/players/gstplayer.h @@ -44,26 +44,26 @@ typedef struct { GstBus *bus; } gst_player; -void gstplayer_init(); -void gstplayer_cleanup(); +void gstplayer_init(void); +void gstplayer_cleanup(void); -void gstplayer_stop(); +void gstplayer_stop(void); void gstplayer_play(const char *); -void gstplayer_pause(); +void gstplayer_pause(void); void gstplayer_seek(int); void gstplayer_volume_step(float); -float gstplayer_get_position(); -float gstplayer_get_volume(); -bool gstplayer_is_playing(); -bool gstplayer_is_paused(); +float gstplayer_get_position(void); +float gstplayer_get_volume(void); +bool gstplayer_is_playing(void); +bool gstplayer_is_paused(void); void gstplayer_set_callback_playnext(void (*f)(void)); void gstplayer_set_callback_notice(void (*f)(char *, ...)); void gstplayer_set_callback_error(void (*f)(char *, ...)); void gstplayer_set_callback_fatal(void (*f)(char *, ...)); -void gstplayer_monitor(); +void gstplayer_monitor(void); #endif /* VITUNES_GSTPLAYER_H */ diff --git a/players/mplayer.c b/players/mplayer.c index fcc8f71..258012c 100644 --- a/players/mplayer.c +++ b/players/mplayer.c @@ -43,7 +43,7 @@ bool restarting = false; void mplayer_volume_set(float); -void mplayer_volume_query(); +void mplayer_volume_query(void); static void mplayer_send_cmd(const char *cmd) @@ -52,7 +52,7 @@ mplayer_send_cmd(const char *cmd) } void -mplayer_start() +mplayer_start(void) { int pwrite[2]; int pread[2]; @@ -114,7 +114,7 @@ mplayer_start() } void -mplayer_finish() +mplayer_finish(void) { mplayer_send_cmd("\nquit\n"); @@ -125,7 +125,7 @@ mplayer_finish() } void -mplayer_restart() +mplayer_restart(void) { int status; @@ -144,7 +144,7 @@ mplayer_restart() } void -mplayer_sigchld_message() +mplayer_sigchld_message(void) { /* TODO find a way to check if mplayer is in $PATH in start() */ mplayer_callback_fatal("%s is crashing too often. Possible causes are:\n\ @@ -154,7 +154,7 @@ mplayer_sigchld_message() } void -mplayer_sigchld() +mplayer_sigchld(void) { static time_t last_sigchld = -1; @@ -195,7 +195,7 @@ mplayer_play(const char *file) } void -mplayer_stop() +mplayer_stop(void) { mplayer_send_cmd("\nstop\n"); @@ -204,7 +204,7 @@ mplayer_stop() } void -mplayer_pause() +mplayer_pause(void) { if (!mplayer_state.playing) return; @@ -282,7 +282,7 @@ mplayer_volume_set(float percent) } void -mplayer_volume_query() +mplayer_volume_query(void) { static const char *cmd = "\npausing_keep get_property volume\n"; @@ -336,7 +336,7 @@ mplayer_set_callback_fatal(void (*f)(char *, ...)) * song, according to the current playmode. ****************************************************************************/ void -mplayer_monitor() +mplayer_monitor(void) { static const char *query_cmd = "\nget_property time_pos\n"; static const char *answer_fail = "ANS_ERROR=PROPERTY_UNAVAILABLE"; diff --git a/players/mplayer.h b/players/mplayer.h index d3ee2cf..942adb5 100644 --- a/players/mplayer.h +++ b/players/mplayer.h @@ -39,26 +39,26 @@ # include "../debug.h" #endif -void mplayer_start(); -void mplayer_finish(); -void mplayer_sigchld(); +void mplayer_start(void); +void mplayer_finish(void); +void mplayer_sigchld(void); void mplayer_play(const char *file); -void mplayer_stop(); -void mplayer_pause(); +void mplayer_stop(void); +void mplayer_pause(void); void mplayer_seek(int seconds); void mplayer_volume_step(float percent); -float mplayer_get_position(); -float mplayer_get_volume(); -bool mplayer_is_playing(); -bool mplayer_is_paused(); +float mplayer_get_position(void); +float mplayer_get_volume(void); +bool mplayer_is_playing(void); +bool mplayer_is_paused(void); void mplayer_set_callback_playnext(void (*f)(void)); void mplayer_set_callback_notice(void (*f)(char *, ...)); void mplayer_set_callback_error(void (*f)(char *, ...)); void mplayer_set_callback_fatal(void (*f)(char *, ...)); -void mplayer_monitor(); +void mplayer_monitor(void); #endif diff --git a/playlist.h b/playlist.h index 947be4e..0ce2fd7 100644 --- a/playlist.h +++ b/playlist.h @@ -107,7 +107,7 @@ int retrieve_playlist_filenames(const char *dirname, char ***files); playlist_changeset *changeset_create(short t, size_t s, meta_info **f, int l); void changeset_free(playlist_changeset *c); -playlist_changeset **playlist_history_new(); +playlist_changeset **playlist_history_new(void); void playlist_history_free(playlist *p); void playlist_history_push(playlist *p, playlist_changeset *c); diff --git a/uinterface.c b/uinterface.c index eef84e3..0de148e 100644 --- a/uinterface.c +++ b/uinterface.c @@ -139,13 +139,13 @@ ui_init(int library_width) } bool -ui_is_init() +ui_is_init(void) { return (ui.active != NULL) && !isendwin(); } void -ui_destroy() +ui_destroy(void) { /* destroy each window (this also free()'s the mem for each window) */ delwin(ui.player); @@ -166,7 +166,7 @@ ui_destroy() } void -ui_resize() +ui_resize(void) { struct winsize ws; @@ -205,7 +205,7 @@ ui_resize() } void -ui_hide_library() +ui_hide_library(void) { int w, h; @@ -222,7 +222,7 @@ ui_hide_library() } void -ui_unhide_library() +ui_unhide_library(void) { int w, h; @@ -241,7 +241,7 @@ ui_unhide_library() } void -ui_clear() +ui_clear(void) { wclear(ui.player); wclear(ui.command); diff --git a/uinterface.h b/uinterface.h index 0c6c02e..adb7206 100644 --- a/uinterface.h +++ b/uinterface.h @@ -72,12 +72,12 @@ typedef struct extern uinterface ui; /* the global ui struct */ void ui_init(int library_width); -bool ui_is_init(); -void ui_clear(); -void ui_destroy(); -void ui_resize(); +bool ui_is_init(void); +void ui_clear(void); +void ui_destroy(void); +void ui_resize(void); -void ui_hide_library(); -void ui_unhide_library(); +void ui_hide_library(void); +void ui_unhide_library(void); #endif diff --git a/vitunes.c b/vitunes.c index e65db99..34386d3 100644 --- a/vitunes.c +++ b/vitunes.c @@ -76,7 +76,7 @@ char *progname; int handle_switches(int argc, char *argv[]); void usage(void); void signal_handler(int); -void setup_timer(); +void setup_timer(void); int @@ -297,7 +297,7 @@ signal_handler(int sig) /* handle any signal flags */ void -process_signals() +process_signals(void) { /* cppcheck-suppress variableScope */ static playlist *prev_queue = NULL; @@ -357,7 +357,7 @@ process_signals() /* setup timer signal handler above */ void -setup_timer() +setup_timer(void) { struct sigaction sig_act; struct itimerval timer; @@ -387,7 +387,7 @@ setup_timer() * XXX note that this requires mdb, ui, and player to all be loaded/setup */ void -load_config() +load_config(void) { const char *errmsg = NULL; size_t length, linenum; diff --git a/vitunes.h b/vitunes.h index acd07f8..54d4a50 100644 --- a/vitunes.h +++ b/vitunes.h @@ -64,7 +64,7 @@ extern int visual_mode_start; extern volatile sig_atomic_t VSIG_QUIT; /* other */ -void load_config(); -void process_signals(); +void load_config(void); +void process_signals(void); #endif From d276904bcdc44d7f042ce08a426089343aa05046 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Thu, 13 Dec 2012 18:14:59 +0000 Subject: [PATCH 4/5] Fix indentation. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 27b1946..d27e919 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ LDEPS=$(TAGLIB_LIBS) $(GSTREAMER_LIBS) ODEPS=$(GSTREAMER_OBJS) # build variables -CC ?= /usr/bin/cc +CC ?= /usr/bin/cc CFLAGS += -c -std=c89 -Wall -Wextra -Wno-unused-value $(CDEBUG) $(CDEPS) LIBS += -lm -lncurses -lutil $(LDEPS) From e8627bf5d4bbba0adee24704036f91c435f43af4 Mon Sep 17 00:00:00 2001 From: Tiago Cunha Date: Thu, 13 Dec 2012 18:24:35 +0000 Subject: [PATCH 5/5] Add -Wstrict-prototypes to CFLAGS. To prevent declaring or defining functions without parameter specification. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d27e919..6926004 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ ODEPS=$(GSTREAMER_OBJS) # build variables CC ?= /usr/bin/cc -CFLAGS += -c -std=c89 -Wall -Wextra -Wno-unused-value $(CDEBUG) $(CDEPS) +CFLAGS += -c -std=c89 -Wall -Wextra -Wno-unused-value -Wstrict-prototypes $(CDEBUG) $(CDEPS) LIBS += -lm -lncurses -lutil $(LDEPS) # object files