Silence compiler warnings in -Wformat mode.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 13 Nov 2014 18:46:38 +0000 (20:46 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 13 Nov 2014 19:01:05 +0000 (21:01 +0200)
Passing SQLINTEGER/SQLUINTEGER sprintf "%d", "%ld" modifiers gave a warning
on some systems (at least on my 32-bit Debian system) .

connection.c
convert.c

index e7ed3cdaa37e3eeb66012a1b554e24aec03e3f83..d0343c4dab38cf95bbd65ee751e43c66a8964698 100644 (file)
@@ -1312,7 +1312,7 @@ static char   *protocol3_opts_build(ConnectionClass *self)
        char    outwrk[16];
 
        slen += (strlen(l_keepalives_idle) + 2);
-       snprintf(outwrk, sizeof(outwrk), FORMAT_UINTEGER, self->connInfo.keepalive_idle);
+       snprintf(outwrk, sizeof(outwrk), FORMAT_INT4, self->connInfo.keepalive_idle);
        slen += strlen(outwrk);
    }
    if (self->connInfo.keepalive_interval > 0)
@@ -1320,7 +1320,7 @@ static char   *protocol3_opts_build(ConnectionClass *self)
        char    outwrk[16];
 
        slen += (strlen(l_keepalives_interval) + 2);
-       snprintf(outwrk, sizeof(outwrk), FORMAT_UINTEGER, self->connInfo.keepalive_interval);
+       snprintf(outwrk, sizeof(outwrk), FORMAT_INT4, self->connInfo.keepalive_interval);
        slen += strlen(outwrk);
    }
 
@@ -1365,14 +1365,14 @@ static char *protocol3_opts_build(ConnectionClass *self)
    {
        sprintf(ppacket, " %s=", l_keepalives_idle);
        ppacket = strchr(ppacket, (int) '\0');
-       sprintf(ppacket, FORMAT_UINTEGER, self->connInfo.keepalive_idle);
+       sprintf(ppacket, FORMAT_INT4, self->connInfo.keepalive_idle);
        ppacket = strchr(ppacket, (int) '\0');
    }
    if (self->connInfo.keepalive_interval > 0)
    {
        sprintf(ppacket, " %s=", l_keepalives_interval);
        ppacket = strchr(ppacket, (int) '\0');
-       sprintf(ppacket, FORMAT_UINTEGER, self->connInfo.keepalive_interval);
+       sprintf(ppacket, FORMAT_INT4, self->connInfo.keepalive_interval);
        ppacket = strchr(ppacket, (int) '\0');
    }
    *ppacket = '\0';
index 06e50b0ba281c6aa83d216db2e77d8648b2f02f4..5070711b04137ab4cbd760c73228c39a3fa4b9d0 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -4219,27 +4219,27 @@ mylog("C_WCHAR=%s(%d)\n", buffer, used);
        }
        case SQL_C_INTERVAL_YEAR:
            ivsign = ivstruct->interval_sign ? "-" : "";
-           sprintf(param_string, "%s%d years", ivsign, ivstruct->intval.year_month.year);
+           sprintf(param_string, "%s%u years", ivsign, (unsigned int) ivstruct->intval.year_month.year);
            break;
        case SQL_C_INTERVAL_MONTH:
        case SQL_C_INTERVAL_YEAR_TO_MONTH:
            ivsign = ivstruct->interval_sign ? "-" : "";
-           sprintf(param_string, "%s%d years %s%d mons", ivsign, ivstruct->intval.year_month.year, ivsign, ivstruct->intval.year_month.month);
+           sprintf(param_string, "%s%u years %s%u mons", ivsign, (unsigned int) ivstruct->intval.year_month.year, ivsign, (unsigned int) ivstruct->intval.year_month.month);
            break;
        case SQL_C_INTERVAL_DAY:
            ivsign = ivstruct->interval_sign ? "-" : "";
-           sprintf(param_string, "%s%d days", ivsign, ivstruct->intval.day_second.day);
+           sprintf(param_string, "%s%u days", ivsign, (unsigned int) ivstruct->intval.day_second.day);
            break;
        case SQL_C_INTERVAL_HOUR:
        case SQL_C_INTERVAL_DAY_TO_HOUR:
            ivsign = ivstruct->interval_sign ? "-" : "";
-           sprintf(param_string, "%s%d days %s%02d:00:00", ivsign, ivstruct->intval.day_second.day, ivsign, ivstruct->intval.day_second.hour);
+           sprintf(param_string, "%s%u days %s%02u:00:00", ivsign, (unsigned int) ivstruct->intval.day_second.day, ivsign, (unsigned int) ivstruct->intval.day_second.hour);
            break;
        case SQL_C_INTERVAL_MINUTE:
        case SQL_C_INTERVAL_HOUR_TO_MINUTE:
        case SQL_C_INTERVAL_DAY_TO_MINUTE:
            ivsign = ivstruct->interval_sign ? "-" : "";
-           sprintf(param_string, "%s%d days %s%02d:%02d:00", ivsign, ivstruct->intval.day_second.day, ivsign, ivstruct->intval.day_second.hour, ivstruct->intval.day_second.minute);
+           sprintf(param_string, "%s%u days %s%02u:%02u:00", ivsign, (unsigned int) ivstruct->intval.day_second.day, ivsign, (unsigned int) ivstruct->intval.day_second.hour, (unsigned int) ivstruct->intval.day_second.minute);
            break;
 
        case SQL_C_INTERVAL_SECOND:
@@ -4247,11 +4247,11 @@ mylog("C_WCHAR=%s(%d)\n", buffer, used);
        case SQL_C_INTERVAL_HOUR_TO_SECOND:
        case SQL_C_INTERVAL_MINUTE_TO_SECOND:
            ivsign = ivstruct->interval_sign ? "-" : "";
-           sprintf(param_string, "%s%d days %s%02d:%02d:%02d",
-               ivsign, ivstruct->intval.day_second.day,
-               ivsign, ivstruct->intval.day_second.hour,
-               ivstruct->intval.day_second.minute,
-               ivstruct->intval.day_second.second);
+           sprintf(param_string, "%s%u days %s%02u:%02u:%02u",
+                   ivsign, (unsigned int) ivstruct->intval.day_second.day,
+                   ivsign, (unsigned int) ivstruct->intval.day_second.hour,
+                   (unsigned int) ivstruct->intval.day_second.minute,
+                   (unsigned int) ivstruct->intval.day_second.second);
            if (ivstruct->intval.day_second.fraction > 0)
            {
                int fraction = ivstruct->intval.day_second.fraction, prec = apara->precision;