Skip to content

Commit 02364ef

Browse files
committed
COMMON: resolved some compiler warnings
1 parent fb6b2c3 commit 02364ef

File tree

13 files changed

+32
-30
lines changed

13 files changed

+32
-30
lines changed

configure.ac

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ function checkDebugMode() {
8181
AC_MSG_RESULT([$with_debug])
8282
if test "$with_debug" = "yes" || test "$with_debug" = "full"
8383
then
84-
CFLAGS="${CFLAGS} -g -O0 -fstack-protector-all"
85-
CXXFLAGS="${CXXFLAGS} -g -O0 -fstack-protector-all"
84+
DEBUG_FLAGS="-g -O1 -fstack-protector-all -fno-omit-frame-pointer"
85+
#-fsanitize=address,undefined"
86+
CFLAGS="${DEBUG_FLAGS}"
87+
CXXFLAGS="${DEBUG_FLAGS}"
8688
AC_DEFINE(_DEBUG, 1, [debugging build enabled])
8789
fi
8890
AC_SUBST(CFLAGS)

src/common/blib_func.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,9 +2003,7 @@ void cmd_numN(long funcCode, var_t *r) {
20032003
int pw;
20042004
if (code_peek() == kwTYPE_SEP) {
20052005
par_getcomma();
2006-
if (!prog_error) {
2007-
pw = par_getint();
2008-
}
2006+
pw = prog_error ? 0 : par_getint();
20092007
} else {
20102008
pw = 0;
20112009
}

src/common/device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ void dev_clear_sound_queue() {
111111
void dev_printf(const char *format, ...) {
112112
va_list args;
113113
va_start(args, format);
114-
unsigned size = vsnprintf(NULL, 0, format, args);
114+
unsigned size = format ? vsnprintf(NULL, 0, format, args) : 0;
115115
va_end(args);
116116

117117
if (size) {
@@ -133,7 +133,7 @@ void dev_printf(const char *format, ...) {
133133
void log_printf(const char *format, ...) {
134134
va_list args;
135135
va_start(args, format);
136-
unsigned size = vsnprintf(NULL, 0, format, args);
136+
unsigned size = format ? vsnprintf(NULL, 0, format, args) : 0;
137137
va_end(args);
138138

139139
if (size) {

src/common/hashmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ int hashmap_destroy(var_p_t var_p) {
150150
}
151151

152152
int hashmap_get_hash(const char *key, int length) {
153-
int hash = 1, i;
154-
for (i = 0; i < length && key[i] != '\0'; i++) {
153+
uint64_t hash = 1;
154+
for (int i = 0; i < length && key[i] != '\0'; i++) {
155155
hash += to_lower(key[i]);
156156
hash <<= 3;
157157
hash ^= (hash >> 3);

src/common/sberr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void sc_raise(const char *format, ...) {
100100

101101
va_list args;
102102
va_start(args, format);
103-
unsigned size = vsnprintf(NULL, 0, format, args);
103+
unsigned size = format ? vsnprintf(NULL, 0, format, args) : 0;
104104
va_end(args);
105105

106106
if (comp_bc_sec) {
@@ -123,7 +123,7 @@ void rt_raise(const char *format, ...) {
123123

124124
va_list args;
125125
va_start(args, format);
126-
unsigned size = vsnprintf(NULL, 0, format, args);
126+
unsigned size = format ? vsnprintf(NULL, 0, format, args) : 0;
127127
va_end(args);
128128

129129
err_title_msg(0, strcmp(format, ERR_PARAM_NUM) == 0);

src/common/scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4446,7 +4446,7 @@ char *comp_preproc_options(char *p) {
44464446
char lc = *pe;
44474447
*pe = '\0';
44484448
if (strlen(p) < OPT_CMD_SZ) {
4449-
strcpy(opt_command, p);
4449+
strlcpy(opt_command, p, sizeof(opt_command));
44504450
} else {
44514451
memcpy(opt_command, p, OPT_CMD_SZ - 1);
44524452
opt_command[OPT_CMD_SZ - 1] = '\0';

src/platform/android/jni/runtime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ void Runtime::runShell() {
522522
_app->activity->callbacks->onContentRectChanged = onContentRectChanged;
523523
loadConfig();
524524

525-
strcpy(opt_modpath, getString("getModulePath"));
525+
strlcpy(opt_modpath, getString("getModulePath"), sizeof(opt_modpath));
526526

527527
#if defined(_ANDROID_LIBRARY)
528528
runOnce(MAIN_BAS, true);

src/platform/console/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ bool process_options(int argc, char *argv[], char **runFile, bool *tmpFile, bool
288288
break;
289289
case 'm':
290290
if (optarg) {
291-
strcpy(opt_modpath, optarg);
291+
strlcpy(opt_modpath, optarg, sizeof(opt_modpath));
292292
}
293293
break;
294294
case 's':
@@ -301,7 +301,7 @@ bool process_options(int argc, char *argv[], char **runFile, bool *tmpFile, bool
301301
}
302302
break;
303303
case 'o':
304-
strcpy(opt_command, optarg);
304+
strlcpy(opt_command, optarg, sizeof(opt_command));
305305
break;
306306
case 'c':
307307
if (setup_command_program(optarg, runFile)) {

src/platform/fltk/MainWindow.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ void MainWindow::export_file(Fl_Widget *w, void *eventData) {
396396
void MainWindow::set_options(Fl_Widget *w, void *eventData) {
397397
const char *args = fl_input("Enter program command line", opt_command);
398398
if (args) {
399-
strcpy(opt_command, args);
399+
strlcpy(opt_command, args, sizeof(opt_command));
400400
}
401401
}
402402

@@ -768,7 +768,7 @@ int arg_cb(int argc, char **argv, int &i) {
768768
return 1;
769769

770770
case 'm':
771-
strcpy(opt_modpath, argv[i + 1]);
771+
strlcpy(opt_modpath, argv[i + 1], sizeof(opt_modpath));
772772
i += 2;
773773
return 1;
774774
}

src/platform/sdl/main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int g_debugPort = 4000;
5252
void appLog(const char *format, ...) {
5353
va_list args;
5454
va_start(args, format);
55-
unsigned size = vsnprintf(NULL, 0, format, args);
55+
unsigned size = format ? vsnprintf(NULL, 0, format, args) : 0;
5656
va_end(args);
5757

5858
if (size) {
@@ -68,7 +68,7 @@ void appLog(const char *format, ...) {
6868
buf[i--] = '\0';
6969
}
7070
strcat(buf, "\r\n");
71-
71+
7272
#if defined(WIN32)
7373
OutputDebugString(buf);
7474
#else
@@ -274,7 +274,7 @@ int main(int argc, char* argv[]) {
274274
|| (strstr(s, "://") != NULL))) {
275275
runFile = strdup(s);
276276
} else if (chdir(s) != 0) {
277-
strcpy(opt_command, s);
277+
strlcpy(opt_command, s, sizeof(opt_command));
278278
}
279279
}
280280
}
@@ -297,7 +297,7 @@ int main(int argc, char* argv[]) {
297297
opt_quiet = false;
298298
break;
299299
case 'c':
300-
strcpy(opt_command, optarg);
300+
strlcpy(opt_command, optarg, sizeof(opt_command));
301301
break;
302302
case 'f':
303303
fontFamily = strdup(optarg);
@@ -323,7 +323,7 @@ int main(int argc, char* argv[]) {
323323
break;
324324
case 'm':
325325
if (optarg) {
326-
strcpy(opt_modpath, optarg);
326+
strlcpy(opt_modpath, optarg, sizeof(opt_modpath));
327327
}
328328
break;
329329
case 'd':

0 commit comments

Comments
 (0)