diff options
Diffstat (limited to 'gcc7.patch')
-rw-r--r-- | gcc7.patch | 211 |
1 files changed, 0 insertions, 211 deletions
diff --git a/gcc7.patch b/gcc7.patch deleted file mode 100644 index 113140e..0000000 --- a/gcc7.patch +++ /dev/null | |||
@@ -1,211 +0,0 @@ | |||
1 | From 0390d827eab62ad2d84f0d6db8278d683659c0ba Mon Sep 17 00:00:00 2001 | ||
2 | From: Oleg Pereverzev <oleg.pereverzev@gmail.com> | ||
3 | Date: Mon, 12 Jun 2017 23:20:59 +0300 | ||
4 | Subject: [PATCH] Support for GCC 7 | ||
5 | |||
6 | --- | ||
7 | lib/runcmd.c | 3 +++ | ||
8 | lib/snprintf.c | 6 ++++++ | ||
9 | src/naemon/checks.c | 12 +++++++++++- | ||
10 | src/naemon/configuration.c | 13 +++++++++++-- | ||
11 | src/naemon/macros.c | 18 ++++++++++++++++++ | ||
12 | src/naemon/xodtemplate.c | 11 ++++++++++- | ||
13 | 6 files changed, 59 insertions(+), 4 deletions(-) | ||
14 | |||
15 | diff --git a/lib/runcmd.c b/lib/runcmd.c | ||
16 | index eb6668fe..4e55fbd7 100644 | ||
17 | --- a/lib/runcmd.c | ||
18 | +++ b/lib/runcmd.c | ||
19 | @@ -199,6 +199,9 @@ int runcmd_cmd2strv(const char *str, int *out_argc, char **out_argv) | ||
20 | set_state(STATE_INSQ | STATE_INARG); | ||
21 | continue; | ||
22 | } | ||
23 | +#if __GNUC__ >= 7 | ||
24 | + __attribute__((fallthrough)); | ||
25 | +#endif | ||
26 | case '"': | ||
27 | if (have_state(STATE_INSQ)) | ||
28 | break; | ||
29 | diff --git a/lib/snprintf.c b/lib/snprintf.c | ||
30 | index 49bf8962..80b69dbf 100644 | ||
31 | --- a/lib/snprintf.c | ||
32 | +++ b/lib/snprintf.c | ||
33 | @@ -493,6 +493,9 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args | ||
34 | break; | ||
35 | case 'X': | ||
36 | cnk->flags |= DP_F_UP; | ||
37 | +#if __GNUC__ >= 7 | ||
38 | + __attribute__((fallthrough)); | ||
39 | +#endif | ||
40 | case 'x': | ||
41 | cnk->type = CNK_HEX; | ||
42 | cnk->flags |= DP_F_UNSIGNED; | ||
43 | @@ -503,6 +506,9 @@ static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args | ||
44 | case 'G': | ||
45 | case 'F': | ||
46 | cnk->flags |= DP_F_UP; | ||
47 | +#if __GNUC__ >= 7 | ||
48 | + __attribute__((fallthrough)); | ||
49 | +#endif | ||
50 | case 'a': | ||
51 | /* hex float not supported yet */ | ||
52 | case 'e': | ||
53 | diff --git a/src/naemon/checks.c b/src/naemon/checks.c | ||
54 | index 97bd9f73..91d83ef1 100644 | ||
55 | --- a/src/naemon/checks.c | ||
56 | +++ b/src/naemon/checks.c | ||
57 | @@ -207,6 +207,9 @@ int process_check_result_queue(char *dirname) | ||
58 | char *temp_buffer = NULL; | ||
59 | int result = OK, check_result_files = 0; | ||
60 | time_t start; | ||
61 | +#if __GNUC__ >= 7 | ||
62 | + unsigned int writesize; | ||
63 | +#endif | ||
64 | |||
65 | /* make sure we have what we need */ | ||
66 | if (dirname == NULL) { | ||
67 | @@ -240,9 +243,16 @@ int process_check_result_queue(char *dirname) | ||
68 | } | ||
69 | |||
70 | /* create /path/to/file */ | ||
71 | + | ||
72 | +#if __GNUC__ >= 7 | ||
73 | + writesize = snprintf(file, sizeof(file), "%s/%s", dirname, dirfile->d_name); | ||
74 | + if (writesize < (strlen(dirname) + strlen(dirfile->d_name) + 2)) | ||
75 | + nm_log(NSLOG_RUNTIME_WARNING, "Warning: truncated path to file in check result queue directory '%s'", dirfile->d_name); | ||
76 | +#else | ||
77 | snprintf(file, sizeof(file), "%s/%s", dirname, dirfile->d_name); | ||
78 | +#endif | ||
79 | file[sizeof(file) - 1] = '\x0'; | ||
80 | - | ||
81 | + | ||
82 | /* process this if it's a check result file... */ | ||
83 | x = strlen(dirfile->d_name); | ||
84 | if (x == 7 && dirfile->d_name[0] == 'c') { | ||
85 | diff --git a/src/naemon/configuration.c b/src/naemon/configuration.c | ||
86 | index a2a8d3ed..c4dc97dd 100644 | ||
87 | --- a/src/naemon/configuration.c | ||
88 | +++ b/src/naemon/configuration.c | ||
89 | @@ -59,6 +59,9 @@ read_config_file(const char *main_config_file, nagios_macros *mac) | ||
90 | char *argptr = NULL; | ||
91 | mmapfile *thefile = NULL; | ||
92 | DIR *tmpdir = NULL; | ||
93 | +#if __GNUC__ >= 7 | ||
94 | + unsigned int writesize; | ||
95 | +#endif | ||
96 | |||
97 | /* open the config file for reading */ | ||
98 | if ((thefile = mmap_fopen(main_config_file)) == NULL) { | ||
99 | @@ -1021,10 +1024,16 @@ read_config_file(const char *main_config_file, nagios_macros *mac) | ||
100 | if (strcmp(dirfile->d_name + strlen(dirfile->d_name) - 4, ".cfg")) | ||
101 | continue; | ||
102 | |||
103 | - /* create /path/to/file */ | ||
104 | + /* create /path/to/file */ | ||
105 | +#if __GNUC__ >= 7 | ||
106 | + writesize = snprintf(file, sizeof(file), "%s/%s", include_dir, dirfile->d_name); | ||
107 | + if (writesize < (strlen(include_dir) + strlen(dirfile->d_name) + 2)) | ||
108 | + nm_log(NSLOG_RUNTIME_WARNING, "Warning: truncated path to sub-configuration file '%s'", dirfile->d_name); | ||
109 | +#else | ||
110 | snprintf(file, sizeof(file), "%s/%s", include_dir, dirfile->d_name); | ||
111 | +#endif | ||
112 | file[sizeof(file) - 1] = '\x0'; | ||
113 | - | ||
114 | + | ||
115 | error |= read_config_file(file, mac); | ||
116 | } | ||
117 | closedir(dirp); | ||
118 | diff --git a/src/naemon/macros.c b/src/naemon/macros.c | ||
119 | index 700bc821..13d817cf 100644 | ||
120 | --- a/src/naemon/macros.c | ||
121 | +++ b/src/naemon/macros.c | ||
122 | @@ -1518,6 +1518,9 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c | ||
123 | /***************/ | ||
124 | case MACRO_HOSTGROUPNAMES: | ||
125 | *free_macro = TRUE; | ||
126 | +#if __GNUC__ >= 7 | ||
127 | + __attribute__((fallthrough)); | ||
128 | +#endif | ||
129 | case MACRO_HOSTNAME: | ||
130 | case MACRO_HOSTALIAS: | ||
131 | case MACRO_HOSTADDRESS: | ||
132 | @@ -1612,6 +1615,9 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c | ||
133 | /********************/ | ||
134 | case MACRO_HOSTGROUPMEMBERS: | ||
135 | *free_macro = TRUE; | ||
136 | +#if __GNUC__ >= 7 | ||
137 | + __attribute__((fallthrough)); | ||
138 | +#endif | ||
139 | case MACRO_HOSTGROUPNAME: | ||
140 | case MACRO_HOSTGROUPALIAS: | ||
141 | case MACRO_HOSTGROUPNOTES: | ||
142 | @@ -1640,6 +1646,9 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c | ||
143 | /******************/ | ||
144 | case MACRO_SERVICEGROUPNAMES: | ||
145 | *free_macro = TRUE; | ||
146 | +#if __GNUC__ >= 7 | ||
147 | + __attribute__((fallthrough)); | ||
148 | +#endif | ||
149 | case MACRO_SERVICEDESC: | ||
150 | case MACRO_SERVICESTATE: | ||
151 | case MACRO_SERVICESTATEID: | ||
152 | @@ -1757,6 +1766,9 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c | ||
153 | case MACRO_SERVICEGROUPNOTESURL: | ||
154 | case MACRO_SERVICEGROUPACTIONURL: | ||
155 | *free_macro = TRUE; | ||
156 | +#if __GNUC__ >= 7 | ||
157 | + __attribute__((fallthrough)); | ||
158 | +#endif | ||
159 | case MACRO_SERVICEGROUPNAME: | ||
160 | case MACRO_SERVICEGROUPALIAS: | ||
161 | /* a standard servicegroup macro */ | ||
162 | @@ -1781,6 +1793,9 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c | ||
163 | /******************/ | ||
164 | case MACRO_CONTACTGROUPNAMES: | ||
165 | *free_macro = TRUE; | ||
166 | +#if __GNUC__ >= 7 | ||
167 | + __attribute__((fallthrough)); | ||
168 | +#endif | ||
169 | case MACRO_CONTACTNAME: | ||
170 | case MACRO_CONTACTALIAS: | ||
171 | case MACRO_CONTACTEMAIL: | ||
172 | @@ -1841,6 +1856,9 @@ static int grab_macrox_value_r(nagios_macros *mac, int macro_type, char *arg1, c | ||
173 | /***********************/ | ||
174 | case MACRO_CONTACTGROUPMEMBERS: | ||
175 | *free_macro = TRUE; | ||
176 | +#if __GNUC__ >= 7 | ||
177 | + __attribute__((fallthrough)); | ||
178 | +#endif | ||
179 | case MACRO_CONTACTGROUPNAME: | ||
180 | case MACRO_CONTACTGROUPALIAS: | ||
181 | /* a standard contactgroup macro */ | ||
182 | diff --git a/src/naemon/xodtemplate.c b/src/naemon/xodtemplate.c | ||
183 | index d5fd1cda..225fc40a 100644 | ||
184 | --- a/src/naemon/xodtemplate.c | ||
185 | +++ b/src/naemon/xodtemplate.c | ||
186 | @@ -8443,7 +8443,10 @@ static int xodtemplate_process_config_dir(char *dir_name) | ||
187 | int result = OK; | ||
188 | register int x = 0; | ||
189 | struct stat stat_buf; | ||
190 | - | ||
191 | +#if __GNUC__ >= 7 | ||
192 | + unsigned int writesize; | ||
193 | +#endif | ||
194 | + | ||
195 | if (verify_config >= 2) | ||
196 | printf("Processing object config directory '%s'...\n", dir_name); | ||
197 | |||
198 | @@ -8462,7 +8465,13 @@ static int xodtemplate_process_config_dir(char *dir_name) | ||
199 | continue; | ||
200 | |||
201 | /* create /path/to/file */ | ||
202 | +#if __GNUC__ >= 7 | ||
203 | + writesize = snprintf(file, sizeof(file), "%s/%s", dir_name, dirfile->d_name); | ||
204 | + if (writesize < (strlen(dir_name) + strlen(dirfile->d_name) + 2)) | ||
205 | + nm_log(NSLOG_RUNTIME_WARNING, "Warning: truncated path to file '%s' in config directory '%s'", dirfile->d_name, dir_name); | ||
206 | +#else | ||
207 | snprintf(file, sizeof(file), "%s/%s", dir_name, dirfile->d_name); | ||
208 | +#endif | ||
209 | file[sizeof(file) - 1] = '\x0'; | ||
210 | |||
211 | /* process this if it's a non-hidden config file... */ | ||