Skip to content

Commit

Permalink
Make C compiler warnings be errors in CI (#953)
Browse files Browse the repository at this point in the history
Fixes #944
  • Loading branch information
mfikes committed Jun 2, 2019
1 parent 8442d59 commit db32018
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ steps:
- apt-get update
- apt-get -qq install -y default-jdk clang cmake xxd pkg-config unzip
- apt-get -qq install -y libjavascriptcoregtk-4.0 libglib2.0-dev libzip-dev libcurl4-gnutls-dev libicu-dev
- script/build --fast
- script/build --fast -Werror
- script/test
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then chmod +x linux-install-1.9.0.315.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ./linux-install-1.9.0.315.sh; fi

script: script/build && script/test
script: script/build -Werror && script/test
6 changes: 6 additions & 0 deletions planck-c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ set(CMAKE_BUILD_TYPE Release)
# Uncomment to enable Clang Address Sanitizer
#set (CMAKE_C_FLAGS "-fsanitize=address -O1 -fno-omit-frame-pointer")

add_compile_options(-Wall)

if(DEFINED ENV{WARN_ERROR_BUILD})
add_compile_options(-Werror)
endif()

set(SOURCE_FILES
archive.c
archive.h
Expand Down
59 changes: 0 additions & 59 deletions planck-c/edn.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ static form_reader get_macro_reader(wint_t c) {
}

static clj_Result read_form(clj_Reader *r) {
clj_Result result;
form_reader macro_reader;
wint_t c;
while (WEOF != (c = pop_char(r))) {
Expand Down Expand Up @@ -471,61 +470,3 @@ int clj_read_error(char *str, const clj_Reader *r, clj_Result result) {
return sprintf(str, "%s at line %d, column %d",
result_message(result), r->line, r->column);
}


// Print forms

static void print_string(clj_Printer *p, const wchar_t *s) {
const wchar_t *i;
for (i = s; *i != L'\0'; i++) {
p->putwchar(*i);
};
}

#pragma GCC diagnostic ignored "-Wall"

void clj_print(clj_Printer *p, const clj_Node *node) {
switch (node->type) {

case CLJ_NUMBER:
case CLJ_STRING:
case CLJ_REGEX:
case CLJ_SYMBOL:
case CLJ_KEYWORD:
case CLJ_CHARACTER:
print_string(p, node->value);
break;

case CLJ_LIST:
p->putwchar(L'(');
break;
case CLJ_LIST | CLJ_END:
p->putwchar(L')');
break;

case CLJ_VECTOR:
p->putwchar(L'[');
break;
case CLJ_VECTOR | CLJ_END:
p->putwchar(L']');
break;

case CLJ_MAP:
p->putwchar(L'{');
break;
case CLJ_MAP | CLJ_END:
p->putwchar(L'}');
break;

case CLJ_SET:
print_string(p, L"#{");
break;
case CLJ_SET | CLJ_END:
p->putwchar(L'}');
break;

default:
fatal("unexpected node type");
}
p->putwchar(L'\n');
}
2 changes: 1 addition & 1 deletion planck-c/engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ JSValueRef get_value(JSContextRef ctx, char *namespace, char *name) {

// printf("get_value: '%s'\n", namespace);
char *ns_tmp = strdup(namespace);
char *saveptr;
char *saveptr = NULL;
char *ns_part = strtok_r(ns_tmp, ".", &saveptr);
while (ns_part != NULL) {
char *munged_ns_part = munge(ns_part);
Expand Down
1 change: 0 additions & 1 deletion planck-c/linenoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ int linenoiseEditInsert(struct linenoiseState *l, char c);
* structure as described in the structure definition. */
static int completeLine(struct linenoiseState *ls) {
linenoiseCompletions lc = {0, NULL};
int nread, nwritten;
char c = 0;

completionCallback(ls->buf, &lc);
Expand Down
8 changes: 4 additions & 4 deletions planck-c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,17 @@ char *get_current_working_dir() {

char *calculate_dependencies_classpath(char *dependencies, char *local_repo) {

char *paths[1024];
char *paths[1024] = { 0 };
size_t ndx = 0;

char *saveptr;
char *saveptr = NULL;
char *dependency = strtok_r(dependencies, ",", &saveptr);
while (dependency != NULL) {
char *saveptr2;
char *saveptr2 = NULL;
char *sym = strtok_r(dependency, ":", &saveptr2);
char *version = strtok_r(NULL, ":", &saveptr2);

char *saveptr3;
char *saveptr3 = NULL;
char *group = strtok_r(sym, "/", &saveptr3);
char *p = group;
while (*p) {
Expand Down
6 changes: 3 additions & 3 deletions planck-c/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ bool process_line(repl_t *repl, char *input_line, bool split_on_newlines) {
// Split on newlines because input_line will contain newlines if pasting
if (split_on_newlines) {
char *tokenize = strdup(input_line);
char *saveptr;
char *saveptr = NULL;
char *token = strtok_r(tokenize, "\n", &saveptr);
while (token != NULL) {
linenoiseHistoryAdd(token);
Expand Down Expand Up @@ -338,12 +338,12 @@ void run_cmdline_loop(repl_t *repl) {
// handle the input. The initial case is for a new line (the
// new itself is not part of input_line).
bool break_out = false;
if (repl->input != NULL & strlen(input_line) == 0) {
if (repl->input != NULL && strlen(input_line) == 0) {
repl->indent_space_count = 0;
break_out = process_line(repl, input_line, false);
} else if (strlen(input_line) < 16384) {
char *tokenize = strdup(input_line);
char *saveptr;
char *saveptr = NULL;
char *token = strtok_r(tokenize, "\n", &saveptr);
while (token != NULL) {
repl->indent_space_count = 0;
Expand Down
3 changes: 3 additions & 0 deletions planck-c/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ static void *thread_proc(void *params) {
return (void *) wait_for_child((struct ThreadParams *) params);
}

#ifdef __APPLE__

static const char *get_path(void) {
const char *s = getenv("PATH");
return (s != NULL) ? s : ":/bin:/usr/bin";
Expand Down Expand Up @@ -342,6 +344,7 @@ static void planck_execvpe(const char *file, char * const *argv, char * const *
errno = sticky_errno;
}
}
#endif

static JSValueRef system_call(JSContextRef ctx, char **cmd, char *in_str, char **env, char *dir, int cb_idx) {
struct SystemResult result = {0, NULL, NULL};
Expand Down
4 changes: 4 additions & 0 deletions script/build
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ do
export VERBOSE_BUILD=1
shift
;;
-Werror)
export WARN_ERROR_BUILD=1
shift
;;
-R*)
export RESOLVE_ALIAS="${1:2}"
shift
Expand Down

0 comments on commit db32018

Please sign in to comment.