Changeset: e12f8c3a37c3 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e12f8c3a37c3 Modified Files: clients/mapiclient/mclient.c configure.ag gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_group.c gdk/gdk_join.c gdk/gdk_unique.c monetdb5/modules/atoms/json.c sql/backends/monet5/UDF/pyapi3/conversion3.c sql/server/rel_schema.c sql/server/rel_select.c sql/storage/store.c Branch: Jun2020 Log Message:
Enable -Wformat-signedness compiler option. This needed a few extra casts. diffs (206 lines): diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c --- a/clients/mapiclient/mclient.c +++ b/clients/mapiclient/mclient.c @@ -687,7 +687,7 @@ SQLrow(int *len, int *numeric, char **re mnstr_printf(toConsole, "\\%03o", (unsigned char) *p); else if (*p == '\302' && (p[1] & 0xE0) == 0x80) { - mnstr_printf(toConsole, "\\u%04x", (p[1] & 0x3F) | 0x80); + mnstr_printf(toConsole, "\\u%04x", (unsigned) ((p[1] & 0x3F) | 0x80)); p++; } else mnstr_write(toConsole, p, 1, 1); @@ -705,7 +705,7 @@ SQLrow(int *len, int *numeric, char **re mnstr_printf(toConsole, "\\%03o", (unsigned char) *p); else if (*p == '\302' && (p[1] & 0xE0) == 0x80) { - mnstr_printf(toConsole, "\\u%04x", (p[1] & 0x3F) | 0x80); + mnstr_printf(toConsole, "\\u%04x", (unsigned) ((p[1] & 0x3F) | 0x80)); p++; } else mnstr_write(toConsole, p, 1, 1); @@ -753,7 +753,7 @@ SQLrow(int *len, int *numeric, char **re mnstr_printf(toConsole, "\\%03o", (unsigned char) *p); else if (*p == '\302' && (p[1] & 0xE0) == 0x80) { - mnstr_printf(toConsole, "\\u%04x", (p[1] & 0x3F) | 0x80); + mnstr_printf(toConsole, "\\u%04x", (unsigned) ((p[1] & 0x3F) | 0x80)); p++; } else mnstr_write(toConsole, p, 1, 1); diff --git a/configure.ag b/configure.ag --- a/configure.ag +++ b/configure.ag @@ -544,7 +544,7 @@ AS_VAR_IF([enable_strict], [yes], [ MCHECK_ADD_FLAG([-Wformat-overflow=1]) MCHECK_ADD_FLAG([-Wno-format-truncation]) MCHECK_ADD_FLAG([-Wno-format-nonliteral]) -dnl MCHECK_ADD_FLAG([-Wformat-signedness]) -- numpy messes this up + MCHECK_ADD_FLAG([-Wformat-signedness]) AS_VAR_IF([target_os], [cygwin], [MCHECK_ADD_FLAG([-Wno-error=suggest-attribute=format])], [MCHECK_ADD_FLAG([-Wno-cast-function-type])]) diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -2366,8 +2366,8 @@ BATassertProps(BAT *b) TRC_ERROR(BAT_, "Cannot allocate hash table\n"); goto abort_check; } - if (snprintf(hs->heaplink.filename, sizeof(hs->heaplink.filename), "%s.thshprpl%x", nme, THRgettid()) >= (int) sizeof(hs->heaplink.filename) || - snprintf(hs->heapbckt.filename, sizeof(hs->heapbckt.filename), "%s.thshprpb%x", nme, THRgettid()) >= (int) sizeof(hs->heapbckt.filename)) { + if (snprintf(hs->heaplink.filename, sizeof(hs->heaplink.filename), "%s.thshprpl%x", nme, (unsigned) THRgettid()) >= (int) sizeof(hs->heaplink.filename) || + snprintf(hs->heapbckt.filename, sizeof(hs->heapbckt.filename), "%s.thshprpb%x", nme, (unsigned) THRgettid()) >= (int) sizeof(hs->heapbckt.filename)) { GDKfree(hs); TRC_ERROR(BAT_, "Heap filename is too large\n"); goto abort_check; diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -1395,8 +1395,8 @@ BATkeyed(BAT *b) } if ((hs = GDKzalloc(sizeof(Hash))) == NULL) goto doreturn; - if (snprintf(hs->heaplink.filename, sizeof(hs->heaplink.filename), "%s.thshkeyl%x", nme, THRgettid()) >= (int) sizeof(hs->heaplink.filename) || - snprintf(hs->heapbckt.filename, sizeof(hs->heapbckt.filename), "%s.thshkeyb%x", nme, THRgettid()) >= (int) sizeof(hs->heapbckt.filename) || + if (snprintf(hs->heaplink.filename, sizeof(hs->heaplink.filename), "%s.thshkeyl%x", nme, (unsigned) THRgettid()) >= (int) sizeof(hs->heaplink.filename) || + snprintf(hs->heapbckt.filename, sizeof(hs->heapbckt.filename), "%s.thshkeyb%x", nme, (unsigned) THRgettid()) >= (int) sizeof(hs->heapbckt.filename) || HASHnew(hs, b->ttype, BUNlast(b), mask, BUN_NONE, false) != GDK_SUCCEED) { GDKfree(hs); /* err on the side of caution: not keyed */ diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c --- a/gdk/gdk_group.c +++ b/gdk/gdk_group.c @@ -1110,8 +1110,8 @@ BATgroup_internal(BAT **groups, BAT **ex GDKerror("BATgroup: cannot allocate hash table\n"); goto error; } - if (snprintf(hs->heaplink.filename, sizeof(hs->heaplink.filename), "%s.thshgrpl%x", nme, THRgettid()) >= (int) sizeof(hs->heaplink.filename) || - snprintf(hs->heapbckt.filename, sizeof(hs->heapbckt.filename), "%s.thshgrpb%x", nme, THRgettid()) >= (int) sizeof(hs->heapbckt.filename) || + if (snprintf(hs->heaplink.filename, sizeof(hs->heaplink.filename), "%s.thshgrpl%x", nme, (unsigned) THRgettid()) >= (int) sizeof(hs->heaplink.filename) || + snprintf(hs->heapbckt.filename, sizeof(hs->heapbckt.filename), "%s.thshgrpb%x", nme, (unsigned) THRgettid()) >= (int) sizeof(hs->heapbckt.filename) || HASHnew(hs, b->ttype, BUNlast(b), nbucket, BUN_NONE, false) != GDK_SUCCEED) { GDKfree(hs); hs = NULL; diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c --- a/gdk/gdk_join.c +++ b/gdk/gdk_join.c @@ -2570,7 +2570,7 @@ hashjoin(BAT **r1p, BAT **r2p, BAT *l, B r->thash ? " ignoring existing hash" : "", swapped ? " (swapped)" : ""); if (snprintf(ext, sizeof(ext), "thshjn%x", - rci->s->batCacheid) >= (int) sizeof(ext)) + (unsigned) rci->s->batCacheid) >= (int) sizeof(ext)) goto bailout; if ((hsh = BAThash_impl(r, rci, ext)) == NULL) { goto bailout; diff --git a/gdk/gdk_unique.c b/gdk/gdk_unique.c --- a/gdk/gdk_unique.c +++ b/gdk/gdk_unique.c @@ -224,8 +224,8 @@ BATunique(BAT *b, BAT *s) GDKerror("BATunique: cannot allocate hash table\n"); goto bunins_failed; } - if (snprintf(hs->heaplink.filename, sizeof(hs->heaplink.filename), "%s.thshunil%x", nme, THRgettid()) >= (int) sizeof(hs->heaplink.filename) || - snprintf(hs->heapbckt.filename, sizeof(hs->heapbckt.filename), "%s.thshunib%x", nme, THRgettid()) >= (int) sizeof(hs->heapbckt.filename) || + if (snprintf(hs->heaplink.filename, sizeof(hs->heaplink.filename), "%s.thshunil%x", nme, (unsigned) THRgettid()) >= (int) sizeof(hs->heaplink.filename) || + snprintf(hs->heapbckt.filename, sizeof(hs->heapbckt.filename), "%s.thshunib%x", nme, (unsigned) THRgettid()) >= (int) sizeof(hs->heapbckt.filename) || HASHnew(hs, b->ttype, BUNlast(b), mask, BUN_NONE, false) != GDK_SUCCEED) { GDKfree(hs); hs = NULL; diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c --- a/monetdb5/modules/atoms/json.c +++ b/monetdb5/modules/atoms/json.c @@ -262,7 +262,7 @@ JSONdumpInternal(stream *fd, JSON *jt, i mnstr_printf(fd, "null "); break; default: - mnstr_printf(fd, "unknown %d ", je->kind); + mnstr_printf(fd, "unknown %d ", (int) je->kind); } mnstr_printf(fd, "child %d list ", je->child); for (i = je->next; i; i = jt->elm[i].next) diff --git a/sql/backends/monet5/UDF/pyapi3/conversion3.c b/sql/backends/monet5/UDF/pyapi3/conversion3.c --- a/sql/backends/monet5/UDF/pyapi3/conversion3.c +++ b/sql/backends/monet5/UDF/pyapi3/conversion3.c @@ -1192,7 +1192,7 @@ str ConvertToSQLType(Client cntxt, BAT * return createException( MAL, "pyapi3.eval", "Convert To SQL Type: Unrecognized SQL type %s (%d).", - sql_subtype->type->sqlname, sql_subtype->type->eclass); + sql_subtype->type->sqlname, (int) sql_subtype->type->eclass); } if (res == MAL_SUCCEED) { *ret_bat = BATdescriptor(result_bat); diff --git a/sql/server/rel_schema.c b/sql/server/rel_schema.c --- a/sql/server/rel_schema.c +++ b/sql/server/rel_schema.c @@ -1897,7 +1897,7 @@ rel_grant_privs(mvc *sql, sql_schema *cu return rel_grant_func(sql, cur, obj_privs, qname, typelist, type, grantees, grant, grantor); } default: - return sql_error(sql, 02, SQLSTATE(M0M03) "Grant: unknown token %d", token); + return sql_error(sql, 02, SQLSTATE(M0M03) "Grant: unknown token %d", (int) token); } } @@ -2079,7 +2079,7 @@ rel_revoke_privs(mvc *sql, sql_schema *c return rel_revoke_func(sql, cur, obj_privs, qname, typelist, type, grantees, grant, grantor); } default: - return sql_error(sql, 02, SQLSTATE(M0M03) "Grant: unknown token %d", token); + return sql_error(sql, 02, SQLSTATE(M0M03) "Grant: unknown token %d", (int) token); } } diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -349,7 +349,7 @@ query_exp_optname(sql_query *query, sql_ return rel_table_optname(sql, tq, q->data.lval->t->data.sym); } default: - (void) sql_error(sql, 02, SQLSTATE(42000) "case %d %s", q->token, token2string(q->token)); + (void) sql_error(sql, 02, SQLSTATE(42000) "case %d %s", (int) q->token, token2string(q->token)); } return NULL; } diff --git a/sql/storage/store.c b/sql/storage/store.c --- a/sql/storage/store.c +++ b/sql/storage/store.c @@ -2378,27 +2378,27 @@ tar_write_header(stream *tarfile, const // in /usr/include/tar.h on a Linux system. tar_write_header_field(&cursor, 100, "%s", path); // name[100] tar_write_header_field(&cursor, 8, "0000644"); // mode[8] - tar_write_header_field(&cursor, 8, "%07o", 0); // uid[8] - tar_write_header_field(&cursor, 8, "%07o", 0); // gid[8] + tar_write_header_field(&cursor, 8, "%07o", 0U); // uid[8] + tar_write_header_field(&cursor, 8, "%07o", 0U); // gid[8] tar_write_header_field(&cursor, 12, "%011zo", size); // size[12] - tar_write_header_field(&cursor, 12, "%011lo", (long)mtime); // mtime[12] + tar_write_header_field(&cursor, 12, "%011lo", (unsigned long)mtime); // mtime[12] chksum = cursor; // use this later to set the computed checksum tar_write_header_field(&cursor, 8, "%8s", ""); // chksum[8] *cursor++ = '0'; // typeflag REGTYPE tar_write_header_field(&cursor, 100, "%s", ""); // linkname[100] tar_write_header_field(&cursor, 6, "%s", "ustar"); // magic[6] - tar_write_header_field(&cursor, 2, "%02o", 0); // version, not null terminated + tar_write_header_field(&cursor, 2, "%02o", 0U); // version, not null terminated tar_write_header_field(&cursor, 32, "%s", ""); // uname[32] tar_write_header_field(&cursor, 32, "%s", ""); // gname[32] - tar_write_header_field(&cursor, 8, "%07o", 0); // devmajor[8] - tar_write_header_field(&cursor, 8, "%07o", 0); // devminor[8] + tar_write_header_field(&cursor, 8, "%07o", 0U); // devmajor[8] + tar_write_header_field(&cursor, 8, "%07o", 0U); // devminor[8] tar_write_header_field(&cursor, 155, "%s", ""); // prefix[155] assert(cursor - buf == 500); - int sum = 0; + unsigned sum = 0; for (int i = 0; i < TAR_BLOCK_SIZE; i++) - sum += buf[i]; + sum += (unsigned char) buf[i]; tar_write_header_field(&chksum, 8, "%06o", sum); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list