From f0811e8f298d77e94029425c182425174fcba19f Mon Sep 17 00:00:00 2001 From: Hummeltech <6109326+hummeltech@users.noreply.github.com> Date: Sun, 1 Jun 2025 08:20:43 -0700 Subject: [PATCH] Astyle/flawfinder updates (#487) * Apply astyle updates from newer version of astyle * Update `github/codeql-action/upload-sarif` --- .github/workflows/flawfinder-analysis.yml | 2 +- includes/cache_expire.h | 1 + includes/g_logger.h | 1 + includes/gen_tile.h | 1 + includes/protocol.h | 1 + includes/protocol_helper.h | 1 + includes/render_submit_queue.h | 1 + includes/renderd.h | 1 + includes/renderd_config.h | 1 + includes/request_queue.h | 1 + includes/store.h | 1 + includes/store_file.h | 1 + includes/store_file_utils.h | 1 + includes/store_memcached.h | 1 + includes/store_null.h | 1 + includes/store_rados.h | 1 + includes/store_ro_composite.h | 1 + includes/store_ro_http_proxy.h | 1 + includes/sys_utils.h | 1 + src/convert_meta.c | 2 ++ src/daemon_compat.c | 1 + src/gen_tile.cpp | 4 +++- src/metatile.cpp | 2 -- src/render_expired.c | 2 ++ src/render_list.c | 2 ++ src/render_old.c | 2 ++ src/render_speedtest.cpp | 3 +++ src/renderd.c | 1 + src/store_file_utils.c | 2 ++ src/store_memcached.c | 1 + tests/catch_test_common.cpp | 2 +- tests/catch_test_common.hpp | 2 +- tests/gen_tile_test.cpp | 9 +++++++-- 33 files changed, 47 insertions(+), 8 deletions(-) diff --git a/.github/workflows/flawfinder-analysis.yml b/.github/workflows/flawfinder-analysis.yml index 87c794b..2745610 100644 --- a/.github/workflows/flawfinder-analysis.yml +++ b/.github/workflows/flawfinder-analysis.yml @@ -29,6 +29,6 @@ jobs: output: "flawfinder_results.sarif" - name: Upload analysis results to GitHub Security tab - uses: github/codeql-action/upload-sarif@v2 + uses: github/codeql-action/upload-sarif@v3 with: sarif_file: ${{github.workspace}}/flawfinder_results.sarif diff --git a/includes/cache_expire.h b/includes/cache_expire.h index 4e1b5fc..3be644a 100644 --- a/includes/cache_expire.h +++ b/includes/cache_expire.h @@ -30,6 +30,7 @@ int init_cache_expire(const char *htcphost); #ifdef __cplusplus } + #endif #endif diff --git a/includes/g_logger.h b/includes/g_logger.h index 12aa7c6..a2c85b7 100644 --- a/includes/g_logger.h +++ b/includes/g_logger.h @@ -32,6 +32,7 @@ const char *g_logger_level_name(int log_level); #ifdef __cplusplus } + #endif #endif diff --git a/includes/gen_tile.h b/includes/gen_tile.h index e617bf8..c7f8175 100644 --- a/includes/gen_tile.h +++ b/includes/gen_tile.h @@ -52,6 +52,7 @@ void render_init(const char *plugins_dir, const char *font_dir, int font_recurse #ifdef __cplusplus } + #endif #endif diff --git a/includes/protocol.h b/includes/protocol.h index cb61fd9..6dbbafd 100644 --- a/includes/protocol.h +++ b/includes/protocol.h @@ -87,5 +87,6 @@ struct protocol_v2 { #ifdef __cplusplus } + #endif #endif diff --git a/includes/protocol_helper.h b/includes/protocol_helper.h index 2045730..5288baf 100644 --- a/includes/protocol_helper.h +++ b/includes/protocol_helper.h @@ -29,5 +29,6 @@ int recv_cmd(struct protocol *cmd, int fd, int block); #ifdef __cplusplus } + #endif #endif diff --git a/includes/render_submit_queue.h b/includes/render_submit_queue.h index 629c1a2..71ba24b 100644 --- a/includes/render_submit_queue.h +++ b/includes/render_submit_queue.h @@ -29,6 +29,7 @@ void print_statistics(void); #ifdef __cplusplus } + #endif #endif diff --git a/includes/renderd.h b/includes/renderd.h index 02551a9..d14e692 100644 --- a/includes/renderd.h +++ b/includes/renderd.h @@ -80,5 +80,6 @@ enum protoCmd rx_request(struct protocol *req, int fd); #ifdef __cplusplus } + #endif #endif diff --git a/includes/renderd_config.h b/includes/renderd_config.h index f1672cd..3f8af71 100644 --- a/includes/renderd_config.h +++ b/includes/renderd_config.h @@ -43,5 +43,6 @@ void process_renderd_sections(const char *config_file_name, renderd_config *conf #ifdef __cplusplus } + #endif #endif diff --git a/includes/request_queue.h b/includes/request_queue.h index d412e24..ea59d4c 100644 --- a/includes/request_queue.h +++ b/includes/request_queue.h @@ -73,5 +73,6 @@ void request_queue_copy_stats(struct request_queue *queue, stats_struct *stats); #ifdef __cplusplus } + #endif #endif diff --git a/includes/store.h b/includes/store.h index 3d2f65b..f4f5cf6 100644 --- a/includes/store.h +++ b/includes/store.h @@ -50,5 +50,6 @@ struct storage_backend *init_storage_backend(const char *options); #ifdef __cplusplus } + #endif #endif diff --git a/includes/store_file.h b/includes/store_file.h index a0f8f45..bc49d1e 100644 --- a/includes/store_file.h +++ b/includes/store_file.h @@ -28,5 +28,6 @@ struct storage_backend *init_storage_file(const char *tile_dir); #ifdef __cplusplus } + #endif #endif diff --git a/includes/store_file_utils.h b/includes/store_file_utils.h index 4bcafbb..be7f9a3 100644 --- a/includes/store_file_utils.h +++ b/includes/store_file_utils.h @@ -49,6 +49,7 @@ void xyz_to_path(char *path, size_t len, const char *tile_dir, const char *xmlco #ifdef __cplusplus } + #endif #endif diff --git a/includes/store_memcached.h b/includes/store_memcached.h index cf28cc2..5fd5b50 100644 --- a/includes/store_memcached.h +++ b/includes/store_memcached.h @@ -28,5 +28,6 @@ struct storage_backend *init_storage_memcached(const char *connection_string); #ifdef __cplusplus } + #endif #endif diff --git a/includes/store_null.h b/includes/store_null.h index 4d663df..5e7ac18 100644 --- a/includes/store_null.h +++ b/includes/store_null.h @@ -26,6 +26,7 @@ struct storage_backend *init_storage_null(); #ifdef __cplusplus } + #endif #endif /* STORE_NULL_H */ diff --git a/includes/store_rados.h b/includes/store_rados.h index ed563ce..5d7cae8 100644 --- a/includes/store_rados.h +++ b/includes/store_rados.h @@ -28,5 +28,6 @@ struct storage_backend *init_storage_rados(const char *connection_string); #ifdef __cplusplus } + #endif #endif diff --git a/includes/store_ro_composite.h b/includes/store_ro_composite.h index dfe92c4..da6a201 100644 --- a/includes/store_ro_composite.h +++ b/includes/store_ro_composite.h @@ -28,5 +28,6 @@ struct storage_backend *init_storage_ro_composite(const char *connection_string) #ifdef __cplusplus } + #endif #endif diff --git a/includes/store_ro_http_proxy.h b/includes/store_ro_http_proxy.h index 9033143..7381d1d 100644 --- a/includes/store_ro_http_proxy.h +++ b/includes/store_ro_http_proxy.h @@ -28,5 +28,6 @@ struct storage_backend *init_storage_ro_http_proxy(const char *connection_string #ifdef __cplusplus } + #endif #endif diff --git a/includes/sys_utils.h b/includes/sys_utils.h index 3fefc57..bf2a5b5 100644 --- a/includes/sys_utils.h +++ b/includes/sys_utils.h @@ -26,6 +26,7 @@ double get_load_avg(void); #ifdef __cplusplus } + #endif #endif diff --git a/src/convert_meta.c b/src/convert_meta.c index ca6fcf3..ef2c1d0 100644 --- a/src/convert_meta.c +++ b/src/convert_meta.c @@ -49,6 +49,7 @@ int main(int argc, char **argv) fprintf(stderr, "convert_meta not implemented for non-metatile mode. Feel free to submit fix!\n"); return -1; } + #else static int minZoom = 0; @@ -226,4 +227,5 @@ int main(int argc, char **argv) return 0; } + #endif diff --git a/src/daemon_compat.c b/src/daemon_compat.c index e6d8ebc..17ca0ce 100644 --- a/src/daemon_compat.c +++ b/src/daemon_compat.c @@ -101,4 +101,5 @@ int nochdir, noclose; return (0); } + #endif diff --git a/src/gen_tile.cpp b/src/gen_tile.cpp index dda5498..c154039 100644 --- a/src/gen_tile.cpp +++ b/src/gen_tile.cpp @@ -283,7 +283,7 @@ static enum protoCmd render(struct xmlmapconfig *map, int x, int y, int z, char for (yy = 0; yy < render_size_ty; yy++) { for (xx = 0; xx < render_size_tx; xx++) { - mapnik::image_view> vw1(xx * map->tilesize, yy * map->tilesize, map->tilesize, map->tilesize, buf); + mapnik::image_view> vw1(xx * map->tilesize, yy * map->tilesize, map->tilesize, map->tilesize, buf); struct mapnik::image_view_any vw(vw1); tiles.set(xx, yy, save_to_string(vw, map->output_format)); } @@ -291,6 +291,7 @@ static enum protoCmd render(struct xmlmapconfig *map, int x, int y, int z, char return cmdDone; // OK } + #else // METATILE static enum protoCmd render(Map &m, const char *tile_dir, char *xmlname, projection &prj, int x, int y, int z, char *outputFormat) { @@ -335,6 +336,7 @@ static enum protoCmd render(Map &m, const char *tile_dir, char *xmlname, project return cmdDone; // OK } + #endif // METATILE void render_init(const char *plugins_dir, const char *font_dir, int font_dir_recurse) diff --git a/src/metatile.cpp b/src/metatile.cpp index 4560da4..d8a8acc 100644 --- a/src/metatile.cpp +++ b/src/metatile.cpp @@ -79,8 +79,6 @@ void metaTile::save(struct storage_backend * store) m.z = z_; offset = header_size; - limit = (1 << z_); - limit = MIN(limit, METATILE); limit = METATILE; // Generate offset table diff --git a/src/render_expired.c b/src/render_expired.c index 9bd13ca..a790c81 100644 --- a/src/render_expired.c +++ b/src/render_expired.c @@ -50,6 +50,7 @@ int main(int argc, char **argv) fprintf(stderr, "render_expired not implemented for non-metatile mode. Feel free to submit fix!\n"); return -1; } + #else // tile marking arrays @@ -522,4 +523,5 @@ int main(int argc, char **argv) return 0; } + #endif diff --git a/src/render_list.c b/src/render_list.c index 1540c3a..b554486 100644 --- a/src/render_list.c +++ b/src/render_list.c @@ -41,6 +41,7 @@ int main(int argc, char **argv) fprintf(stderr, "render_list not implemented for non-metatile mode. Feel free to submit fix!\n"); return -1; } + #else int lon2tilex(double lon, int z) @@ -572,4 +573,5 @@ int main(int argc, char **argv) return 0; } + #endif diff --git a/src/render_old.c b/src/render_old.c index 2c5ff08..5c02756 100644 --- a/src/render_old.c +++ b/src/render_old.c @@ -43,6 +43,7 @@ int main(int argc, char **argv) fprintf(stderr, "render_old not implemented for non-metatile mode. Feel free to submit fix!\n"); return -1; } + #else static int num_render = 0, num_all = 0; @@ -433,4 +434,5 @@ int main(int argc, char **argv) return 0; } + #endif diff --git a/src/render_speedtest.cpp b/src/render_speedtest.cpp index f198c33..a4511e2 100644 --- a/src/render_speedtest.cpp +++ b/src/render_speedtest.cpp @@ -41,6 +41,7 @@ int main(int argc, char **argv) fprintf(stderr, "Speed test not implemented for non-metatile mode. Feel free to submit fix!\n"); return -1; } + #else #if 1 @@ -101,6 +102,7 @@ public: x = round(d + x * Bc[zoom]); y = round(d + 0.5 * log((1 + f) / (1 - f)) * -Cc[zoom]); } + void fromPixelToLL(double &x, double &y, int zoom) { double e = zc[zoom]; @@ -349,4 +351,5 @@ int main(int argc, char **argv) return 0; } + #endif diff --git a/src/renderd.c b/src/renderd.c index 8fa98f4..34ce08a 100644 --- a/src/renderd.c +++ b/src/renderd.c @@ -914,4 +914,5 @@ int main(int argc, char **argv) close(fd); return 0; } + #endif diff --git a/src/store_file_utils.c b/src/store_file_utils.c index 6882b8b..84ab21a 100644 --- a/src/store_file_utils.c +++ b/src/store_file_utils.c @@ -214,6 +214,7 @@ int xyz_to_meta(char *path, size_t len, const char *tile_dir, const char *xmlcon { return xyzo_to_meta(path, len, tile_dir, xmlconfig, "", x, y, z); } + #else // METATILE void xyz_to_path(char *path, size_t len, const char *tile_dir, const char *xmlconfig, int x, int y, int z) { @@ -235,4 +236,5 @@ void xyz_to_path(char *path, size_t len, const char *tile_dir, const char *xmlco #endif // DIRECTORY_HASH return; } + #endif // METATILE diff --git a/src/store_memcached.c b/src/store_memcached.c index 2353e08..dd29671 100644 --- a/src/store_memcached.c +++ b/src/store_memcached.c @@ -266,6 +266,7 @@ static int memcached_close_storage(struct storage_backend * store) memcached_free(store->storage_ctx); return 0; } + #endif //Have memcached struct storage_backend * init_storage_memcached(const char * connection_string) diff --git a/tests/catch_test_common.cpp b/tests/catch_test_common.cpp index f26ff1a..179f7ee 100644 --- a/tests/catch_test_common.cpp +++ b/tests/catch_test_common.cpp @@ -32,7 +32,7 @@ std::string err_log_lines, out_log_lines; captured_stdio captured_stderr; captured_stdio captured_stdout; -int run_command(std::string file, std::vector argv, std::string input) +int run_command(const std::string &file, std::vector argv, const std::string &input) { auto mode = redi::pstreams::pstdout | redi::pstreams::pstderr | redi::pstreams::pstdin; diff --git a/tests/catch_test_common.hpp b/tests/catch_test_common.hpp index 948b1c2..1678190 100644 --- a/tests/catch_test_common.hpp +++ b/tests/catch_test_common.hpp @@ -38,6 +38,6 @@ std::string get_captured_stdout(bool print = false); void start_capture(bool debug = false); std::tuple end_capture(bool print = false); -int run_command(std::string file, std::vector argv = {}, std::string input = ""); +int run_command(const std::string &file, std::vector argv = {}, const std::string &input = ""); #endif diff --git a/tests/gen_tile_test.cpp b/tests/gen_tile_test.cpp index e9529ce..eb4291a 100644 --- a/tests/gen_tile_test.cpp +++ b/tests/gen_tile_test.cpp @@ -115,7 +115,7 @@ void *fetch_thread(void *arg) return NULL; } -std::string create_tile_dir(std::string dir_name = "mod_tile_test", const char *tmp_dir = getenv("TMPDIR")) +std::string create_tile_dir(const std::string &dir_name = "mod_tile_test", const char *tmp_dir = getenv("TMPDIR")) { if (tmp_dir == NULL) { tmp_dir = P_tmpdir; @@ -129,7 +129,7 @@ std::string create_tile_dir(std::string dir_name = "mod_tile_test", const char * return tile_dir; } -int delete_tile_dir(std::string tile_dir) +int delete_tile_dir(const std::string &tile_dir) { return rmdir(tile_dir.c_str()); } @@ -1014,6 +1014,7 @@ TEST_CASE("memcached storage-backend", "MemcacheD Tile storage backend") found = out_log_lines.find("init_storage_memcached: Creating memcached ctx with options"); REQUIRE(found > -1); } + #else SECTION("memcached storage/initialise", "should return NULL") { start_capture(); @@ -1023,6 +1024,7 @@ TEST_CASE("memcached storage-backend", "MemcacheD Tile storage backend") found = err_log_lines.find("init_storage_memcached: Support for memcached has not been compiled into this program"); REQUIRE(found > -1); } + #endif } @@ -1221,6 +1223,7 @@ TEST_CASE("ro_composite storage-backend", "RO Composite Tile storage backend") found = err_log_lines.find("init_storage_ro_coposite: Support for compositing storage has not been compiled into this program"); REQUIRE(found > -1); } + #endif } @@ -1239,6 +1242,7 @@ TEST_CASE("ro_http_proxy storage-backend", "RO HTTP Proxy Tile storage backend") store->close_storage(store); } + #else SECTION("storage/initialise", "should return NULL") { start_capture(); @@ -1248,6 +1252,7 @@ TEST_CASE("ro_http_proxy storage-backend", "RO HTTP Proxy Tile storage backend") found = err_log_lines.find("init_storage_ro_http_proxy: Support for curl and therefore the http proxy storage has not been compiled into this program"); REQUIRE(found > -1); } + #endif }