Resolve various compiler warnings and errors (#279)

* Resolved warnings in `src/daemon.c`

I.E.:
```
src/daemon.c:835:16: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
   char *name = iniparser_getsecname(ini, section);
                ^~~~~~~~~~~~~~~~~~~~
src/daemon.c:860:20: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
    char *ini_uri = iniparser_getstring(ini, buffer, (char *)"");
                    ^~~~~~~~~~~~~~~~~~~
```

* Resolved warning in `src/mod_tile.c`

I.E.:
```
./src/mod_tile.c:327:53: warning: format '%d' expects argument of type 'int', but argument 9 has type 'long unsigned int' [-Wformat=]
      ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "request_tile: Failed to read response from rendering socket. Got %d bytes but expected %d. Errno %d (%s)",
                                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             ret, sizeof(struct protocol_v2), errno, strerror(errno));
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~
                  |
                  long unsigned int
```

* Resolved `cppcheck`-detected error

I.E.:
```
src/store_rados.c:355:3: error: Memory leak: store [memleak]
  return NULL;
  ^
```

* Fix `Does not check for buffer overflows (CWE-120)` in `src/daemon.c`

* Fix `Does not check for buffer overflows (CWE-120)` in `src/cache_expire.c`

* Resolved `cppcheck`-detected error

I.E.:
```
src/parameterize_style.cpp:43:3: error: Memory leak: data [memleak]
  return;        //No parameterization given
  ^

* url is `char *`, unlike buffer, size is not known
This commit is contained in:
Hummeltech
2022-05-29 11:29:21 -07:00
committed by GitHub
parent 42e4f0d283
commit 296f888752
6 changed files with 40 additions and 37 deletions

View File

@ -34,16 +34,16 @@ int daemon(int nochdir, int noclose);
#define MAX_SLAVES 5
typedef struct {
char *socketname;
char *iphostname;
const char *iphostname;
const char *mapnik_font_dir;
const char *mapnik_plugins_dir;
const char *pid_filename;
const char *socketname;
const char *stats_filename;
const char *tile_dir;
int ipport;
int num_threads;
char *tile_dir;
char *mapnik_plugins_dir;
char *mapnik_font_dir;
int mapnik_font_dir_recurse;
char * stats_filename;
const char * pid_filename;
int num_threads;
} renderd_config;
typedef struct {