diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-11-22 19:01:07 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-11-22 19:01:07 -0800 |
commit | 76329c0206ede0a986da423e6a813ef91334f6cd (patch) | |
tree | 5a70ab28b4d10e92b0e2ca8e12efc99f2b8fd425 /src | |
parent | e77f3eb9f9cfbd79f56c666545e96d00cb752695 (diff) | |
download | teliva-76329c0206ede0a986da423e6a813ef91334f6cd.tar.gz |
standardize warning flags everywhere
I'd like to enable -Wextra as well, but that creates some false positives. I've at least made my changes clean w.r.t. -Wextra. Now we have 4 remaining warnings with gcc 9.3 that seem genuine. Need to fix those.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/kilo.c | 2 | ||||
-rw-r--r-- | src/lcurses/compat-5.2.c | 2 | ||||
-rw-r--r-- | src/lcurses/window.c | 4 | ||||
-rw-r--r-- | src/ldebug.c | 2 | ||||
-rw-r--r-- | src/lua.c | 17 | ||||
-rw-r--r-- | src/luasec/Makefile | 2 | ||||
-rw-r--r-- | src/luasec/context.c | 16 | ||||
-rw-r--r-- | src/luasocket/makefile | 2 |
9 files changed, 23 insertions, 26 deletions
diff --git a/src/Makefile b/src/Makefile index 45f3b41..1d36c93 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,7 +8,7 @@ PLAT= none CC= gcc -CFLAGS= -g -O2 -Wall -Wpedantic $(MYCFLAGS) +CFLAGS= -g -O2 -Wall -Wpedantic -Wshadow $(MYCFLAGS) AR= ar rc RANLIB= ranlib RM= rm -f diff --git a/src/kilo.c b/src/kilo.c index f43cfdb..1e672c1 100644 --- a/src/kilo.c +++ b/src/kilo.c @@ -1119,7 +1119,7 @@ void edit(lua_State* L, char* filename, const char* message) { } } -void resumeEdit(lua_State* L, char* filename) { +void resumeEdit(lua_State* L) { Quit = 0; editorSetStatusMessage(Previous_error); while(!Quit) { diff --git a/src/lcurses/compat-5.2.c b/src/lcurses/compat-5.2.c index 89eb73b..bdbd8a4 100644 --- a/src/lcurses/compat-5.2.c +++ b/src/lcurses/compat-5.2.c @@ -530,7 +530,7 @@ void lua_len (lua_State *L, int i) { case LUA_TUSERDATA: if (luaL_callmeta(L, i, "__len")) break; - /* maybe fall through */ + /* maybe fall through */ default: luaL_error(L, "attempt to get length of a %s value", lua_typename(L, lua_type(L, i))); diff --git a/src/lcurses/window.c b/src/lcurses/window.c index 9c243ea..82d8dfe 100644 --- a/src/lcurses/window.c +++ b/src/lcurses/window.c @@ -1304,7 +1304,7 @@ Read a character from the window input. @see curses.echo @see keypad */ -extern void switch_to_editor (lua_State *L, const char *message); +extern void switch_to_editor (lua_State *L); static int Wgetch(lua_State *L) { @@ -1316,7 +1316,7 @@ Wgetch(lua_State *L) if (c == 24) /* ctrl-x */ exit(0); if (c == 5) /* ctrl-e */ - switch_to_editor(L, ""); + switch_to_editor(L); /* handle other standard menu hotkeys here */ return pushintresult(c); diff --git a/src/ldebug.c b/src/ldebug.c index de643b0..8d1e0ab 100644 --- a/src/ldebug.c +++ b/src/ldebug.c @@ -412,7 +412,7 @@ Instruction symbexec (const Proto *pt, int lastpc, int reg) { case OP_FORLOOP: case OP_FORPREP: checkreg(pt, a+3); - /* go through */ + /* fall through */ case OP_JMP: { int dest = pc+1+b; /* not full check and jump is forward and do not skip `lastpc'? */ diff --git a/src/lua.c b/src/lua.c index e248e36..12e9934 100644 --- a/src/lua.c +++ b/src/lua.c @@ -326,7 +326,7 @@ void save_to_current_definition_and_editor_buffer (lua_State *L, const char *def } -static void read_contents (lua_State *L, char *filename, char *out) { +static void read_contents (char *filename, char *out) { int infd = open(filename, O_RDONLY); read(infd, out, 8190); /* TODO: handle overly large file */ close(infd); @@ -373,15 +373,12 @@ void editor_refresh_buffer (void) { clearEditor(); editorOpen("teliva_editbuffer"); } -extern void resumeEdit (lua_State *L, char *filename); -void editor_resume (lua_State *L) { - resumeEdit(L, "teliva_editbuffer"); -} +extern void resumeEdit (lua_State *L); int load_editor_buffer_to_current_definition_in_image(lua_State *L) { char new_contents[8192] = {0}; - read_contents(L, "teliva_editbuffer", new_contents); + read_contents("teliva_editbuffer", new_contents); update_definition(L, Current_definition, new_contents); save_image(L); /* reload binding */ @@ -402,7 +399,7 @@ void edit_image (lua_State *L, const char *definition) { break; Previous_error = lua_tostring(L, -1); if (Previous_error == NULL) Previous_error = "(error object is not a string)"; - editor_resume(L); + resumeEdit(L); lua_pop(L, 1); } } @@ -550,7 +547,7 @@ int browse_image (lua_State *L) { extern void cleanup_curses (void); -void switch_to_editor (lua_State *L, const char *message) { +void switch_to_editor (lua_State *L) { /* clobber the app's ncurses colors; we'll restart the app when we rerun it. */ for (int i = 0; i < 8; ++i) init_pair(i, i, -1); @@ -581,13 +578,13 @@ static int collectargs (char **argv, int *pi, int *pv, int *pe) { return i; case 'i': notail(argv[i]); - *pi = 1; /* go through */ + *pi = 1; /* fall through */ case 'v': notail(argv[i]); *pv = 1; break; case 'e': - *pe = 1; /* go through */ + *pe = 1; /* fall through */ case 'l': if (argv[i][2] == '\0') { i++; diff --git a/src/luasec/Makefile b/src/luasec/Makefile index d266209..c495109 100644 --- a/src/luasec/Makefile +++ b/src/luasec/Makefile @@ -9,7 +9,7 @@ OBJS= \ config.o \ ec.o -WARN=-Wall -pedantic +WARN=-Wall -Wpedantic -Wshadow BSD_CFLAGS=-O2 -fPIC $(WARN) $(INCDIR) $(DEFS) BSD_LDFLAGS=-O -fPIC -shared $(LIBDIR) diff --git a/src/luasec/context.c b/src/luasec/context.c index 5496fbf..b67f36f 100644 --- a/src/luasec/context.c +++ b/src/luasec/context.c @@ -1,7 +1,7 @@ /*-------------------------------------------------------------------------- * LuaSec 1.0.2 * - * Copyright (C) 2014-2021 Kim Alvefur, Paul Aurich, Tobias Markmann, + * Copyright (C) 2014-2021 Kim Alvefur, Paul Aurich, Tobias Markmann, * Matthew Wild. * Copyright (C) 2006-2021 Bruno Silvestre. * @@ -120,7 +120,7 @@ static const SSL_METHOD* str2method(const char *method, int *vmin, int *vmax) */ static int set_verify_flag(const char *str, int *flag) { - if (!strcmp(str, "none")) { + if (!strcmp(str, "none")) { *flag |= SSL_VERIFY_NONE; return 1; } @@ -132,7 +132,7 @@ static int set_verify_flag(const char *str, int *flag) *flag |= SSL_VERIFY_CLIENT_ONCE; return 1; } - if (!strcmp(str, "fail_if_no_peer_cert")) { + if (!strcmp(str, "fail_if_no_peer_cert")) { *flag |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT; return 1; } @@ -153,7 +153,7 @@ static int passwd_cb(char *buf, int size, int flag, void *udata) lua_pop(L, 1); /* Remove the result from the stack */ return 0; } - /* fallback */ + /* fall through */ case LUA_TSTRING: strncpy(buf, lua_tostring(L, -1), size); lua_pop(L, 1); /* Remove the result from the stack */ @@ -398,8 +398,8 @@ static int load_key(lua_State *L) case LUA_TFUNCTION: SSL_CTX_set_default_passwd_cb(ctx, passwd_cb); SSL_CTX_set_default_passwd_cb_userdata(ctx, L); - /* fallback */ - case LUA_TNIL: + /* fall through */ + case LUA_TNIL: if (SSL_CTX_use_PrivateKey_file(ctx, filename, SSL_FILETYPE_PEM) == 1) lua_pushboolean(L, 1); else { @@ -543,7 +543,7 @@ static int set_mode(lua_State *L) lua_pushboolean(L, 0); lua_pushfstring(L, "invalid mode (%s)", str); return 1; -} +} /** * Configure DH parameters. @@ -677,7 +677,7 @@ static int alpn_cb(SSL *s, const unsigned char **out, unsigned char *outlen, if (ret != OPENSSL_NPN_NEGOTIATED) { lua_pop(L, 2); return SSL_TLSEXT_ERR_NOACK; - } + } // Copy the result because lua_pop() can collect the pointer ctx->alpn = malloc(*outlen); diff --git a/src/luasocket/makefile b/src/luasocket/makefile index 688aca4..f6548d9 100644 --- a/src/luasocket/makefile +++ b/src/luasocket/makefile @@ -174,7 +174,7 @@ SO_linux=so O_linux=o CC_linux=gcc DEF_linux=-DLUASOCKET_$(DEBUG) -CFLAGS_linux=-g -O2 -Wall -Wpedantic -Wshadow -Wextra $(LUAINC:%=-I%) $(DEF) +CFLAGS_linux= -g -O2 -Wall -Wpedantic -Wshadow -Wextra $(LUAINC:%=-I%) $(DEF) LDFLAGS_linux= -o LD_linux=ld SOCKET_linux=usocket.o |