Skip to content

Commit d1c1042

Browse files
authored
Merge pull request #1278 from LinuxCNC/jepler/warnings-fixes
Fix (and silence) a bunch of build-time diagnostics ("warnings")
2 parents 0238ea7 + ac62308 commit d1c1042

File tree

21 files changed

+96
-90
lines changed

21 files changed

+96
-90
lines changed

src/Makefile

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,6 @@ install: install-software install-docs
2525

2626
install-software: install-kernel-dep install-kernel-indep install-menu
2727

28-
29-
# buster gcc (Debian 8.3.0-6) emits many warnings
30-
# use at your own risk
31-
ifeq ($(origin SUPPRESS_WARNINGS), undefined)
32-
else
33-
QUIETFLAGS ?=
34-
QUIETFLAGS += -Wno-unused-label
35-
QUIETFLAGS += -Wno-format-overflow
36-
QUIETFLAGS += -Wno-format-truncation
37-
QUIETFLAGS += -Wno-stringop-truncation
38-
CXXQUIETFLAGS := $(QUIETFLAGS)
39-
CXXQUIETFLAGS += -Wno-catch-value
40-
endif
41-
4228
ifeq ($(origin KERNELRELEASE), undefined)
4329
MAKEFLAGS += --warn-undefined-variables
4430
endif
@@ -258,11 +244,17 @@ INCLUDE += $(LIBTIRPC_CFLAGS)
258244
# Compilation options. Perhaps some of these should come from Makefile.inc? (CXXFLAGS now does)
259245
INTEGER_OVERFLOW_FLAGS := -fwrapv
260246
OPT := -Os $(INTEGER_OVERFLOW_FLAGS)
261-
DEBUG := $(DEBUG) -g -Wall
247+
DEBUG := $(DEBUG) -g -Wall -Wno-stringop-truncation
262248
CFLAGS := $(INCLUDE) $(OPT) $(DEBUG) $(EXTRA_DEBUG) -DULAPI -std=gnu99 -fgnu89-inline -Werror=implicit-function-declaration $(CFLAGS) $(CPPFLAGS)
263249
CXXFLAGS := $(INCLUDE) $(EXTRA_DEBUG) -DULAPI $(DEBUG) $(OPT) -Woverloaded-virtual $(CXXFLAGS) $(CPPFLAGS)
264250
CXXFLAGS += $(call cxx-option, -Wno-psabi)
265251
CXXFLAGS += $(call cxx-option, -std=gnu++11, -std=gnu++0x)
252+
# In Debian 11, any inclusion of <boost/python.hpp> leads to several
253+
# diagnostics from included headers about deprecated features. LinuxCNC does
254+
# not directly use these deprecated features, but it does use boost::python.
255+
# Silence the warnings just when they occur in files using boost/python.hpp by
256+
# adding SILENCE_BOOST_INTERNAL_DIAGNOSTICS_FLAGS to the object's EXTRAFLAGS
257+
SILENCE_BOOST_INTERNAL_DIAGNOSTICS_FLAGS = -DBOOST_ALLOW_DEPRECATED_HEADERS=1 -DBOOST_BIND_GLOBAL_PLACEHOLDERS=1
266258

267259
CFLAGS += $(TOOL_NML_FLAG)
268260
CXXFLAGS += $(TOOL_NML_FLAG)
@@ -645,7 +637,7 @@ install install-software install-docs:
645637

646638
MENUS = ../share/menus/CNC.menu \
647639
../share/desktop-directories/cnc.directory
648-
install-menus install-menu: $(MENUS) $(XDGDESKTOP)
640+
rip-install-menus rip-install-menu: $(MENUS) $(XDGDESKTOP)
649641
mkdir -p $(HOME)/.config/menus/applications-merged
650642
cp $< $(HOME)/.config/menus/applications-merged
651643
else

src/emc/kinematics/Submakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ USERSRCS += $(GENSERKINSSRCS)
77

88
DELTAMODULESRCS := emc/kinematics/lineardeltakins.cc
99
PYSRCS += $(DELTAMODULESRCS)
10-
$(call TOOBJS, $(DELTAMODULESRCS)): CFLAGS += -x c++ -Wno-declaration-after-statement
10+
$(call TOOBJS, $(DELTAMODULESRCS)): EXTRAFLAGS += $(SILENCE_BOOST_INTERNAL_DIAGNOSTICS_FLAGS)
1111

1212
DELTAMODULE := ../lib/python/lineardeltakins.so
1313
$(DELTAMODULE): $(call TOOBJS, $(DELTAMODULESRCS))
@@ -27,7 +27,7 @@ TARGETS += ../bin/genserkins
2727

2828
RDELTAMODULESRCS := emc/kinematics/rotarydeltakins.cc
2929
PYSRCS += $(RDELTAMODULESRCS)
30-
$(call TOOBJS, $(RDELTAMODULESRCS)): CFLAGS += -x c++ -Wno-declaration-after-statement
30+
$(call TOOBJS, $(RDELTAMODULESRCS)): EXTRAFLAGS += $(SILENCE_BOOST_INTERNAL_DIAGNOSTICS_FLAGS)
3131

3232
RDELTAMODULE := ../lib/python/rotarydeltakins.so
3333
$(RDELTAMODULE): $(call TOOBJS, $(RDELTAMODULESRCS))

src/emc/rs274ngc/Submakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ LIBRS274SRCS := $(addprefix emc/rs274ngc/, \
3636
interp_inspection.cc)
3737
USERSRCS += $(LIBRS274SRCS)
3838

39-
$(call TOOBJSDEPS, $(LIBRS274SRCS)) : EXTRAFLAGS=-fPIC $(BOOST_DEBUG_FLAGS)
39+
$(call TOOBJSDEPS, $(LIBRS274SRCS)) : EXTRAFLAGS+=-fPIC $(BOOST_DEBUG_FLAGS)
40+
$(call TOOBJSDEPS, emc/rs274ngc/pyinterp1.cc emc/rs274ngc/pyparamclass.cc emc/rs274ngc/pyinterp1.cc emc/rs274ngc/pyblock.cc emc/rs274ngc/pyarrays.cc emc/rs274ngc/interpmodule.cc): EXTRAFLAGS += $(SILENCE_BOOST_INTERNAL_DIAGNOSTICS_FLAGS)
4041

4142
TARGETS += ../lib/librs274.so ../lib/librs274.so.0
4243

src/emc/rs274ngc/array1.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
#ifndef BOOST_PYTHON_MAX_ARITY
1010
#define BOOST_PYTHON_MAX_ARITY 4
1111
#endif
12-
#include <boost/python/iterator.hpp>
12+
#include <boost/python/class.hpp>
13+
#include <boost/python/object/class_detail.hpp>
1314
#include <boost/python/enum.hpp>
1415
#include <boost/python/object.hpp>
1516
#include <boost/python/scope.hpp>

src/emc/task/Submakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ MILLTASKSRCS := \
2323
emc/task/taskclass.cc \
2424
emc/task/backtrace.cc \
2525

26+
$(call TOOBJSDEPS, emc/task/taskmodule.cc): EXTRAFLAGS += $(SILENCE_BOOST_INTERNAL_DIAGNOSTICS_FLAGS)
27+
2628
USERSRCS += $(MILLTASKSRCS)
2729

2830
#LDFLAGS +=

src/emc/task/emctask.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ int emcTaskInit()
184184
// set the user_defined_fmt string with dirname
185185
// note the %%02d means 2 digits after the M code
186186
// and we need two % to get the literal %
187-
ret = snprintf(user_defined_fmt[dct], sizeof(user_defined_fmt[0]),
187+
ret = snprintf(user_defined_fmt[dct], sizeof(user_defined_fmt[dct]),
188188
"%s/M1%%02d", expanddir); // update global
189189
if(ret >= sizeof(user_defined_fmt[0])){
190190
return -EMSGSIZE; // name truncated
@@ -217,13 +217,13 @@ int emcTaskHalt()
217217

218218
int emcTaskStateRestore()
219219
{
220-
int res;
220+
int res = 0;
221221
// Do NOT restore on MDI command
222222
if (emcStatus->task.mode == EMC_TASK_MODE_AUTO) {
223223
// Validity of state tag checked within restore function
224224
res = pinterp->restore_from_tag(emcStatus->motion.traj.tag);
225225
}
226-
return 0;
226+
return res;
227227
}
228228

229229
int emcTaskAbort()

src/emc/usr_intf/emclcd.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,9 +1705,9 @@ int main(int argc, char *argv[])
17051705
while((opt = getopt_long(argc, argv, "p:d:a", longopts, NULL)) != -1) {
17061706
switch(opt) {
17071707
case 'a': autoStart = 1; break;
1708-
case 'd': strncpy(driver, optarg, strlen(optarg) + 1); break;
1708+
case 'd': snprintf(driver, sizeof(driver), "%s", optarg); break;
17091709
case 'p': sscanf(optarg, "%d", &port); break;
1710-
case 's': strncpy(server, optarg, strlen(optarg) + 1); break;
1710+
case 's': snprintf(server, sizeof(server), "%s", optarg); break;
17111711
case 'w': sscanf(optarg, "%f", &delay); break;
17121712
}
17131713
}

src/emc/usr_intf/emcrsh.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,12 +2939,12 @@ int main(int argc, char *argv[])
29392939
while((opt = getopt_long(argc, argv, "he:n:p:s:w:d:", longopts, NULL)) != - 1) {
29402940
switch(opt) {
29412941
case 'h': usage(argv[0]); exit(1);
2942-
case 'e': strncpy(enablePWD, optarg, strlen(optarg) + 1); break;
2943-
case 'n': strncpy(serverName, optarg, strlen(optarg) + 1); break;
2942+
case 'e': snprintf(enablePWD, sizeof(enablePWD), "%s", optarg); break;
2943+
case 'n': snprintf(serverName, sizeof(serverName), "%s", optarg); break;
29442944
case 'p': sscanf(optarg, "%d", &port); break;
29452945
case 's': sscanf(optarg, "%d", &maxSessions); break;
2946-
case 'w': strncpy(pwd, optarg, strlen(optarg) + 1); break;
2947-
case 'd': strncpy(defaultPath, optarg, strlen(optarg) + 1);
2946+
case 'w': snprintf(pwd, sizeof(pwd), "%s", optarg); break;
2947+
case 'd': snprintf(defaultPath, sizeof(defaultPath), "%s", optarg); break;
29482948
}
29492949
}
29502950

src/emc/usr_intf/schedrmt.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,12 +1254,12 @@ int main(int argc, char *argv[])
12541254
// process local command line args
12551255
while((opt = getopt_long(argc, argv, "e:n:p:s:w:", longopts, NULL)) != -1) {
12561256
switch(opt) {
1257-
case 'e': strncpy(enablePWD, optarg, strlen(optarg) + 1); break;
1258-
case 'n': strncpy(serverName, optarg, strlen(optarg) + 1); break;
1257+
case 'e': snprintf(enablePWD, sizeof(enablePWD), "%s", optarg); break;
1258+
case 'n': snprintf(serverName, sizeof(serverName), "%s", optarg); break;
12591259
case 'p': sscanf(optarg, "%d", &port); break;
12601260
case 's': sscanf(optarg, "%d", &maxSessions); break;
1261-
case 'w': strncpy(pwd, optarg, strlen(optarg) + 1); break;
1262-
case 'd': strncpy(defaultPath, optarg, strlen(optarg) + 1);
1261+
case 'w': snprintf(pwd, sizeof(pwd), "%s", optarg); break;
1262+
case 'd': snprintf(defaultPath, sizeof(defaultPath), "%s", optarg); break;
12631263
}
12641264
}
12651265

src/hal/classicladder/Submakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ CLASSICLADDERSRCS := $(addprefix hal/classicladder/, \
3232
vars_access.c \
3333
)
3434

35-
GTK2_CFLAGS += -DGTK_INTERFACE -DGTK2
35+
GTK2_CFLAGS += -DGTK_INTERFACE -DGTK2 -Wno-deprecated-declarations
3636
ifeq ($(HAVE_GNOMEPRINT),yes)
3737
CLASSICLADDERSRCS += hal/classicladder/print_gnome.c
3838
GTK2_CFLAGS += -DGNOME_PRINT_USE

0 commit comments

Comments
 (0)