aboutsummaryrefslogtreecommitdiff
path: root/src/my
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-06-12 14:57:51 +0200
committerChristian Grothoff <christian@grothoff.org>2018-06-12 14:57:51 +0200
commit3e5842e44aac604c505edd60a4f3dd8a360ff45b (patch)
tree14edc9f7f22aff29ef0b970e1e2bd9aecc570367 /src/my
parentf6a87ee66310529edf76c0fab76cdc7cd2aac216 (diff)
downloadgnunet-3e5842e44aac604c505edd60a4f3dd8a360ff45b.tar.gz
gnunet-3e5842e44aac604c505edd60a4f3dd8a360ff45b.zip
tell mysql that our integers are unsigned
Diffstat (limited to 'src/my')
-rw-r--r--src/my/my.c26
-rw-r--r--src/my/my_query_helper.c22
2 files changed, 24 insertions, 24 deletions
diff --git a/src/my/my.c b/src/my/my.c
index b9d5c8424..2f4cd3ba3 100644
--- a/src/my/my.c
+++ b/src/my/my.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet 2 This file is part of GNUnet
3 Copyright (C) 2016 Inria & GNUnet e.V. 3 Copyright (C) 2016, 2018 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -43,19 +43,20 @@ GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc,
43{ 43{
44 const struct GNUNET_MY_QueryParam *p; 44 const struct GNUNET_MY_QueryParam *p;
45 unsigned int num; 45 unsigned int num;
46 unsigned int i;
47 MYSQL_STMT *stmt; 46 MYSQL_STMT *stmt;
48 47
49 num = 0; 48 num = 0;
50 for (i=0;NULL != params[i].conv;i++) 49 for (unsigned int i=0;NULL != params[i].conv;i++)
51 num += params[i].num_params; 50 num += params[i].num_params;
52 { 51 {
53 MYSQL_BIND qbind[num]; 52 MYSQL_BIND qbind[num];
54 unsigned int off; 53 unsigned int off;
55 54
56 memset (qbind, 0, sizeof(qbind)); 55 memset (qbind,
56 0,
57 sizeof(qbind));
57 off = 0; 58 off = 0;
58 for (i=0;NULL != (p = &params[i])->conv;i++) 59 for (unsigned int i=0;NULL != (p = &params[i])->conv;i++)
59 { 60 {
60 if (GNUNET_OK != 61 if (GNUNET_OK !=
61 p->conv (p->conv_cls, 62 p->conv (p->conv_cls,
@@ -111,9 +112,7 @@ void
111GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp, 112GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp,
112 MYSQL_BIND *qbind) 113 MYSQL_BIND *qbind)
113{ 114{
114 unsigned int i; 115 for (unsigned int i=0; NULL != qp[i].conv ;i++)
115
116 for (i=0; NULL != qp[i].conv ;i++)
117 if (NULL != qp[i].cleaner) 116 if (NULL != qp[i].cleaner)
118 qp[i].cleaner (qp[i].conv_cls, 117 qp[i].cleaner (qp[i].conv_cls,
119 &qbind[i]); 118 &qbind[i]);
@@ -136,7 +135,6 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh,
136 struct GNUNET_MY_ResultSpec *rs) 135 struct GNUNET_MY_ResultSpec *rs)
137{ 136{
138 unsigned int num_fields; 137 unsigned int num_fields;
139 unsigned int i;
140 int ret; 138 int ret;
141 MYSQL_STMT *stmt; 139 MYSQL_STMT *stmt;
142 140
@@ -153,7 +151,7 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh,
153 } 151 }
154 152
155 num_fields = 0; 153 num_fields = 0;
156 for (i=0;NULL != rs[i].pre_conv;i++) 154 for (unsigned int i=0;NULL != rs[i].pre_conv;i++)
157 num_fields += rs[i].num_fields; 155 num_fields += rs[i].num_fields;
158 156
159 if (mysql_stmt_field_count (stmt) != num_fields) 157 if (mysql_stmt_field_count (stmt) != num_fields)
@@ -169,7 +167,7 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh,
169 167
170 memset (result, 0, sizeof (MYSQL_BIND) * num_fields); 168 memset (result, 0, sizeof (MYSQL_BIND) * num_fields);
171 field_off = 0; 169 field_off = 0;
172 for (i=0;NULL != rs[i].pre_conv;i++) 170 for (unsigned int i=0;NULL != rs[i].pre_conv;i++)
173 { 171 {
174 struct GNUNET_MY_ResultSpec *rp = &rs[i]; 172 struct GNUNET_MY_ResultSpec *rp = &rs[i];
175 173
@@ -221,7 +219,7 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh,
221 return GNUNET_SYSERR; 219 return GNUNET_SYSERR;
222 } 220 }
223 field_off = 0; 221 field_off = 0;
224 for (i=0;NULL != rs[i].post_conv;i++) 222 for (unsigned int i=0;NULL != rs[i].post_conv;i++)
225 { 223 {
226 struct GNUNET_MY_ResultSpec *rp = &rs[i]; 224 struct GNUNET_MY_ResultSpec *rp = &rs[i];
227 225
@@ -256,9 +254,7 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh,
256void 254void
257GNUNET_MY_cleanup_result (struct GNUNET_MY_ResultSpec *rs) 255GNUNET_MY_cleanup_result (struct GNUNET_MY_ResultSpec *rs)
258{ 256{
259 unsigned int i; 257 for (unsigned int i=0;NULL != rs[i].post_conv;i++)
260
261 for (i=0;NULL != rs[i].post_conv;i++)
262 if (NULL != rs[i].cleaner) 258 if (NULL != rs[i].cleaner)
263 rs[i].cleaner (rs[i].conv_cls, 259 rs[i].cleaner (rs[i].conv_cls,
264 &rs[i]); 260 &rs[i]);
diff --git a/src/my/my_query_helper.c b/src/my/my_query_helper.c
index c4516715a..b2a893a44 100644
--- a/src/my/my_query_helper.c
+++ b/src/my/my_query_helper.c
@@ -37,6 +37,7 @@ static void
37my_clean_query (void *cls, 37my_clean_query (void *cls,
38 MYSQL_BIND *qbind) 38 MYSQL_BIND *qbind)
39{ 39{
40 (void) cls;
40 GNUNET_free (qbind[0].buffer); 41 GNUNET_free (qbind[0].buffer);
41} 42}
42 43
@@ -54,6 +55,7 @@ my_conv_fixed_size (void *cls,
54 const struct GNUNET_MY_QueryParam *qp, 55 const struct GNUNET_MY_QueryParam *qp,
55 MYSQL_BIND *qbind) 56 MYSQL_BIND *qbind)
56{ 57{
58 (void) cls;
57 GNUNET_assert (1 == qp->num_params); 59 GNUNET_assert (1 == qp->num_params);
58 qbind->buffer = (void *) qp->data; 60 qbind->buffer = (void *) qp->data;
59 qbind->buffer_length = qp->data_len; 61 qbind->buffer_length = qp->data_len;
@@ -99,12 +101,11 @@ my_conv_string (void *cls,
99 const struct GNUNET_MY_QueryParam *qp, 101 const struct GNUNET_MY_QueryParam *qp,
100 MYSQL_BIND *qbind) 102 MYSQL_BIND *qbind)
101{ 103{
104 (void) cls;
102 GNUNET_assert (1 == qp->num_params); 105 GNUNET_assert (1 == qp->num_params);
103
104 qbind->buffer = (void *) qp->data; 106 qbind->buffer = (void *) qp->data;
105 qbind->buffer_length = qp->data_len; 107 qbind->buffer_length = qp->data_len;
106 qbind->buffer_type = MYSQL_TYPE_STRING; 108 qbind->buffer_type = MYSQL_TYPE_STRING;
107
108 return 1; 109 return 1;
109} 110}
110 111
@@ -142,10 +143,12 @@ my_conv_uint16 (void *cls,
142 const struct GNUNET_MY_QueryParam *qp, 143 const struct GNUNET_MY_QueryParam *qp,
143 MYSQL_BIND *qbind) 144 MYSQL_BIND *qbind)
144{ 145{
146 (void) cls;
145 GNUNET_assert (1 == qp->num_params); 147 GNUNET_assert (1 == qp->num_params);
146 qbind->buffer = (void *) qp->data; 148 qbind->buffer = (void *) qp->data;
147 qbind->buffer_length = sizeof (uint16_t); 149 qbind->buffer_length = sizeof (uint16_t);
148 qbind->buffer_type = MYSQL_TYPE_SHORT; 150 qbind->buffer_type = MYSQL_TYPE_SHORT;
151 qbind->is_unsigned = 1;
149 return 1; 152 return 1;
150} 153}
151 154
@@ -184,11 +187,12 @@ my_conv_uint32 (void *cls,
184 const struct GNUNET_MY_QueryParam *qp, 187 const struct GNUNET_MY_QueryParam *qp,
185 MYSQL_BIND *qbind) 188 MYSQL_BIND *qbind)
186{ 189{
190 (void) cls;
187 GNUNET_assert (1 == qp->num_params); 191 GNUNET_assert (1 == qp->num_params);
188 qbind->buffer = (void *) qp->data; 192 qbind->buffer = (void *) qp->data;
189 qbind->buffer_length = sizeof(uint32_t); 193 qbind->buffer_length = sizeof(uint32_t);
190 qbind->buffer_type = MYSQL_TYPE_LONG; 194 qbind->buffer_type = MYSQL_TYPE_LONG;
191 195 qbind->is_unsigned = 1;
192 return 1; 196 return 1;
193} 197}
194 198
@@ -227,10 +231,12 @@ my_conv_uint64 (void *cls,
227 const struct GNUNET_MY_QueryParam *qp, 231 const struct GNUNET_MY_QueryParam *qp,
228 MYSQL_BIND * qbind) 232 MYSQL_BIND * qbind)
229{ 233{
234 (void) cls;
230 GNUNET_assert (1 == qp->num_params); 235 GNUNET_assert (1 == qp->num_params);
231 qbind->buffer = (void *) qp->data; 236 qbind->buffer = (void *) qp->data;
232 qbind->buffer_length = sizeof (uint64_t); 237 qbind->buffer_length = sizeof (uint64_t);
233 qbind->buffer_type = MYSQL_TYPE_LONGLONG; 238 qbind->buffer_type = MYSQL_TYPE_LONGLONG;
239 qbind->is_unsigned = 1;
234 return 1; 240 return 1;
235} 241}
236 242
@@ -273,14 +279,13 @@ my_conv_rsa_public_key (void *cls,
273 char *buf; 279 char *buf;
274 size_t buf_size; 280 size_t buf_size;
275 281
282 (void) cls;
276 GNUNET_assert(1 == qp->num_params); 283 GNUNET_assert(1 == qp->num_params);
277 284 buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rsa,
278 buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rsa, &buf); 285 &buf);
279
280 qbind->buffer = (void *) buf; 286 qbind->buffer = (void *) buf;
281 qbind->buffer_length = buf_size; 287 qbind->buffer_length = buf_size;
282 qbind->buffer_type = MYSQL_TYPE_BLOB; 288 qbind->buffer_type = MYSQL_TYPE_BLOB;
283
284 return 1; 289 return 1;
285} 290}
286 291
@@ -325,14 +330,13 @@ my_conv_rsa_signature (void *cls,
325 char *buf; 330 char *buf;
326 size_t buf_size; 331 size_t buf_size;
327 332
333 (void) cls;
328 GNUNET_assert(1 == qp->num_params); 334 GNUNET_assert(1 == qp->num_params);
329
330 buf_size = GNUNET_CRYPTO_rsa_signature_encode (sig, 335 buf_size = GNUNET_CRYPTO_rsa_signature_encode (sig,
331 &buf); 336 &buf);
332 qbind->buffer = (void *) buf; 337 qbind->buffer = (void *) buf;
333 qbind->buffer_length = buf_size; 338 qbind->buffer_length = buf_size;
334 qbind->buffer_type = MYSQL_TYPE_BLOB; 339 qbind->buffer_type = MYSQL_TYPE_BLOB;
335
336 return 1; 340 return 1;
337} 341}
338 342