1
0
forked from bip/bip

sanitize: pragmas for our code

This commit is contained in:
Loïc Gomez 2022-01-09 21:30:25 +01:00 committed by Pierre-Louis Bonicoli
parent efb79b1e80
commit edf78eadb1
Signed by untrusted user: pilou
GPG Key ID: 06914C4A5EDAA6DD
5 changed files with 18 additions and 0 deletions

View File

@ -82,7 +82,12 @@ static void hash_binary(char *hex, unsigned char **password, unsigned int *seed)
md5 = bip_malloc((size_t) 20); md5 = bip_malloc((size_t) 20);
for (i = 0; i < 20; i++) { for (i = 0; i < 20; i++) {
sscanf(hex + 2 * i, "%02x", &buf); sscanf(hex + 2 * i, "%02x", &buf);
// conversion from unsigned int to unsigned char may change value
// we're parsing a text (hex) so buf won't ever be something else than a char
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
md5[i] = buf; md5[i] = buf;
#pragma GCC diagnostic pop
} }
*seed = 0; *seed = 0;

View File

@ -24,6 +24,9 @@
#include "md5.h" #include "md5.h"
#include "utils/base64.h" #include "utils/base64.h"
// TODO resolve assuming signed overflow does not occur when changing X +- C1 cmp C2 to X cmp C2 -+ C1
#pragma GCC diagnostic ignored "-Wstrict-overflow"
#define S_CONN_DELAY (10) #define S_CONN_DELAY (10)
extern int sighup; extern int sighup;

View File

@ -16,6 +16,9 @@
#include "line.h" #include "line.h"
#include "util.h" #include "util.h"
// TODO resolve assuming signed overflow does not occur when changing X +- C1 cmp C2 to X cmp C2 -+ C1
#pragma GCC diagnostic ignored "-Wstrict-overflow"
void irc_line_init(struct line *l) void irc_line_init(struct line *l)
{ {
memset(l, 0, sizeof(struct line)); memset(l, 0, sizeof(struct line));

View File

@ -360,7 +360,11 @@ unsigned char *chash_double(char *str, unsigned int seed)
length = strlen(str); length = strlen(str);
length += 4; length += 4;
ptr = bip_malloc(length); ptr = bip_malloc(length);
// conversion from unsigned int to unsigned char may change value [-Werror=conversion]
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
ptr[0] = seed >> 24 & 0xff; ptr[0] = seed >> 24 & 0xff;
#pragma GCC diagnostic pop
ptr[1] = seed >> 16 & 0xff; ptr[1] = seed >> 16 & 0xff;
ptr[2] = seed >> 8 & 0xff; ptr[2] = seed >> 8 & 0xff;
ptr[3] = seed & 0xff; ptr[3] = seed & 0xff;

View File

@ -43,11 +43,14 @@ struct list_item {
void *ptr; void *ptr;
}; };
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
typedef struct list { typedef struct list {
struct list_item *first; struct list_item *first;
struct list_item *last; struct list_item *last;
int (*cmp)(); int (*cmp)();
} list_t; } list_t;
#pragma GCC diagnostic pop
typedef struct list_iterator { typedef struct list_iterator {
list_t *list; list_t *list;