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:
parent
e77f3eb9f9
commit
76329c0206
|
@ -8,7 +8,7 @@
|
||||||
PLAT= none
|
PLAT= none
|
||||||
|
|
||||||
CC= gcc
|
CC= gcc
|
||||||
CFLAGS= -g -O2 -Wall -Wpedantic $(MYCFLAGS)
|
CFLAGS= -g -O2 -Wall -Wpedantic -Wshadow $(MYCFLAGS)
|
||||||
AR= ar rc
|
AR= ar rc
|
||||||
RANLIB= ranlib
|
RANLIB= ranlib
|
||||||
RM= rm -f
|
RM= rm -f
|
||||||
|
|
|
@ -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;
|
Quit = 0;
|
||||||
editorSetStatusMessage(Previous_error);
|
editorSetStatusMessage(Previous_error);
|
||||||
while(!Quit) {
|
while(!Quit) {
|
||||||
|
|
|
@ -530,7 +530,7 @@ void lua_len (lua_State *L, int i) {
|
||||||
case LUA_TUSERDATA:
|
case LUA_TUSERDATA:
|
||||||
if (luaL_callmeta(L, i, "__len"))
|
if (luaL_callmeta(L, i, "__len"))
|
||||||
break;
|
break;
|
||||||
/* maybe fall through */
|
/* maybe fall through */
|
||||||
default:
|
default:
|
||||||
luaL_error(L, "attempt to get length of a %s value",
|
luaL_error(L, "attempt to get length of a %s value",
|
||||||
lua_typename(L, lua_type(L, i)));
|
lua_typename(L, lua_type(L, i)));
|
||||||
|
|
|
@ -1304,7 +1304,7 @@ Read a character from the window input.
|
||||||
@see curses.echo
|
@see curses.echo
|
||||||
@see keypad
|
@see keypad
|
||||||
*/
|
*/
|
||||||
extern void switch_to_editor (lua_State *L, const char *message);
|
extern void switch_to_editor (lua_State *L);
|
||||||
static int
|
static int
|
||||||
Wgetch(lua_State *L)
|
Wgetch(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -1316,7 +1316,7 @@ Wgetch(lua_State *L)
|
||||||
if (c == 24) /* ctrl-x */
|
if (c == 24) /* ctrl-x */
|
||||||
exit(0);
|
exit(0);
|
||||||
if (c == 5) /* ctrl-e */
|
if (c == 5) /* ctrl-e */
|
||||||
switch_to_editor(L, "");
|
switch_to_editor(L);
|
||||||
/* handle other standard menu hotkeys here */
|
/* handle other standard menu hotkeys here */
|
||||||
|
|
||||||
return pushintresult(c);
|
return pushintresult(c);
|
||||||
|
|
|
@ -412,7 +412,7 @@ Instruction symbexec (const Proto *pt, int lastpc, int reg) {
|
||||||
case OP_FORLOOP:
|
case OP_FORLOOP:
|
||||||
case OP_FORPREP:
|
case OP_FORPREP:
|
||||||
checkreg(pt, a+3);
|
checkreg(pt, a+3);
|
||||||
/* go through */
|
/* fall through */
|
||||||
case OP_JMP: {
|
case OP_JMP: {
|
||||||
int dest = pc+1+b;
|
int dest = pc+1+b;
|
||||||
/* not full check and jump is forward and do not skip `lastpc'? */
|
/* not full check and jump is forward and do not skip `lastpc'? */
|
||||||
|
|
17
src/lua.c
17
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);
|
int infd = open(filename, O_RDONLY);
|
||||||
read(infd, out, 8190); /* TODO: handle overly large file */
|
read(infd, out, 8190); /* TODO: handle overly large file */
|
||||||
close(infd);
|
close(infd);
|
||||||
|
@ -373,15 +373,12 @@ void editor_refresh_buffer (void) {
|
||||||
clearEditor();
|
clearEditor();
|
||||||
editorOpen("teliva_editbuffer");
|
editorOpen("teliva_editbuffer");
|
||||||
}
|
}
|
||||||
extern void resumeEdit (lua_State *L, char *filename);
|
extern void resumeEdit (lua_State *L);
|
||||||
void editor_resume (lua_State *L) {
|
|
||||||
resumeEdit(L, "teliva_editbuffer");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int load_editor_buffer_to_current_definition_in_image(lua_State *L) {
|
int load_editor_buffer_to_current_definition_in_image(lua_State *L) {
|
||||||
char new_contents[8192] = {0};
|
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);
|
update_definition(L, Current_definition, new_contents);
|
||||||
save_image(L);
|
save_image(L);
|
||||||
/* reload binding */
|
/* reload binding */
|
||||||
|
@ -402,7 +399,7 @@ void edit_image (lua_State *L, const char *definition) {
|
||||||
break;
|
break;
|
||||||
Previous_error = lua_tostring(L, -1);
|
Previous_error = lua_tostring(L, -1);
|
||||||
if (Previous_error == NULL) Previous_error = "(error object is not a string)";
|
if (Previous_error == NULL) Previous_error = "(error object is not a string)";
|
||||||
editor_resume(L);
|
resumeEdit(L);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -550,7 +547,7 @@ int browse_image (lua_State *L) {
|
||||||
|
|
||||||
|
|
||||||
extern void cleanup_curses (void);
|
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. */
|
/* clobber the app's ncurses colors; we'll restart the app when we rerun it. */
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
init_pair(i, i, -1);
|
init_pair(i, i, -1);
|
||||||
|
@ -581,13 +578,13 @@ static int collectargs (char **argv, int *pi, int *pv, int *pe) {
|
||||||
return i;
|
return i;
|
||||||
case 'i':
|
case 'i':
|
||||||
notail(argv[i]);
|
notail(argv[i]);
|
||||||
*pi = 1; /* go through */
|
*pi = 1; /* fall through */
|
||||||
case 'v':
|
case 'v':
|
||||||
notail(argv[i]);
|
notail(argv[i]);
|
||||||
*pv = 1;
|
*pv = 1;
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
*pe = 1; /* go through */
|
*pe = 1; /* fall through */
|
||||||
case 'l':
|
case 'l':
|
||||||
if (argv[i][2] == '\0') {
|
if (argv[i][2] == '\0') {
|
||||||
i++;
|
i++;
|
||||||
|
|
|
@ -9,7 +9,7 @@ OBJS= \
|
||||||
config.o \
|
config.o \
|
||||||
ec.o
|
ec.o
|
||||||
|
|
||||||
WARN=-Wall -pedantic
|
WARN=-Wall -Wpedantic -Wshadow
|
||||||
|
|
||||||
BSD_CFLAGS=-O2 -fPIC $(WARN) $(INCDIR) $(DEFS)
|
BSD_CFLAGS=-O2 -fPIC $(WARN) $(INCDIR) $(DEFS)
|
||||||
BSD_LDFLAGS=-O -fPIC -shared $(LIBDIR)
|
BSD_LDFLAGS=-O -fPIC -shared $(LIBDIR)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
* LuaSec 1.0.2
|
* 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.
|
* Matthew Wild.
|
||||||
* Copyright (C) 2006-2021 Bruno Silvestre.
|
* 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)
|
static int set_verify_flag(const char *str, int *flag)
|
||||||
{
|
{
|
||||||
if (!strcmp(str, "none")) {
|
if (!strcmp(str, "none")) {
|
||||||
*flag |= SSL_VERIFY_NONE;
|
*flag |= SSL_VERIFY_NONE;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ static int set_verify_flag(const char *str, int *flag)
|
||||||
*flag |= SSL_VERIFY_CLIENT_ONCE;
|
*flag |= SSL_VERIFY_CLIENT_ONCE;
|
||||||
return 1;
|
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;
|
*flag |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
|
||||||
return 1;
|
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 */
|
lua_pop(L, 1); /* Remove the result from the stack */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* fallback */
|
/* fall through */
|
||||||
case LUA_TSTRING:
|
case LUA_TSTRING:
|
||||||
strncpy(buf, lua_tostring(L, -1), size);
|
strncpy(buf, lua_tostring(L, -1), size);
|
||||||
lua_pop(L, 1); /* Remove the result from the stack */
|
lua_pop(L, 1); /* Remove the result from the stack */
|
||||||
|
@ -398,8 +398,8 @@ static int load_key(lua_State *L)
|
||||||
case LUA_TFUNCTION:
|
case LUA_TFUNCTION:
|
||||||
SSL_CTX_set_default_passwd_cb(ctx, passwd_cb);
|
SSL_CTX_set_default_passwd_cb(ctx, passwd_cb);
|
||||||
SSL_CTX_set_default_passwd_cb_userdata(ctx, L);
|
SSL_CTX_set_default_passwd_cb_userdata(ctx, L);
|
||||||
/* fallback */
|
/* fall through */
|
||||||
case LUA_TNIL:
|
case LUA_TNIL:
|
||||||
if (SSL_CTX_use_PrivateKey_file(ctx, filename, SSL_FILETYPE_PEM) == 1)
|
if (SSL_CTX_use_PrivateKey_file(ctx, filename, SSL_FILETYPE_PEM) == 1)
|
||||||
lua_pushboolean(L, 1);
|
lua_pushboolean(L, 1);
|
||||||
else {
|
else {
|
||||||
|
@ -543,7 +543,7 @@ static int set_mode(lua_State *L)
|
||||||
lua_pushboolean(L, 0);
|
lua_pushboolean(L, 0);
|
||||||
lua_pushfstring(L, "invalid mode (%s)", str);
|
lua_pushfstring(L, "invalid mode (%s)", str);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure DH parameters.
|
* 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) {
|
if (ret != OPENSSL_NPN_NEGOTIATED) {
|
||||||
lua_pop(L, 2);
|
lua_pop(L, 2);
|
||||||
return SSL_TLSEXT_ERR_NOACK;
|
return SSL_TLSEXT_ERR_NOACK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the result because lua_pop() can collect the pointer
|
// Copy the result because lua_pop() can collect the pointer
|
||||||
ctx->alpn = malloc(*outlen);
|
ctx->alpn = malloc(*outlen);
|
||||||
|
|
|
@ -174,7 +174,7 @@ SO_linux=so
|
||||||
O_linux=o
|
O_linux=o
|
||||||
CC_linux=gcc
|
CC_linux=gcc
|
||||||
DEF_linux=-DLUASOCKET_$(DEBUG)
|
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
|
LDFLAGS_linux= -o
|
||||||
LD_linux=ld
|
LD_linux=ld
|
||||||
SOCKET_linux=usocket.o
|
SOCKET_linux=usocket.o
|
||||||
|
|
Loading…
Reference in New Issue