Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mx_myqsl: Don't compare signed int and unsigned long
  • Loading branch information
donald committed May 5, 2022
1 parent 9328af6 commit 0c35a52
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions mx_mysql.c
Expand Up @@ -699,11 +699,9 @@ static int _mx_mysql_bind_string(struct mx_mysql_bind *b, unsigned int index, ch

static int _mx_mysql_bind_validate(struct mx_mysql_bind *b)
{
int i;

mx_assert_return_minus_errno(b, EINVAL);

for (i=0; i < b->count; i++) {
for (unsigned long i=0; i < b->count; i++) {
if (!(b->data[i].flags)) {
return -(errno=EBADSLT);
}
Expand Down Expand Up @@ -1015,7 +1013,6 @@ int mx_mysql_statement_fetch(struct mx_mysql_stmt *stmt)
{
struct mx_mysql_bind *r;
int res;
int col;
char *str;
int no_error = 1;

Expand Down Expand Up @@ -1044,7 +1041,7 @@ int mx_mysql_statement_fetch(struct mx_mysql_stmt *stmt)
}

r = &stmt->result;
for (col = 0; col < r->count; col++) {
for (unsigned long col = 0; col < r->count; col++) {
if (r->bind[col].buffer_type == MYSQL_TYPE_STRING) {
str = mx_calloc_forever(r->data[col].length + 1, sizeof(*str));

Expand All @@ -1063,7 +1060,7 @@ int mx_mysql_statement_fetch(struct mx_mysql_stmt *stmt)
if (!(r->data[col].is_error))
continue;

mx_log_debug("WARNING: result data returned in column with index %d was truncated. query was:", col);
mx_log_debug("WARNING: result data returned in column with index %lu was truncated. query was:", col);
mx_log_debug(" \\ %s", stmt->statement);
no_error = 0;
}
Expand Down Expand Up @@ -1165,7 +1162,6 @@ static int _mx_mysql_do_statement(struct mx_mysql *mysql, char *query, struct mx
struct mx_mysql_stmt *stmt = NULL;
unsigned long long num_rows = 0;
int res;
int cnt = 0;
char *tmpdata;

assert(mysql);
Expand Down Expand Up @@ -1196,7 +1192,7 @@ static int _mx_mysql_do_statement(struct mx_mysql *mysql, char *query, struct mx
if (result && result->count && num_rows) {
tmpdata = mx_calloc_forever(num_rows, size);

for (cnt = 0; cnt < num_rows; cnt++) {
for (unsigned long cnt = 0; cnt < num_rows; cnt++) {
res = mx_mysql_statement_fetch(stmt);
if (res < 0) {
mx_log_err("mx_mysql_statement_fetch(): %m");
Expand Down

0 comments on commit 0c35a52

Please sign in to comment.