Skip to content

Commit

Permalink
fix C compiler warnings in cobc
Browse files Browse the repository at this point in the history
error.c: missing default leads to undefined value [r5074]
replace.c: return of "const void"  [r5109]
  • Loading branch information
sf-mensch committed Jul 24, 2023
1 parent b9f6085 commit bc1d6c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 4 additions & 1 deletion cobc/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,14 @@ print_error (const char *file, int line, enum cb_error_kind kind,
{
const char *prefix;

switch( kind ){
switch (kind) {
case CB_KIND_ERROR: prefix = _("error: "); break;
case CB_KIND_WARNING: prefix = _("warning: "); break;
case CB_KIND_NOTE: prefix = _("note: "); break;
case CB_KIND_GENERAL: prefix = ""; break;
default:
cobc_err_msg ("call to print_error with unexpected error kind");
cobc_abort_terminate (1);
}

if (!file) {
Expand Down
14 changes: 6 additions & 8 deletions cobc/replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,26 +244,24 @@ token_list_add (WITH_DEPTH struct cb_token_list *list,
return p;
} else {
struct cb_token_list *cursor = list;
for(;cursor->next != NULL; cursor = cursor->next);
for (; cursor->next != NULL; cursor = cursor->next);
cursor->next = p;
return list;
}
}



static
const void pop_token (WITH_DEPTH struct cb_replacement_state *repls,
void pop_token (WITH_DEPTH struct cb_replacement_state *repls,
const char **text, const char **token)
{
const struct cb_token_list *q = repls->token_queue ;
const struct cb_token_list *q = repls->token_queue;
repls->token_queue = q->next ;
#ifdef DEBUG_REPLACE_TRACE
fprintf (stderr, "%spop_token(%s) -> '%s'\n",
DEPTH, repls->name, q->text);
#endif
if (text) *text = q->text ;
if (token) *token = q->token ;
if (text) *text = q->text;
if (token) *token = q->token;
}

static
Expand Down Expand Up @@ -417,7 +415,7 @@ void check_replace (WITH_DEPTH struct cb_replacement_state* repls,
replace_list = replace_list->next;

if (src->lead_trail == CB_REPLACE_LEADING
|| src->lead_trail == CB_REPLACE_TRAILING){
|| src->lead_trail == CB_REPLACE_TRAILING){
/* LEADING and TRAILING replacements are
* different: they match only on one text, so
* we just need one test to decide if it is a
Expand Down

0 comments on commit bc1d6c9

Please sign in to comment.