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.
This commit is contained in:
Kartik K. Agaram 2021-11-22 19:01:07 -08:00
parent e77f3eb9f9
commit 76329c0206
9 changed files with 23 additions and 26 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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)));

View File

@ -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);

View File

@ -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'? */

View File

@ -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++;

View File

@ -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)

View File

@ -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);

View File

@ -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