From 42125c63f23d65fa47f074524d26699eed60e439 Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Fri, 20 Dec 2019 17:33:22 -0500 Subject: [PATCH 1/2] Run clang-format over all header files --- config.h | 5 +++-- debug.h | 4 +++- iniparser/src/dictionary.h | 30 +++++++++++++----------------- iniparser/src/iniparser.h | 37 ++++++++++++++++--------------------- input/alsa.h | 5 ++--- input/fifo.h | 6 +++--- input/portaudio.h | 2 +- input/pulse.h | 5 ++--- output/raw.h | 4 ++-- output/terminal_ncurses.h | 14 +++++++------- output/terminal_noncurses.h | 3 ++- 11 files changed, 54 insertions(+), 61 deletions(-) diff --git a/config.h b/config.h index a2dc137..69e513b 100644 --- a/config.h +++ b/config.h @@ -1,5 +1,6 @@ #include -#include #include +#include -bool load_config(char configPath[255], char supportedInput[255], void* p, bool colorsOnly, void* error); +bool load_config(char configPath[255], char supportedInput[255], void *p, bool colorsOnly, + void *error); diff --git a/debug.h b/debug.h index 4e9d46f..f1f3c91 100644 --- a/debug.h +++ b/debug.h @@ -1,7 +1,9 @@ #include #ifdef NDEBUG -#define debug(...) do { } while (0) +#define debug(...) \ + do { \ + } while (0) #else #define debug(...) fprintf(stderr, __VA_ARGS__) #endif diff --git a/iniparser/src/dictionary.h b/iniparser/src/dictionary.h index d04b6ce..796c4ff 100644 --- a/iniparser/src/dictionary.h +++ b/iniparser/src/dictionary.h @@ -31,7 +31,6 @@ extern "C" { New types ---------------------------------------------------------------------------*/ - /*-------------------------------------------------------------------------*/ /** @brief Dictionary object @@ -43,13 +42,12 @@ extern "C" { */ /*-------------------------------------------------------------------------*/ typedef struct _dictionary_ { - int n ; /** Number of entries in dictionary */ - ssize_t size ; /** Storage size */ - char ** val ; /** List of string values */ - char ** key ; /** List of string keys */ - unsigned * hash ; /** List of hash values for keys */ -} dictionary ; - + int n; /** Number of entries in dictionary */ + ssize_t size; /** Storage size */ + char **val; /** List of string values */ + char **key; /** List of string keys */ + unsigned *hash; /** List of hash values for keys */ +} dictionary; /*--------------------------------------------------------------------------- Function prototypes @@ -67,7 +65,7 @@ typedef struct _dictionary_ { by comparing the key itself in last resort. */ /*--------------------------------------------------------------------------*/ -unsigned dictionary_hash(const char * key); +unsigned dictionary_hash(const char *key); /*-------------------------------------------------------------------------*/ /** @@ -80,7 +78,7 @@ unsigned dictionary_hash(const char * key); dictionary, give size=0. */ /*--------------------------------------------------------------------------*/ -dictionary * dictionary_new(size_t size); +dictionary *dictionary_new(size_t size); /*-------------------------------------------------------------------------*/ /** @@ -91,7 +89,7 @@ dictionary * dictionary_new(size_t size); Deallocate a dictionary object and all memory associated to it. */ /*--------------------------------------------------------------------------*/ -void dictionary_del(dictionary * vd); +void dictionary_del(dictionary *vd); /*-------------------------------------------------------------------------*/ /** @@ -107,8 +105,7 @@ void dictionary_del(dictionary * vd); dictionary object, you should not try to free it or modify it. */ /*--------------------------------------------------------------------------*/ -const char * dictionary_get(const dictionary * d, const char * key, const char * def); - +const char *dictionary_get(const dictionary *d, const char *key, const char *def); /*-------------------------------------------------------------------------*/ /** @@ -136,7 +133,7 @@ const char * dictionary_get(const dictionary * d, const char * key, const char * This function returns non-zero in case of failure. */ /*--------------------------------------------------------------------------*/ -int dictionary_set(dictionary * vd, const char * key, const char * val); +int dictionary_set(dictionary *vd, const char *key, const char *val); /*-------------------------------------------------------------------------*/ /** @@ -149,8 +146,7 @@ int dictionary_set(dictionary * vd, const char * key, const char * val); key cannot be found. */ /*--------------------------------------------------------------------------*/ -void dictionary_unset(dictionary * d, const char * key); - +void dictionary_unset(dictionary *d, const char *key); /*-------------------------------------------------------------------------*/ /** @@ -164,7 +160,7 @@ void dictionary_unset(dictionary * d, const char * key); output file pointers. */ /*--------------------------------------------------------------------------*/ -void dictionary_dump(const dictionary * d, FILE * out); +void dictionary_dump(const dictionary *d, FILE *out); #ifdef __cplusplus } diff --git a/iniparser/src/iniparser.h b/iniparser/src/iniparser.h index 0a9da72..e76b8ce 100644 --- a/iniparser/src/iniparser.h +++ b/iniparser/src/iniparser.h @@ -50,8 +50,7 @@ extern "C" { */ /*--------------------------------------------------------------------------*/ -int iniparser_getnsec(const dictionary * d); - +int iniparser_getnsec(const dictionary *d); /*-------------------------------------------------------------------------*/ /** @@ -68,8 +67,7 @@ int iniparser_getnsec(const dictionary * d); */ /*--------------------------------------------------------------------------*/ -const char * iniparser_getsecname(const dictionary * d, int n); - +const char *iniparser_getsecname(const dictionary *d, int n); /*-------------------------------------------------------------------------*/ /** @@ -83,7 +81,7 @@ const char * iniparser_getsecname(const dictionary * d, int n); */ /*--------------------------------------------------------------------------*/ -void iniparser_dump_ini(const dictionary * d, FILE * f); +void iniparser_dump_ini(const dictionary *d, FILE *f); /*-------------------------------------------------------------------------*/ /** @@ -98,7 +96,7 @@ void iniparser_dump_ini(const dictionary * d, FILE * f); */ /*--------------------------------------------------------------------------*/ -void iniparser_dumpsection_ini(const dictionary * d, const char * s, FILE * f); +void iniparser_dumpsection_ini(const dictionary *d, const char *s, FILE *f); /*-------------------------------------------------------------------------*/ /** @@ -113,7 +111,7 @@ void iniparser_dumpsection_ini(const dictionary * d, const char * s, FILE * f); purposes mostly. */ /*--------------------------------------------------------------------------*/ -void iniparser_dump(const dictionary * d, FILE * f); +void iniparser_dump(const dictionary *d, FILE *f); /*-------------------------------------------------------------------------*/ /** @@ -123,7 +121,7 @@ void iniparser_dump(const dictionary * d, FILE * f); @return Number of keys in section */ /*--------------------------------------------------------------------------*/ -int iniparser_getsecnkeys(const dictionary * d, const char * s); +int iniparser_getsecnkeys(const dictionary *d, const char *s); /*-------------------------------------------------------------------------*/ /** @@ -141,8 +139,7 @@ int iniparser_getsecnkeys(const dictionary * d, const char * s); a string allocated in the dictionary; do not free or modify them. */ /*--------------------------------------------------------------------------*/ -const char ** iniparser_getseckeys(const dictionary * d, const char * s, const char ** keys); - +const char **iniparser_getseckeys(const dictionary *d, const char *s, const char **keys); /*-------------------------------------------------------------------------*/ /** @@ -159,7 +156,7 @@ const char ** iniparser_getseckeys(const dictionary * d, const char * s, const c the dictionary, do not free or modify it. */ /*--------------------------------------------------------------------------*/ -const char * iniparser_getstring(const dictionary * d, const char * key, const char * def); +const char *iniparser_getstring(const dictionary *d, const char *key, const char *def); /*-------------------------------------------------------------------------*/ /** @@ -188,7 +185,7 @@ const char * iniparser_getstring(const dictionary * d, const char * key, const c Credits: Thanks to A. Becker for suggesting strtol() */ /*--------------------------------------------------------------------------*/ -int iniparser_getint(const dictionary * d, const char * key, int notfound); +int iniparser_getint(const dictionary *d, const char *key, int notfound); /*-------------------------------------------------------------------------*/ /** @@ -203,7 +200,7 @@ int iniparser_getint(const dictionary * d, const char * key, int notfound); the notfound value is returned. */ /*--------------------------------------------------------------------------*/ -double iniparser_getdouble(const dictionary * d, const char * key, double notfound); +double iniparser_getdouble(const dictionary *d, const char *key, double notfound); /*-------------------------------------------------------------------------*/ /** @@ -237,8 +234,7 @@ double iniparser_getdouble(const dictionary * d, const char * key, double notfou necessarily have to be 0 or 1. */ /*--------------------------------------------------------------------------*/ -int iniparser_getboolean(const dictionary * d, const char * key, int notfound); - +int iniparser_getboolean(const dictionary *d, const char *key, int notfound); /*-------------------------------------------------------------------------*/ /** @@ -253,8 +249,7 @@ int iniparser_getboolean(const dictionary * d, const char * key, int notfound); It is Ok to set val to NULL. */ /*--------------------------------------------------------------------------*/ -int iniparser_set(dictionary * ini, const char * entry, const char * val); - +int iniparser_set(dictionary *ini, const char *entry, const char *val); /*-------------------------------------------------------------------------*/ /** @@ -266,7 +261,7 @@ int iniparser_set(dictionary * ini, const char * entry, const char * val); If the given entry can be found, it is deleted from the dictionary. */ /*--------------------------------------------------------------------------*/ -void iniparser_unset(dictionary * ini, const char * entry); +void iniparser_unset(dictionary *ini, const char *entry); /*-------------------------------------------------------------------------*/ /** @@ -280,7 +275,7 @@ void iniparser_unset(dictionary * ini, const char * entry); of querying for the presence of sections in a dictionary. */ /*--------------------------------------------------------------------------*/ -int iniparser_find_entry(const dictionary * ini, const char * entry) ; +int iniparser_find_entry(const dictionary *ini, const char *entry); /*-------------------------------------------------------------------------*/ /** @@ -296,7 +291,7 @@ int iniparser_find_entry(const dictionary * ini, const char * entry) ; The returned dictionary must be freed using iniparser_freedict(). */ /*--------------------------------------------------------------------------*/ -dictionary * iniparser_load(const char * ininame); +dictionary *iniparser_load(const char *ininame); /*-------------------------------------------------------------------------*/ /** @@ -309,7 +304,7 @@ dictionary * iniparser_load(const char * ininame); gets out of the current context. */ /*--------------------------------------------------------------------------*/ -void iniparser_freedict(dictionary * d); +void iniparser_freedict(dictionary *d); #ifdef __cplusplus } diff --git a/input/alsa.h b/input/alsa.h index 89474da..9daf87d 100644 --- a/input/alsa.h +++ b/input/alsa.h @@ -1,4 +1,3 @@ -//header file for alsa, part of cava. - -void* input_alsa(void* data); +// header file for alsa, part of cava. +void *input_alsa(void *data); diff --git a/input/fifo.h b/input/fifo.h index e43826b..8afb382 100644 --- a/input/fifo.h +++ b/input/fifo.h @@ -1,3 +1,3 @@ -//header files for fifo, part of cava -void* input_fifo(void* data); -int write_to_fftw_input_buffers(int16_t buf[], int16_t frames, void* data); +// header files for fifo, part of cava +void *input_fifo(void *data); +int write_to_fftw_input_buffers(int16_t buf[], int16_t frames, void *data); diff --git a/input/portaudio.h b/input/portaudio.h index b6f17e1..3e21a7d 100644 --- a/input/portaudio.h +++ b/input/portaudio.h @@ -1 +1 @@ -void* input_portaudio(void *audiodata); +void *input_portaudio(void *audiodata); diff --git a/input/pulse.h b/input/pulse.h index 8441d82..5a16157 100644 --- a/input/pulse.h +++ b/input/pulse.h @@ -1,5 +1,4 @@ -//header file for pulse, part of cava. +// header file for pulse, part of cava. -void* input_pulse(void* data); +void *input_pulse(void *data); void getPulseDefaultSink(); - diff --git a/output/raw.h b/output/raw.h index 0c41c1d..f2f50cf 100644 --- a/output/raw.h +++ b/output/raw.h @@ -1,2 +1,2 @@ -int print_raw_out(int bars_count, int fd, int is_binary, int bit_format, - int ascii_range, char bar_delim, char frame_delim, int const f[200]); +int print_raw_out(int bars_count, int fd, int is_binary, int bit_format, int ascii_range, + char bar_delim, char frame_delim, int const f[200]); diff --git a/output/terminal_ncurses.h b/output/terminal_ncurses.h index 02c6dbe..5c36fb2 100644 --- a/output/terminal_ncurses.h +++ b/output/terminal_ncurses.h @@ -1,8 +1,8 @@ -void init_terminal_ncurses(char* const fg_color_string, - char* const bg_color_string, int predef_fg_color, int predef_bg_color, int gradient, - int gradient_count, char **gradient_colors,int* width, int* height); -void get_terminal_dim_ncurses(int* width, int* height); -int draw_terminal_ncurses(int is_tty, int terminal_height, int terminal_width, - int bars_count, int bar_width, int bar_spacing, int rest, const int f[200], - int flastd[200], int gradient); +void init_terminal_ncurses(char *const fg_color_string, char *const bg_color_string, + int predef_fg_color, int predef_bg_color, int gradient, + int gradient_count, char **gradient_colors, int *width, int *height); +void get_terminal_dim_ncurses(int *width, int *height); +int draw_terminal_ncurses(int is_tty, int terminal_height, int terminal_width, int bars_count, + int bar_width, int bar_spacing, int rest, const int f[200], + int flastd[200], int gradient); void cleanup_terminal_ncurses(void); diff --git a/output/terminal_noncurses.h b/output/terminal_noncurses.h index 15c8e31..938adce 100644 --- a/output/terminal_noncurses.h +++ b/output/terminal_noncurses.h @@ -1,4 +1,5 @@ int init_terminal_noncurses(int col, int bgcol, int w, int h, int bw); void get_terminal_dim_noncurses(int *w, int *h); -int draw_terminal_noncurses(int virt, int height, int width, int bars, int bw, int bs, int rest, int f[200], int flastd[200]); +int draw_terminal_noncurses(int virt, int height, int width, int bars, int bw, int bs, int rest, + int f[200], int flastd[200]); void cleanup_terminal_noncurses(void); From daed000cc3869a9b7c9bc0a7cd9c6bd7264f7454 Mon Sep 17 00:00:00 2001 From: Tudor Brindus Date: Fri, 20 Dec 2019 17:26:23 -0500 Subject: [PATCH 2/2] Add clang-format lint step to CI Also condense build-mac.yml and build.yml into one file, so we can have a single action reporting the status of the entire project. --- .github/workflows/build-mac.yml | 17 ----------------- .github/workflows/build.yml | 21 ++++++++++++++++++++- 2 files changed, 20 insertions(+), 18 deletions(-) delete mode 100644 .github/workflows/build-mac.yml diff --git a/.github/workflows/build-mac.yml b/.github/workflows/build-mac.yml deleted file mode 100644 index e9e1c08..0000000 --- a/.github/workflows/build-mac.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: build-mac -on: [push, pull_request] -jobs: - build: - runs-on: macos-latest - steps: - - uses: actions/checkout@v1 - - name: Install dependencies - run: | - brew install fftw ncurses libtool automake portaudio iniparser - ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize - - name: Generate configure - run: ./autogen.sh - - name: Run ./configure - run: LDFLAGS="-L/usr/local/opt/ncurses/lib" CPPFLAGS="-I/usr/local/opt/ncurses/include" ./configure - - name: Run make - run: make diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 171b350..789f7d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,12 @@ name: build on: [push, pull_request] jobs: - build: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: DoozyX/clang-format-lint-action@v0.5 + build-linux: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 @@ -15,3 +20,17 @@ jobs: run: CPPFLAGS=-I/usr/include/iniparser ./configure - name: Run make run: make + build-macos: + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + - name: Install dependencies + run: | + brew install fftw ncurses libtool automake portaudio iniparser + ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize + - name: Generate configure + run: ./autogen.sh + - name: Run ./configure + run: LDFLAGS="-L/usr/local/opt/ncurses/lib" CPPFLAGS="-I/usr/local/opt/ncurses/include" ./configure + - name: Run make + run: make