From d6309f63160e22da2707412eac7228cd83fbac30 Mon Sep 17 00:00:00 2001 From: Hummeltech <6109326+hummeltech@users.noreply.github.com> Date: Tue, 30 Jan 2024 09:42:38 -0700 Subject: [PATCH] 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` --- .github/workflows/build-and-test.yml | 1 - includes/config.h.in | 3 + includes/g_logger.h | 4 +- includes/mod_tile.h | 3 + includes/parameterize_style.hpp | 2 + includes/request_queue.h | 2 + includes/store.h | 2 +- src/cache_expire.c | 1 + src/gen_tile.cpp | 2 +- src/gen_tile_test.cpp | 2 +- src/mod_tile.c | 92 ++++++++++++++-------------- src/render_submit_queue.c | 4 +- src/renderd.c | 8 +-- src/request_queue.c | 6 ++ src/store_file.c | 2 +- 15 files changed, 75 insertions(+), 59 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index da98b00e..df6968c8 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -116,7 +116,6 @@ jobs: macOS: env: - CFLAGS: -Wno-implicit-function-declaration LDFLAGS: -undefined dynamic_lookup LIBRARY_PATH: /usr/local/lib TEST_PARALLEL_LEVEL: 1 diff --git a/includes/config.h.in b/includes/config.h.in index eee09f68..6e16c6ce 100644 --- a/includes/config.h.in +++ b/includes/config.h.in @@ -1,3 +1,5 @@ +#ifndef CONFIG_H +#define CONFIG_H /* Define to 1 if you have the functions. */ #cmakedefine HAVE_DAEMON @HAVE_DAEMON@ #cmakedefine HAVE_GETLOADAVG @HAVE_GETLOADAVG@ @@ -25,3 +27,4 @@ /* Version number of project */ #cmakedefine VERSION "@VERSION@" +#endif diff --git a/includes/g_logger.h b/includes/g_logger.h index 9f44a1a6..4e062bf4 100644 --- a/includes/g_logger.h +++ b/includes/g_logger.h @@ -15,8 +15,8 @@ * along with this program; If not, see http://www.gnu.org/licenses/. */ -#ifndef GLOGGER_H -#define GLOGGER_H +#ifndef G_LOGGER_H +#define G_LOGGER_H #include diff --git a/includes/mod_tile.h b/includes/mod_tile.h index 615f76d4..95f766e2 100644 --- a/includes/mod_tile.h +++ b/includes/mod_tile.h @@ -18,7 +18,10 @@ #ifndef MODTILE_H #define MODTILE_H +#include "protocol.h" #include "store.h" +#include +#include /*Size of the delaypool hashtable*/ #define DELAY_HASHTABLE_SIZE 100057 diff --git a/includes/parameterize_style.hpp b/includes/parameterize_style.hpp index b1d0245b..2938e53f 100644 --- a/includes/parameterize_style.hpp +++ b/includes/parameterize_style.hpp @@ -18,6 +18,8 @@ #ifndef PARAMETERIZE_HPP #define PARAMETERIZE_HPP +#include + typedef void (*parameterize_function_ptr)(mapnik::Map &m, char * parameter); parameterize_function_ptr init_parameterization_function(char * function_name); diff --git a/includes/request_queue.h b/includes/request_queue.h index ee7ba5ff..09e4da32 100644 --- a/includes/request_queue.h +++ b/includes/request_queue.h @@ -19,6 +19,8 @@ #define REQUEST_QUEUE_H #include "gen_tile.h" +#include "render_config.h" +#include #ifdef __cplusplus extern "C" { diff --git a/includes/store.h b/includes/store.h index 7d2d5d71..c74d53ae 100644 --- a/includes/store.h +++ b/includes/store.h @@ -22,9 +22,9 @@ extern "C" { #endif +#include "render_config.h" #include #include -#include "render_config.h" struct stat_info { off_t size; /* total size, in bytes */ diff --git a/src/cache_expire.c b/src/cache_expire.c index 4a63b8df..933c7b1a 100644 --- a/src/cache_expire.c +++ b/src/cache_expire.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include diff --git a/src/gen_tile.cpp b/src/gen_tile.cpp index 65029aa8..a82fa7fe 100644 --- a/src/gen_tile.cpp +++ b/src/gen_tile.cpp @@ -214,7 +214,7 @@ static void parameterize_map_max_connections(Map &m, int num_threads) parameters params = l.datasource()->params(); if (params.find("max_size") == params.end()) { - sprintf(tmp, "%i", num_threads + 2); + snprintf(tmp, 20, "%i", num_threads + 2); params["max_size"] = std::string(tmp); } diff --git a/src/gen_tile_test.cpp b/src/gen_tile_test.cpp index 7cda7457..442bf9bf 100644 --- a/src/gen_tile_test.cpp +++ b/src/gen_tile_test.cpp @@ -834,7 +834,7 @@ TEST_CASE("storage-backend", "Tile storage backend") } tile_dir = (char *) malloc(sizeof(char) * (strlen(tmp) + 15)); - sprintf(tile_dir, "%s/mod_tile_test", tmp); + snprintf(tile_dir, sizeof(char) * (strlen(tmp) + 15), "%s/mod_tile_test", tmp); mkdir(tile_dir, 0777); SECTION("storage/initialise", "should return NULL") { diff --git a/src/mod_tile.c b/src/mod_tile.c index 5287d7f6..4a8b1656 100644 --- a/src/mod_tile.c +++ b/src/mod_tile.c @@ -156,7 +156,7 @@ static int socket_init(request_rec *r) hints.ai_canonname = NULL; hints.ai_addr = NULL; hints.ai_next = NULL; - sprintf(portnum, "%i", scfg->renderd_socket_port); + snprintf(portnum, 16, "%i", scfg->renderd_socket_port); s = getaddrinfo(scfg->renderd_socket_name, portnum, &hints, &result); @@ -397,7 +397,7 @@ static struct storage_backend * get_storage_backend(request_rec *r, int tile_lay apr_os_thread_t os_thread = apr_os_thread_current(); ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "get_storage_backend: Retrieving storage back end for tile layer %i in pool %pp and thread %li", - tile_layer, lifecycle_pool, os_thread); + tile_layer, lifecycle_pool, (unsigned long) os_thread); /* In Apache 2.2, we are using the process memory pool, but with mpm_event and mpm_worker, each process has multiple threads. * As apache's memory pool operations are not thread-safe, we need to wrap everything into a mutex to protect against @@ -411,7 +411,7 @@ static struct storage_backend * get_storage_backend(request_rec *r, int tile_lay } if (stores == NULL) { - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "get_storage_backend: No storage backends for this lifecycle %pp, creating it in thread %li", lifecycle_pool, os_thread); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "get_storage_backend: No storage backends for this lifecycle %pp, creating it in thread %li", lifecycle_pool, (unsigned long) os_thread); stores = apr_pcalloc(lifecycle_pool, sizeof(struct storage_backends)); stores->stores = apr_pcalloc(lifecycle_pool, sizeof(struct storage_backend *) * scfg->configs->nelts); stores->noBackends = scfg->configs->nelts; @@ -420,7 +420,7 @@ static struct storage_backend * get_storage_backend(request_rec *r, int tile_lay ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "get_storage_backend: Failed horribly to set user_data!"); } } else { - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "get_storage_backend: Found backends (%pp) for this lifecycle %pp in thread %li", stores, lifecycle_pool, os_thread); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "get_storage_backend: Found backends (%pp) for this lifecycle %pp in thread %li", stores, lifecycle_pool, (unsigned long) os_thread); } #ifndef APACHE24 @@ -429,11 +429,11 @@ static struct storage_backend * get_storage_backend(request_rec *r, int tile_lay if (stores->stores[tile_layer] == NULL) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "get_storage_backend: No storage backend in current lifecycle %pp in thread %li for current tile layer %i", - lifecycle_pool, os_thread, tile_layer); + lifecycle_pool, (unsigned long) os_thread, tile_layer); stores->stores[tile_layer] = init_storage_backend(tile_config->store); } else { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "get_storage_backend: Storage backend found in current lifecycle %pp for current tile layer %i in thread %li", - lifecycle_pool, tile_layer, os_thread); + lifecycle_pool, tile_layer, (unsigned long) os_thread); } return stores->stores[tile_layer]; @@ -449,7 +449,7 @@ static enum tileState tile_state(request_rec *r, struct protocol *cmd) stat = rdata->store->tile_stat(rdata->store, cmd->xmlname, cmd->options, cmd->x, cmd->y, cmd->z); - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "tile_state: determined state of %s %i %i %i on store %pp: Tile size: %li, expired: %i created: %li", + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "tile_state: determined state of %s %i %i %i on store %pp: Tile size: %" APR_OFF_T_FMT ", expired: %i created: %li", cmd->xmlname, cmd->x, cmd->y, cmd->z, rdata->store, stat.size, stat.expired, stat.mtime); r->finfo.mtime = stat.mtime * 1000000; @@ -546,7 +546,7 @@ static void add_expiry(request_rec *r, struct protocol * cmd) /* Test if the tile we are serving is out of date, then set a low maxAge*/ if (state == tileOld) { - holdoff = (scfg->cache_duration_dirty / 2) * (rand() / (RAND_MAX + holdoff = (scfg->cache_duration_dirty / 2.0) * (rand() / (RAND_MAX + 1.0)); maxAge = scfg->cache_duration_dirty + holdoff; } else { @@ -589,8 +589,7 @@ static void add_expiry(request_rec *r, struct protocol * cmd) ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "Setting tiles maxAge to %ld\n", maxAge); apr_table_mergen(t, "Cache-Control", - apr_psprintf(r->pool, "max-age=%" APR_TIME_T_FMT, - maxAge)); + apr_psprintf(r->pool, "max-age=%li", maxAge)); timestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN); apr_rfc822_date(timestr, (apr_time_from_sec(maxAge) + r->request_time)); apr_table_setn(t, "Expires", timestr); @@ -1267,8 +1266,7 @@ static int tile_handler_json(request_rec *r) ap_set_content_type(r, "application/json"); ap_set_content_length(r, len); apr_table_mergen(t, "Cache-Control", - apr_psprintf(r->pool, "max-age=%" APR_TIME_T_FMT, - maxAge)); + apr_psprintf(r->pool, "max-age=%li", maxAge)); timestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN); apr_rfc822_date(timestr, (apr_time_from_sec(maxAge) + r->request_time)); apr_table_setn(t, "Expires", timestr); @@ -1314,35 +1312,35 @@ static int tile_handler_mod_stats(request_rec *r) return error_message(r, "Failed to acquire lock, can't display stats"); } - ap_rprintf(r, "NoResp200: %li\n", local_stats.noResp200); - ap_rprintf(r, "NoResp304: %li\n", local_stats.noResp304); - ap_rprintf(r, "NoResp404: %li\n", local_stats.noResp404); - ap_rprintf(r, "NoResp503: %li\n", local_stats.noResp503); - ap_rprintf(r, "NoResp5XX: %li\n", local_stats.noResp5XX); - ap_rprintf(r, "NoRespOther: %li\n", local_stats.noRespOther); - ap_rprintf(r, "NoFreshCache: %li\n", local_stats.noFreshCache); - ap_rprintf(r, "NoOldCache: %li\n", local_stats.noOldCache); - ap_rprintf(r, "NoVeryOldCache: %li\n", local_stats.noVeryOldCache); - ap_rprintf(r, "NoFreshRender: %li\n", local_stats.noFreshRender); - ap_rprintf(r, "NoOldRender: %li\n", local_stats.noOldRender); - ap_rprintf(r, "NoVeryOldRender: %li\n", local_stats.noVeryOldRender); + ap_rprintf(r, "NoResp200: %" APR_UINT64_T_FMT "\n", local_stats.noResp200); + ap_rprintf(r, "NoResp304: %" APR_UINT64_T_FMT "\n", local_stats.noResp304); + ap_rprintf(r, "NoResp404: %" APR_UINT64_T_FMT "\n", local_stats.noResp404); + ap_rprintf(r, "NoResp503: %" APR_UINT64_T_FMT "\n", local_stats.noResp503); + ap_rprintf(r, "NoResp5XX: %" APR_UINT64_T_FMT "\n", local_stats.noResp5XX); + ap_rprintf(r, "NoRespOther: %" APR_UINT64_T_FMT "\n", local_stats.noRespOther); + ap_rprintf(r, "NoFreshCache: %" APR_UINT64_T_FMT "\n", local_stats.noFreshCache); + ap_rprintf(r, "NoOldCache: %" APR_UINT64_T_FMT "\n", local_stats.noOldCache); + ap_rprintf(r, "NoVeryOldCache: %" APR_UINT64_T_FMT "\n", local_stats.noVeryOldCache); + ap_rprintf(r, "NoFreshRender: %" APR_UINT64_T_FMT "\n", local_stats.noFreshRender); + ap_rprintf(r, "NoOldRender: %" APR_UINT64_T_FMT "\n", local_stats.noOldRender); + ap_rprintf(r, "NoVeryOldRender: %" APR_UINT64_T_FMT "\n", local_stats.noVeryOldRender); for (i = 0; i <= global_max_zoom; i++) { - ap_rprintf(r, "NoRespZoom%02i: %li\n", i, local_stats.noRespZoom[i]); + ap_rprintf(r, "NoRespZoom%02i: %" APR_UINT64_T_FMT "\n", i, local_stats.noRespZoom[i]); } - ap_rprintf(r, "NoTileBufferReads: %li\n", local_stats.noTotalBufferRetrieval); - ap_rprintf(r, "DurationTileBufferReads: %li\n", local_stats.totalBufferRetrievalTime); + ap_rprintf(r, "NoTileBufferReads: %" APR_UINT64_T_FMT "\n", local_stats.noTotalBufferRetrieval); + ap_rprintf(r, "DurationTileBufferReads: %" APR_UINT64_T_FMT "\n", local_stats.totalBufferRetrievalTime); for (i = 0; i <= global_max_zoom; i++) { - ap_rprintf(r, "NoTileBufferReadZoom%02i: %li\n", i, local_stats.noZoomBufferRetrieval[i]); - ap_rprintf(r, "DurationTileBufferReadZoom%02i: %li\n", i, local_stats.zoomBufferRetrievalTime[i]); + ap_rprintf(r, "NoTileBufferReadZoom%02i: %" APR_UINT64_T_FMT "\n", i, local_stats.noZoomBufferRetrieval[i]); + ap_rprintf(r, "DurationTileBufferReadZoom%02i: %" APR_UINT64_T_FMT "\n", i, local_stats.zoomBufferRetrievalTime[i]); } for (i = 0; i < scfg->configs->nelts; ++i) { tile_config_rec *tile_config = &tile_configs[i]; - ap_rprintf(r, "NoRes200Layer%s: %li\n", tile_config->baseuri, local_stats.noResp200Layer[i]); - ap_rprintf(r, "NoRes404Layer%s: %li\n", tile_config->baseuri, local_stats.noResp404Layer[i]); + ap_rprintf(r, "NoRes200Layer%s: %" APR_UINT64_T_FMT "\n", tile_config->baseuri, local_stats.noResp200Layer[i]); + ap_rprintf(r, "NoRes404Layer%s: %" APR_UINT64_T_FMT "\n", tile_config->baseuri, local_stats.noResp404Layer[i]); } free(local_stats.noResp200Layer); @@ -1388,27 +1386,27 @@ static int tile_handler_metrics(request_rec *r) ap_rprintf(r, "# HELP modtile_http_responses_total Number of HTTP responses by response code\n"); ap_rprintf(r, "# TYPE modtile_http_responses_total counter\n"); - ap_rprintf(r, "modtile_http_responses_total{status=\"200\"} %li\n", local_stats.noResp200); - ap_rprintf(r, "modtile_http_responses_total{status=\"304\"} %li\n", local_stats.noResp304); - ap_rprintf(r, "modtile_http_responses_total{status=\"404\"} %li\n", local_stats.noResp404); - ap_rprintf(r, "modtile_http_responses_total{status=\"503\"} %li\n", local_stats.noResp503); - ap_rprintf(r, "modtile_http_responses_total{status=\"5XX\"} %li\n", local_stats.noResp5XX); - ap_rprintf(r, "modtile_http_responses_total{status=\"other\"} %li\n", local_stats.noRespOther); + ap_rprintf(r, "modtile_http_responses_total{status=\"200\"} %" APR_UINT64_T_FMT "\n", local_stats.noResp200); + ap_rprintf(r, "modtile_http_responses_total{status=\"304\"} %" APR_UINT64_T_FMT "\n", local_stats.noResp304); + ap_rprintf(r, "modtile_http_responses_total{status=\"404\"} %" APR_UINT64_T_FMT "\n", local_stats.noResp404); + ap_rprintf(r, "modtile_http_responses_total{status=\"503\"} %" APR_UINT64_T_FMT "\n", local_stats.noResp503); + ap_rprintf(r, "modtile_http_responses_total{status=\"5XX\"} %" APR_UINT64_T_FMT "\n", local_stats.noResp5XX); + ap_rprintf(r, "modtile_http_responses_total{status=\"other\"} %" APR_UINT64_T_FMT "\n", local_stats.noRespOther); ap_rprintf(r, "# HELP modtile_tiles_total Tiles served\n"); ap_rprintf(r, "# TYPE modtile_tiles_total counter\n"); - ap_rprintf(r, "modtile_tiles_total{age=\"fresh\",rendered=\"no\"} %li\n", local_stats.noFreshCache); - ap_rprintf(r, "modtile_tiles_total{age=\"old\",rendered=\"no\"} %li\n", local_stats.noOldCache); - ap_rprintf(r, "modtile_tiles_total{age=\"outdated\",rendered=\"no\"} %li\n", local_stats.noVeryOldCache); - ap_rprintf(r, "modtile_tiles_total{age=\"fresh\",rendered=\"yes\"} %li\n", local_stats.noFreshRender); - ap_rprintf(r, "modtile_tiles_total{age=\"old\",rendered=\"attempted\"} %li\n", local_stats.noOldRender); - ap_rprintf(r, "modtile_tiles_total{age=\"outdated\",rendered=\"attempted\"} %li\n", local_stats.noVeryOldRender); + ap_rprintf(r, "modtile_tiles_total{age=\"fresh\",rendered=\"no\"} %" APR_UINT64_T_FMT "\n", local_stats.noFreshCache); + ap_rprintf(r, "modtile_tiles_total{age=\"old\",rendered=\"no\"} %" APR_UINT64_T_FMT "\n", local_stats.noOldCache); + ap_rprintf(r, "modtile_tiles_total{age=\"outdated\",rendered=\"no\"} %" APR_UINT64_T_FMT "\n", local_stats.noVeryOldCache); + ap_rprintf(r, "modtile_tiles_total{age=\"fresh\",rendered=\"yes\"} %" APR_UINT64_T_FMT "\n", local_stats.noFreshRender); + ap_rprintf(r, "modtile_tiles_total{age=\"old\",rendered=\"attempted\"} %" APR_UINT64_T_FMT "\n", local_stats.noOldRender); + ap_rprintf(r, "modtile_tiles_total{age=\"outdated\",rendered=\"attempted\"} %" APR_UINT64_T_FMT "\n", local_stats.noVeryOldRender); ap_rprintf(r, "# HELP modtile_zoom_responses_total Tiles served by zoom level\n"); ap_rprintf(r, "# TYPE modtile_zoom_responses_total counter\n"); for (i = 0; i <= global_max_zoom; i++) { - ap_rprintf(r, "modtile_zoom_responses_total{zoom=\"%02i\"} %li\n", i, local_stats.noRespZoom[i]); + ap_rprintf(r, "modtile_zoom_responses_total{zoom=\"%02i\"} %" APR_UINT64_T_FMT "\n", i, local_stats.noRespZoom[i]); } @@ -1416,7 +1414,7 @@ static int tile_handler_metrics(request_rec *r) ap_rprintf(r, "# TYPE modtile_tile_reads_total counter\n"); for (i = 0; i <= global_max_zoom; i++) { - ap_rprintf(r, "modtile_tile_reads_total{zoom=\"%02i\"} %li\n", i, local_stats.noZoomBufferRetrieval[i]); + ap_rprintf(r, "modtile_tile_reads_total{zoom=\"%02i\"} %" APR_UINT64_T_FMT "\n", i, local_stats.noZoomBufferRetrieval[i]); } ap_rprintf(r, "# HELP modtile_tile_reads_seconds_total Tile buffer duration\n"); @@ -1431,8 +1429,8 @@ static int tile_handler_metrics(request_rec *r) for (i = 0; i < scfg->configs->nelts; ++i) { tile_config_rec *tile_config = &tile_configs[i]; - ap_rprintf(r, "modtile_layer_responses_total{layer=\"%s\",status=\"200\"} %li\n", tile_config->baseuri, local_stats.noResp200Layer[i]); - ap_rprintf(r, "modtile_layer_responses_total{layer=\"%s\",status=\"404\"} %li\n", tile_config->baseuri, local_stats.noResp404Layer[i]); + ap_rprintf(r, "modtile_layer_responses_total{layer=\"%s\",status=\"200\"} %" APR_UINT64_T_FMT "\n", tile_config->baseuri, local_stats.noResp200Layer[i]); + ap_rprintf(r, "modtile_layer_responses_total{layer=\"%s\",status=\"404\"} %" APR_UINT64_T_FMT "\n", tile_config->baseuri, local_stats.noResp404Layer[i]); } free(local_stats.noResp200Layer); diff --git a/src/render_submit_queue.c b/src/render_submit_queue.c index 51d6cba7..e428360d 100644 --- a/src/render_submit_queue.c +++ b/src/render_submit_queue.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -428,7 +430,7 @@ void print_statistics(void) } printf("Zoom %02i: min: %4.1f avg: %4.1f max: %4.1f over a total of %8.1fs in %i requests\n", - i, performance_stats.stat[i].time_min / 1000.0, (performance_stats.stat[i].time_total / performance_stats.stat[i].noRendered) / 1000.0, + i, performance_stats.stat[i].time_min / 1000.0, (performance_stats.stat[i].time_total / (float) performance_stats.stat[i].noRendered) / 1000.0, performance_stats.stat[i].time_max / 1000.0, performance_stats.stat[i].time_total / 1000.0, performance_stats.stat[i].noRendered); } diff --git a/src/renderd.c b/src/renderd.c index e7cb1585..96420af1 100644 --- a/src/renderd.c +++ b/src/renderd.c @@ -417,7 +417,7 @@ int client_socket_init(renderd_config * sConfig) hints.ai_canonname = NULL; hints.ai_addr = NULL; hints.ai_next = NULL; - sprintf(portnum, "%i", sConfig->ipport); + snprintf(portnum, 16, "%i", sConfig->ipport); s = getaddrinfo(sConfig->iphostname, portnum, &hints, &result); @@ -1031,9 +1031,9 @@ int main(int argc, char **argv) snprintf(buffer, sizeof(buffer), "%s:type", name); const char *ini_type = iniparser_getstring(ini, buffer, "png image/png png256"); - const char ini_fileExtension[INILINE_MAX] = "png"; - const char ini_mimeType[INILINE_MAX] = "image/png"; - const char ini_outputFormat[INILINE_MAX] = "png256"; + char ini_fileExtension[INILINE_MAX] = "png"; + char ini_mimeType[INILINE_MAX] = "image/png"; + char ini_outputFormat[INILINE_MAX] = "png256"; sscanf(ini_type, "%[^ ] %[^ ] %[^;#]", ini_fileExtension, ini_mimeType, ini_outputFormat); diff --git a/src/request_queue.c b/src/request_queue.c index ede30627..91a1358a 100644 --- a/src/request_queue.c +++ b/src/request_queue.c @@ -394,6 +394,9 @@ void request_queue_remove_request(struct request_queue * queue, struct item * re queue->stats.timeReqBulkRender += render_time; break; } + + default: + break; } queue->stats.noZoomRender[request->req.z]++; @@ -431,6 +434,9 @@ int request_queue_no_requests_queued(struct request_queue * queue, enum protoCmd case cmdRenderBulk: noReq = queue->reqBulkNum; break; + + default: + break; } pthread_mutex_unlock(&queue->qLock); diff --git a/src/store_file.c b/src/store_file.c index 42535c6e..b1409aa7 100644 --- a/src/store_file.c +++ b/src/store_file.c @@ -219,7 +219,7 @@ static int file_metatile_write(struct storage_backend * store, const char *xmlco g_logger(G_LOG_LEVEL_DEBUG, "Creating and writing a metatile to %s", meta_path); tmp = malloc(sizeof(char) * strlen(meta_path) + 24); - snprintf(tmp, strlen(meta_path) + 24, "%s.%lu", meta_path, pthread_self()); + snprintf(tmp, strlen(meta_path) + 24, "%s.%lu", meta_path, (unsigned long) pthread_self()); if (mkdirp(tmp)) { free(tmp);