Remove unreachable #else directives in plugins. (#10523)
They are unreachable because Makefile.am will conditionally include the relevant source files iff the #ifdef's argument is defined in configure.ac.
vkalintiris committed
Feb 25, 2021 at 14:29 UTC
ad163251fca6056b3f88221cfc8f246ce1df3feb
6 files changed
+14
-95
collectors/cups.plugin/cups_plugin.c
+1
-13
@@ -7,6 +7,7 @@
7
*/
8
9
#include "../../libnetdata/libnetdata.h"
10
+#include <cups/cups.h>
11
#include <limits.h>
12
13
// callback required by fatal()
@@ -45,10 +46,6 @@ static int debug = 0;
46
static int netdata_update_every = 1;
47
static int netdata_priority = 100004;
48
48
-
49
-#ifdef HAVE_CUPS
50
-#include <cups/cups.h>
51
-
49
http_t *http; // connection to the cups daemon
50
51
/*
@@ -468,12 +465,3 @@ int main(int argc, char **argv) {
465
httpClose(http);
466
info("CUPS process exiting");
467
}
471
-
472
-#else // !HAVE_CUPS
473
-
474
-int main(int argc, char **argv)
475
-{
476
- fatal("cups.plugin is not compiled.");
477
-}
478
-
479
-#endif // !HAVE_CUPS
collectors/freeipmi.plugin/freeipmi_plugin.c
-10
@@ -26,8 +26,6 @@
26
#include <unistd.h>
27
#include <sys/time.h>
28
29
-#ifdef HAVE_FREEIPMI
30
-
29
#define IPMI_PARSE_DEVICE_LAN_STR "lan"
30
#define IPMI_PARSE_DEVICE_LAN_2_0_STR "lan_2_0"
31
#define IPMI_PARSE_DEVICE_LAN_2_0_STR2 "lan20"
@@ -1861,11 +1859,3 @@ int main (int argc, char **argv) {
1859
if(now_monotonic_sec() - started_t > 14400) exit(0);
1860
}
1861
}
1864
-
1865
-#else // !HAVE_FREEIPMI
1866
-
1867
-int main(int argc, char **argv) {
1868
- fatal("freeipmi.plugin is not compiled.");
1869
-}
1870
-
1871
-#endif // !HAVE_FREEIPMI
collectors/nfacct.plugin/plugin_nfacct.c
+8
-49
@@ -1,6 +1,9 @@
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
#include "../../libnetdata/libnetdata.h"
4
+#include <linux/netfilter/nfnetlink_conntrack.h>
5
+#include <libmnl/libmnl.h>
6
+#include <libnetfilter_acct/libnetfilter_acct.h>
7
8
#define PLUGIN_NFACCT_NAME "nfacct.plugin"
9
@@ -13,9 +16,6 @@
16
#define NETDATA_CHART_PRIO_NETFILTER_PACKETS 8906
17
#define NETDATA_CHART_PRIO_NETFILTER_BYTES 8907
18
16
-#ifdef HAVE_LIBMNL
17
-#include <libmnl/libmnl.h>
18
-
19
static inline size_t mnl_buffer_size() {
20
long s = MNL_SOCKET_BUFFER_SIZE;
21
if(s <= 0) return 8192;
@@ -50,25 +50,13 @@ int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *
50
51
// required by get_system_cpus()
52
char *netdata_configured_host_prefix = "";
53
-
54
-// Variables
55
-
53
+// variables
54
static int debug = 0;
57
-
55
static int netdata_update_every = 1;
56
60
-// ----------------------------------------------------------------------------
61
-// DO_NFSTAT - collect netfilter connection tracker statistics via netlink
62
-// example: https://github.com/formorer/pkg-conntrack-tools/blob/master/src/conntrack.c
63
-
64
-#ifdef HAVE_LINUX_NETFILTER_NFNETLINK_CONNTRACK_H
65
-#define DO_NFSTAT 1
66
-
57
#define RRD_TYPE_NET_STAT_NETFILTER "netfilter"
58
#define RRD_TYPE_NET_STAT_CONNTRACK "netlink"
59
70
-#include <linux/netfilter/nfnetlink_conntrack.h>
71
-
60
static struct {
61
int update_every;
62
char *buf;
@@ -530,16 +518,6 @@ static void nfstat_send_metrics() {
518
printf("END\n");
519
}
520
533
-#endif // HAVE_LINUX_NETFILTER_NFNETLINK_CONNTRACK_H
534
-
535
-
536
-// ----------------------------------------------------------------------------
537
-// DO_NFACCT - collect netfilter accounting statistics via netlink
538
-
539
-#ifdef HAVE_LIBNETFILTER_ACCT
540
-#define DO_NFACCT 1
541
-
542
-#include <libnetfilter_acct/libnetfilter_acct.h>
521
522
struct nfacct_data {
523
char *name;
@@ -760,8 +738,6 @@ static void nfacct_send_metrics() {
738
printf("END\n");
739
}
740
763
-#endif // HAVE_LIBNETFILTER_ACCT
764
-
741
static void nfacct_signal_handler(int signo)
742
{
743
exit((signo == SIGPIPE)?1:0);
@@ -866,15 +842,13 @@ int main(int argc, char **argv) {
842
else if(freq)
843
error("update frequency %d seconds is too small for NFACCT. Using %d.", freq, netdata_update_every);
844
869
-#ifdef DO_NFACCT
870
- if(debug) fprintf(stderr, "nfacct.plugin: calling nfacct_init()\n");
845
+ if (debug)
846
+ fprintf(stderr, "nfacct.plugin: calling nfacct_init()\n");
847
int nfacct = !nfacct_init(netdata_update_every);
872
-#endif
848
874
-#ifdef DO_NFSTAT
875
- if(debug) fprintf(stderr, "nfacct.plugin: calling nfstat_init()\n");
849
+ if (debug)
850
+ fprintf(stderr, "nfacct.plugin: calling nfstat_init()\n");
851
int nfstat = !nfstat_init(netdata_update_every);
877
-#endif
852
853
// ------------------------------------------------------------------------
854
// the main loop
@@ -899,7 +873,6 @@ int main(int argc, char **argv) {
873
, dt
874
);
875
902
-#ifdef DO_NFACCT
876
if(likely(nfacct)) {
877
if(debug) fprintf(stderr, "nfacct.plugin: calling nfacct_collect()\n");
878
nfacct = !nfacct_collect();
@@ -909,9 +882,7 @@ int main(int argc, char **argv) {
882
nfacct_send_metrics();
883
}
884
}
912
-#endif
885
914
-#ifdef DO_NFSTAT
886
if(likely(nfstat)) {
887
if(debug) fprintf(stderr, "nfacct.plugin: calling nfstat_collect()\n");
888
nfstat = !nfstat_collect();
@@ -921,7 +892,6 @@ int main(int argc, char **argv) {
892
nfstat_send_metrics();
893
}
894
}
924
-#endif
895
896
fflush(stdout);
897
@@ -931,14 +901,3 @@ int main(int argc, char **argv) {
901
902
info("NFACCT process exiting");
903
}
934
-
935
-#else // !HAVE_LIBMNL
936
-
937
-int main(int argc, char **argv) {
938
- (void)argc;
939
- (void)argv;
940
-
941
- fatal("nfacct.plugin is not compiled.");
942
-}
943
-
944
-#endif // !HAVE_LIBMNL
collectors/xenstat.plugin/xenstat_plugin.c
+3
-17
@@ -2,6 +2,9 @@
2
3
#include "../../libnetdata/libnetdata.h"
4
5
+#include <xenstat.h>
6
+#include <libxl.h>
7
+
8
#define PLUGIN_XENSTAT_NAME "xenstat.plugin"
9
10
#define NETDATA_CHART_PRIO_XENSTAT_NODE_CPUS 30001
@@ -62,15 +65,9 @@ int health_variable_lookup(const char *variable, uint32_t hash, struct rrdcalc *
65
char *netdata_configured_host_prefix = "";
66
67
// Variables
65
-
68
static int debug = 0;
67
-
69
static int netdata_update_every = 1;
70
70
-#ifdef HAVE_LIBXENSTAT
71
-#include <xenstat.h>
72
-#include <libxl.h>
73
-
71
struct vcpu_metrics {
72
unsigned int id;
73
@@ -1093,14 +1090,3 @@ int main(int argc, char **argv) {
1090
xenstat_uninit(xhandle);
1091
info("XENSTAT process exiting");
1092
}
1096
-
1097
-#else // !HAVE_LIBXENSTAT
1098
-
1099
-int main(int argc, char **argv) {
1100
- (void)argc;
1101
- (void)argv;
1102
-
1103
- fatal("xenstat.plugin is not compiled.");
1104
-}
1105
-
1106
-#endif // !HAVE_LIBXENSTAT
configure.ac
+1
-5
@@ -888,9 +888,7 @@ if test "${enable_plugin_nfacct}" != "no" -a "${have_libnetfilter_acct}" = "yes"
888
-a "${have_libmnl}" = "yes" \
889
-a "${have_nfnetlink_conntrack}" = "yes"; then
890
enable_plugin_nfacct="yes"
891
- AC_DEFINE([HAVE_LIBMNL], [1], [libmnl usability])
892
- AC_DEFINE([HAVE_LIBNETFILTER_ACCT], [1], [libnetfilter_acct usability])
893
- AC_DEFINE([HAVE_LINUX_NETFILTER_NFNETLINK_CONNTRACK_H], [1], [libnetfilter_nfnetlink_conntrack header usability])
891
+ AC_DEFINE([HAVE_NFACCT], [1], [netfilter accounting usability])
892
OPTIONAL_NFACCT_CFLAGS="${NFACCT_CFLAGS} ${LIBMNL_CFLAGS}"
893
OPTIONAL_NFACCT_LIBS="${NFACCT_LIBS} ${LIBMNL_LIBS}"
894
else
@@ -956,8 +954,6 @@ AC_MSG_CHECKING([if xenstat.plugin should be enabled])
954
if test "${enable_plugin_xenstat}" != "no" -a "${have_libxenstat}" = "yes" -a "${have_libxenlight}" = "yes" -a "${have_libyajl}" = "yes"; then
955
enable_plugin_xenstat="yes"
956
AC_DEFINE([HAVE_LIBXENSTAT], [1], [libxenstat usability])
959
- AC_DEFINE([HAVE_LIBXENLIGHT], [1], [libxenlight usability])
960
- AC_DEFINE([HAVE_LIBYAJL], [1], [libyajl usability])
957
OPTIONAL_XENSTAT_CFLAGS="${XENLIGHT_CFLAGS} ${YAJL_CFLAGS}"
958
OPTIONAL_XENSTAT_LIBS="-lxenstat ${XENLIGHT_LIBS} ${YAJL_LIBS}"
959
else
daemon/buildinfo.c
+1
-1
@@ -116,7 +116,7 @@
116
#define FEAT_CUPS "NO"
117
#endif
118
119
-#ifdef HAVE_LIBMNL
119
+#ifdef HAVE_NFACCT
120
#define FEAT_NFACCT "YES"
121
#else
122
#define FEAT_NFACCT "NO"