Skip to content

Commit d6309f6

Browse files
authored
Address compiler warnings (#376)
* `includes/config.h.in` * Wrap contents in `#ifndef CONFIG_H` * `includes/mod_tile.h` * Include `protocol.h` * For `XMLCONFIG_MAX` * Include `apr_tables.h` * For `apr_array_header_t`/`apr_time_t`/`apr_uint64_t` * Include `netinet/in.h` * For `in6_addr`/`in_addr_t` * `src/cache_expire.c` * Include `netinet/in.h` * For `htonl`/`htons` * `src/gen_tile.cpp` * Use `snprintf` instead of `sprintf` * To resolve `warning: 'sprintf' is deprecated` in [`macOS` builds](https://github.com/openstreetmap/mod_tile/actions/runs/7590268635/job/20677236621#step:5:579) * `src/gen_tile_test.cpp` * Use `snprintf` instead of `sprintf` * To resolve `warning: 'sprintf' is deprecated` in [`macOS` builds](https://github.com/openstreetmap/mod_tile/actions/runs/7590268635/job/20677236621#step:5:579) * `src/mod_tile.c` * Use `snprintf` instead of `sprintf` * To resolve `warning: 'sprintf' is deprecated` in [`macOS` builds](https://github.com/openstreetmap/mod_tile/actions/runs/7590268635/job/20677236621#step:5:579) * Cast `os_thread` to `(unsigned long)` in `ap_log_rerror` calls format * To resolve `warning: format specifies type 'long' but the argument has type 'apr_os_thread_t'` * `os_thread` is an alias of `unsigned long` * Use `"%" APR_OFF_T_FMT`/`APR_UINT64_T_FMT "..."` to resolve warnings under `macOS` * To resolve `warning: format specifies type 'long' but the argument has type 'off_t'` * The format/type for `apr_off_t` varies under `macOS` * See [here](https://github.com/apache/apr/blob/8e68a77f6110462ea8d2fd7f2003f7d09997a074/include/apr.h.in#L610-L645) * And resolve `warning: format specifies type 'long' but the argument has type 'apr_uint64_t'` * The format/type for `apr_uint64_t` varies under `macOS` * See [here](https://github.com/apache/apr/blob/8e68a77f6110462ea8d2fd7f2003f7d09997a074/include/apr.h.in#L610-L645) * Divide by `2.0` rather than `2` * To resolve `possible loss of precision` warning * Use `%li` rather than `"%" APR_TIME_T_FMT` as format for `maxAge` * It is defined as a `long int` * `src/render_submit_queue.c` * Include `string.h`/`strings.h` * To resolve `warning: call to undeclared library function 'bzero'` * To resolve `warning: call to undeclared library function 'strncpy'` * To resolve `warning: call to undeclared library function 'strdup'` * To resolve `warning: call to undeclared library function 'strerror'` * To resolve `warning: call to undeclared library function 'strchr'` * To resolve `warning: call to undeclared library function 'strlen'` * To resolve `warning: call to undeclared library function 'memset'` * Cast `performance_stats.stat[i].noRendered` to `(float)` * To resolve `possible loss of precision` warning * `src/renderd.c` * Use `snprintf` instead of `sprintf` * To resolve `warning: 'sprintf' is deprecated` in [`macOS` builds](https://github.com/openstreetmap/mod_tile/actions/runs/7590268635/job/20677236621#step:5:579) * Change `const char` to `char` for `ini_fileExtension`, `ini_mimeType`, `ini_outputFormat` * To resolve `warning: format specifies type 'char *' but the argument has type 'const char *'` * `src/request_queue.c` * Add `default case` to `switch` statements * To resolve: * `warning: enumeration values 'queueRender' and 'queueDuplicate' not handled in switch` * `warning: enumeration values 'cmdIgnore', 'cmdDone', and 'cmdNotDone' not handled in switch` * `src/store_file.c` * Cast `pthread_self()` to `(unsigned long)` * To resolve `warning: format specifies type 'unsigned long' but the argument has type 'pthread_t'` * No longer need `CFLAGS=-Wno-implicit-function-declaration`
1 parent 38fb906 commit d6309f6

15 files changed

Lines changed: 75 additions & 59 deletions

.github/workflows/build-and-test.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ jobs:
116116

117117
macOS:
118118
env:
119-
CFLAGS: -Wno-implicit-function-declaration
120119
LDFLAGS: -undefined dynamic_lookup
121120
LIBRARY_PATH: /usr/local/lib
122121
TEST_PARALLEL_LEVEL: 1

includes/config.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ifndef CONFIG_H
2+
#define CONFIG_H
13
/* Define to 1 if you have the functions. */
24
#cmakedefine HAVE_DAEMON @HAVE_DAEMON@
35
#cmakedefine HAVE_GETLOADAVG @HAVE_GETLOADAVG@
@@ -25,3 +27,4 @@
2527

2628
/* Version number of project */
2729
#cmakedefine VERSION "@VERSION@"
30+
#endif

includes/g_logger.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
* along with this program; If not, see http://www.gnu.org/licenses/.
1616
*/
1717

18-
#ifndef GLOGGER_H
19-
#define GLOGGER_H
18+
#ifndef G_LOGGER_H
19+
#define G_LOGGER_H
2020

2121
#include <glib.h>
2222

includes/mod_tile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
#ifndef MODTILE_H
1919
#define MODTILE_H
2020

21+
#include "protocol.h"
2122
#include "store.h"
23+
#include <apr_tables.h>
24+
#include <netinet/in.h>
2225

2326
/*Size of the delaypool hashtable*/
2427
#define DELAY_HASHTABLE_SIZE 100057

includes/parameterize_style.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#ifndef PARAMETERIZE_HPP
1919
#define PARAMETERIZE_HPP
2020

21+
#include <mapnik/map.hpp>
22+
2123
typedef void (*parameterize_function_ptr)(mapnik::Map &m, char * parameter);
2224

2325
parameterize_function_ptr init_parameterization_function(char * function_name);

includes/request_queue.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#define REQUEST_QUEUE_H
2020

2121
#include "gen_tile.h"
22+
#include "render_config.h"
23+
#include <pthread.h>
2224

2325
#ifdef __cplusplus
2426
extern "C" {

includes/store.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
extern "C" {
2323
#endif
2424

25+
#include "render_config.h"
2526
#include <stdlib.h>
2627
#include <sys/types.h>
27-
#include "render_config.h"
2828

2929
struct stat_info {
3030
off_t size; /* total size, in bytes */

src/cache_expire.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <unistd.h>
2020
#include <sys/socket.h>
2121
#include <netdb.h>
22+
#include <netinet/in.h>
2223
#include <stdlib.h>
2324
#include <stdio.h>
2425

src/gen_tile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static void parameterize_map_max_connections(Map &m, int num_threads)
214214
parameters params = l.datasource()->params();
215215

216216
if (params.find("max_size") == params.end()) {
217-
sprintf(tmp, "%i", num_threads + 2);
217+
snprintf(tmp, 20, "%i", num_threads + 2);
218218
params["max_size"] = std::string(tmp);
219219
}
220220

src/gen_tile_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ TEST_CASE("storage-backend", "Tile storage backend")
834834
}
835835

836836
tile_dir = (char *) malloc(sizeof(char) * (strlen(tmp) + 15));
837-
sprintf(tile_dir, "%s/mod_tile_test", tmp);
837+
snprintf(tile_dir, sizeof(char) * (strlen(tmp) + 15), "%s/mod_tile_test", tmp);
838838
mkdir(tile_dir, 0777);
839839

840840
SECTION("storage/initialise", "should return NULL") {

0 commit comments

Comments
 (0)