From 16e375e637e362996f458450cdad4c801384ad5e Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Tue, 4 Sep 2018 20:07:05 +0200 Subject: [PATCH] [db/misc] Cast ARRAY_SIZE to unsigned (avoids compiler warnings) --- src/db.c | 12 ++++++------ src/db_upgrade.c | 2 +- src/misc.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/db.c b/src/db.c index 6aa6af6b..54b9dfcd 100644 --- a/src/db.c +++ b/src/db.c @@ -2021,7 +2021,7 @@ db_query_fetch_file(struct query_params *qp, struct db_media_file_info *dbmfi) // We allow more cols in db than in map because the db may be a future schema if (ncols < ARRAY_SIZE(dbmfi_cols_map)) { - DPRINTF(E_LOG, L_DB, "BUG: database has fewer columns (%d) than dbmfi column map (%lu)\n", ncols, ARRAY_SIZE(dbmfi_cols_map)); + DPRINTF(E_LOG, L_DB, "BUG: database has fewer columns (%d) than dbmfi column map (%u)\n", ncols, ARRAY_SIZE(dbmfi_cols_map)); return -1; } @@ -2079,7 +2079,7 @@ db_query_fetch_pl(struct query_params *qp, struct db_playlist_info *dbpli, int w // We allow more cols in db than in map because the db may be a future schema if (ncols < ARRAY_SIZE(dbpli_cols_map)) { - DPRINTF(E_LOG, L_DB, "BUG: database has fewer columns (%d) than dbpli column map (%lu)\n", ncols, ARRAY_SIZE(dbpli_cols_map)); + DPRINTF(E_LOG, L_DB, "BUG: database has fewer columns (%d) than dbpli column map (%u)\n", ncols, ARRAY_SIZE(dbpli_cols_map)); return -1; } @@ -2174,7 +2174,7 @@ db_query_fetch_group(struct query_params *qp, struct db_group_info *dbgri) // We allow more cols in db than in map because the db may be a future schema if (ncols < ARRAY_SIZE(dbgri_cols_map)) { - DPRINTF(E_LOG, L_DB, "BUG: database has fewer columns (%d) than dbgri column map (%lu)\n", ncols, ARRAY_SIZE(dbgri_cols_map)); + DPRINTF(E_LOG, L_DB, "BUG: database has fewer columns (%d) than dbgri column map (%u)\n", ncols, ARRAY_SIZE(dbgri_cols_map)); return -1; } @@ -2660,7 +2660,7 @@ db_file_fetch_byquery(char *query) // We allow more cols in db than in map because the db may be a future schema if (ncols < ARRAY_SIZE(mfi_cols_map)) { - DPRINTF(E_LOG, L_DB, "BUG: database has fewer columns (%d) than mfi column map (%lu)\n", ncols, ARRAY_SIZE(mfi_cols_map)); + DPRINTF(E_LOG, L_DB, "BUG: database has fewer columns (%d) than mfi column map (%u)\n", ncols, ARRAY_SIZE(mfi_cols_map)); sqlite3_finalize(stmt); free(mfi); @@ -3270,7 +3270,7 @@ db_pl_fetch_byquery(const char *query) if (ncols < ARRAY_SIZE(pli_cols_map)) { - DPRINTF(E_LOG, L_DB, "BUG: database has fewer columns (%d) than pli column map (%lu)\n", ncols, ARRAY_SIZE(pli_cols_map)); + DPRINTF(E_LOG, L_DB, "BUG: database has fewer columns (%d) than pli column map (%u)\n", ncols, ARRAY_SIZE(pli_cols_map)); sqlite3_finalize(stmt); free(pli); @@ -6027,7 +6027,7 @@ db_watch_get_byquery(struct watch_info *wi, char *query) if (ncols < ARRAY_SIZE(wi_cols_map)) { - DPRINTF(E_LOG, L_DB, "BUG: database has fewer columns (%d) than wi column map (%lu)\n", ncols, ARRAY_SIZE(wi_cols_map)); + DPRINTF(E_LOG, L_DB, "BUG: database has fewer columns (%d) than wi column map (%u)\n", ncols, ARRAY_SIZE(wi_cols_map)); sqlite3_finalize(stmt); sqlite3_free(query); diff --git a/src/db_upgrade.c b/src/db_upgrade.c index 17c48faf..be820aa6 100644 --- a/src/db_upgrade.c +++ b/src/db_upgrade.c @@ -103,7 +103,7 @@ db_drop_indices(sqlite3 *hdl) static int -db_generic_upgrade(sqlite3 *hdl, const struct db_upgrade_query *queries, int nqueries) +db_generic_upgrade(sqlite3 *hdl, const struct db_upgrade_query *queries, unsigned int nqueries) { char *errmsg; int i; diff --git a/src/misc.h b/src/misc.h index 8f1764c1..65915540 100644 --- a/src/misc.h +++ b/src/misc.h @@ -15,7 +15,7 @@ #define STOB(s) ((s) * 4) #define BTOS(b) ((b) / 4) -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#define ARRAY_SIZE(x) ((unsigned int)(sizeof(x) / sizeof((x)[0]))) struct onekeyval { char *name;