aboutsummaryrefslogtreecommitdiff
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
parentf6a87ee66310529edf76c0fab76cdc7cd2aac216 (diff)
tell mysql that our integers are unsigned
-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 b9d5c84247..2f4cd3ba38 100644
--- a/src/my/my.c
+++ b/src/my/my.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- Copyright (C) 2016 Inria & GNUnet e.V.
+ Copyright (C) 2016, 2018 GNUnet e.V.
GNUnet is free software: you can redistribute it and/or modify it
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,
{
const struct GNUNET_MY_QueryParam *p;
unsigned int num;
- unsigned int i;
MYSQL_STMT *stmt;
num = 0;
- for (i=0;NULL != params[i].conv;i++)
+ for (unsigned int i=0;NULL != params[i].conv;i++)
num += params[i].num_params;
{
MYSQL_BIND qbind[num];
unsigned int off;
- memset (qbind, 0, sizeof(qbind));
+ memset (qbind,
+ 0,
+ sizeof(qbind));
off = 0;
- for (i=0;NULL != (p = &params[i])->conv;i++)
+ for (unsigned int i=0;NULL != (p = &params[i])->conv;i++)
{
if (GNUNET_OK !=
p->conv (p->conv_cls,
@@ -111,9 +112,7 @@ void
GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp,
MYSQL_BIND *qbind)
{
- unsigned int i;
-
- for (i=0; NULL != qp[i].conv ;i++)
+ for (unsigned int i=0; NULL != qp[i].conv ;i++)
if (NULL != qp[i].cleaner)
qp[i].cleaner (qp[i].conv_cls,
&qbind[i]);
@@ -136,7 +135,6 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh,
struct GNUNET_MY_ResultSpec *rs)
{
unsigned int num_fields;
- unsigned int i;
int ret;
MYSQL_STMT *stmt;
@@ -153,7 +151,7 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh,
}
num_fields = 0;
- for (i=0;NULL != rs[i].pre_conv;i++)
+ for (unsigned int i=0;NULL != rs[i].pre_conv;i++)
num_fields += rs[i].num_fields;
if (mysql_stmt_field_count (stmt) != num_fields)
@@ -169,7 +167,7 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh,
memset (result, 0, sizeof (MYSQL_BIND) * num_fields);
field_off = 0;
- for (i=0;NULL != rs[i].pre_conv;i++)
+ for (unsigned int i=0;NULL != rs[i].pre_conv;i++)
{
struct GNUNET_MY_ResultSpec *rp = &rs[i];
@@ -221,7 +219,7 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh,
return GNUNET_SYSERR;
}
field_off = 0;
- for (i=0;NULL != rs[i].post_conv;i++)
+ for (unsigned int i=0;NULL != rs[i].post_conv;i++)
{
struct GNUNET_MY_ResultSpec *rp = &rs[i];
@@ -256,9 +254,7 @@ GNUNET_MY_extract_result (struct GNUNET_MYSQL_StatementHandle *sh,
void
GNUNET_MY_cleanup_result (struct GNUNET_MY_ResultSpec *rs)
{
- unsigned int i;
-
- for (i=0;NULL != rs[i].post_conv;i++)
+ for (unsigned int i=0;NULL != rs[i].post_conv;i++)
if (NULL != rs[i].cleaner)
rs[i].cleaner (rs[i].conv_cls,
&rs[i]);
diff --git a/src/my/my_query_helper.c b/src/my/my_query_helper.c
index c4516715a7..b2a893a44c 100644
--- a/src/my/my_query_helper.c
+++ b/src/my/my_query_helper.c
@@ -37,6 +37,7 @@ static void
my_clean_query (void *cls,
MYSQL_BIND *qbind)
{
+ (void) cls;
GNUNET_free (qbind[0].buffer);
}
@@ -54,6 +55,7 @@ my_conv_fixed_size (void *cls,
const struct GNUNET_MY_QueryParam *qp,
MYSQL_BIND *qbind)
{
+ (void) cls;
GNUNET_assert (1 == qp->num_params);
qbind->buffer = (void *) qp->data;
qbind->buffer_length = qp->data_len;
@@ -99,12 +101,11 @@ my_conv_string (void *cls,
const struct GNUNET_MY_QueryParam *qp,
MYSQL_BIND *qbind)
{
+ (void) cls;
GNUNET_assert (1 == qp->num_params);
-
qbind->buffer = (void *) qp->data;
qbind->buffer_length = qp->data_len;
qbind->buffer_type = MYSQL_TYPE_STRING;
-
return 1;
}
@@ -142,10 +143,12 @@ my_conv_uint16 (void *cls,
const struct GNUNET_MY_QueryParam *qp,
MYSQL_BIND *qbind)
{
+ (void) cls;
GNUNET_assert (1 == qp->num_params);
qbind->buffer = (void *) qp->data;
qbind->buffer_length = sizeof (uint16_t);
qbind->buffer_type = MYSQL_TYPE_SHORT;
+ qbind->is_unsigned = 1;
return 1;
}
@@ -184,11 +187,12 @@ my_conv_uint32 (void *cls,
const struct GNUNET_MY_QueryParam *qp,
MYSQL_BIND *qbind)
{
+ (void) cls;
GNUNET_assert (1 == qp->num_params);
qbind->buffer = (void *) qp->data;
qbind->buffer_length = sizeof(uint32_t);
qbind->buffer_type = MYSQL_TYPE_LONG;
-
+ qbind->is_unsigned = 1;
return 1;
}
@@ -227,10 +231,12 @@ my_conv_uint64 (void *cls,
const struct GNUNET_MY_QueryParam *qp,
MYSQL_BIND * qbind)
{
+ (void) cls;
GNUNET_assert (1 == qp->num_params);
qbind->buffer = (void *) qp->data;
qbind->buffer_length = sizeof (uint64_t);
qbind->buffer_type = MYSQL_TYPE_LONGLONG;
+ qbind->is_unsigned = 1;
return 1;
}
@@ -273,14 +279,13 @@ my_conv_rsa_public_key (void *cls,
char *buf;
size_t buf_size;
+ (void) cls;
GNUNET_assert(1 == qp->num_params);
-
- buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rsa, &buf);
-
+ buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rsa,
+ &buf);
qbind->buffer = (void *) buf;
qbind->buffer_length = buf_size;
qbind->buffer_type = MYSQL_TYPE_BLOB;
-
return 1;
}
@@ -325,14 +330,13 @@ my_conv_rsa_signature (void *cls,
char *buf;
size_t buf_size;
+ (void) cls;
GNUNET_assert(1 == qp->num_params);
-
buf_size = GNUNET_CRYPTO_rsa_signature_encode (sig,
&buf);
qbind->buffer = (void *) buf;
qbind->buffer_length = buf_size;
qbind->buffer_type = MYSQL_TYPE_BLOB;
-
return 1;
}