murphy-db: get rid of a bunch of compilation warnings.
authorKrisztian Litkey <krisztian.litkey@intel.com>
Fri, 22 Feb 2013 08:37:38 +0000 (10:37 +0200)
committerKrisztian Litkey <krisztian.litkey@intel.com>
Fri, 22 Feb 2013 08:56:26 +0000 (10:56 +0200)
12 files changed:
src/murphy-db/include/murphy-db/mqi-types.h
src/murphy-db/mdb/column.c
src/murphy-db/mdb/handle.c
src/murphy-db/mdb/hash.c
src/murphy-db/mdb/mqi-types.c
src/murphy-db/mdb/table.c
src/murphy-db/mqi/mqi.c
src/murphy-db/mql/mql-parser.y
src/murphy-db/mql/result.c
src/murphy-db/mql/statement.c
src/murphy-db/tests/check-libmqi.c
src/murphy-db/tests/check-libmql.c

index 8f586a6..ed0d06e 100644 (file)
@@ -33,6 +33,9 @@
 #include <stdint.h>
 #include <stdbool.h>
 
+/** macro to tag a variable unused */
+#define MQI_UNUSED(var) ((void)var)
+
 /** maximum number of rows a query can produce */
 #define MQI_QUERY_RESULT_MAX   8192
 /** the maximum number columns a table can have */
index 3e61920..aa224e2 100644 (file)
@@ -184,6 +184,11 @@ int mdb_column_print(mdb_column_t *cdesc, void *data, char *buf, int len)
 
 static int print_blob(uint8_t *data, int data_len, char *buf, int buflen)
 {
+    MQI_UNUSED(data);
+    MQI_UNUSED(data_len);
+    MQI_UNUSED(buf);
+    MQI_UNUSED(buflen);
+
     return 0;
 }
 
index f2cf292..379fd4d 100644 (file)
@@ -214,7 +214,7 @@ static mdb_handle_t index_alloc(indextbl_t *indextbl, int index, void *data)
     indextbl_entry_t *entries, *entry;
     size_t size;
 
-    MDB_CHECKARG(index >= 0 && index < HANDLE_INDEX_MAX && data,
+    MDB_CHECKARG(index >= 0 && (mdb_handle_t)index < HANDLE_INDEX_MAX && data,
                  MDB_HANDLE_INVALID);
 
     if (index >= indextbl->nentry) {
index 67c15f0..89ad450 100644 (file)
@@ -417,6 +417,9 @@ int mdb_hash_function_pointer(int bits, int nchain, int klen, void *key)
 #define MASK(t)  ((((uint##t##_t)1) << (sizeof(int) * 8 - 3)) - 1)
     int hash;
 
+    MQI_UNUSED(bits);
+    MQI_UNUSED(klen);
+
 #if __SIZEOF_POINTER__ == 8
     hash = (int)(((uint64_t)key >> 2) & MASK(64)) % nchain;
 #else
index d85f664..2496102 100644 (file)
@@ -147,6 +147,10 @@ int mqi_data_print_varchar(void *data, char *buf, int len)
 
 int mqi_data_print_blob(void *data, char *buf, int len)
 {
+    MQI_UNUSED(data);
+    MQI_UNUSED(buf);
+    MQI_UNUSED(len);
+
     return 0;
 }
 
index 12df4c6..9106809 100644 (file)
@@ -504,7 +504,7 @@ int mdb_table_print_rows(mdb_table_t *tbl, char *buf, int len)
         p += mdb_column_print_header(tbl->columns + i, p, e-p);
 
     if (p + ((l = p - buf) + 3) < e) {
-        if (l > sizeof(dashes) - 1)
+        if (l > (int)sizeof(dashes) - 1)
             l = sizeof(dashes) - 1;
 
         memset(dashes, '-', l);
@@ -661,6 +661,8 @@ static int select_all(mdb_table_t       *tbl,
     int                cindex;
     int                j;
 
+    MQI_UNUSED(dim);
+
     for (it.cursor = NULL, nresult = 0;
          (row = table_iterator(tbl, &it));
          nresult++)
index 0c6408e..34cb75c 100644 (file)
@@ -412,7 +412,7 @@ int mqi_commit_transaction(mqi_handle_t h)
 
     MDB_CHECKARG(h != MQI_HANDLE_INVALID && depth < MQI_TXDEPTH_MAX, -1);
     MDB_PREREQUISITE(dbs && ndb > 0, -1);
-    MDB_ASSERT(txdepth > 0 && depth == txdepth - 1, EBADSLT, -1);
+    MDB_ASSERT(txdepth > 0 && depth == (uint32_t)txdepth - 1, EBADSLT, -1);
 
     tx = txstack + depth;
 
@@ -443,7 +443,7 @@ int mqi_rollback_transaction(mqi_handle_t h)
 
     MDB_CHECKARG(h != MQI_HANDLE_INVALID && depth < MQI_TXDEPTH_MAX, -1);
     MDB_PREREQUISITE(dbs && ndb > 0, -1);
-    MDB_ASSERT(txdepth > 0 && depth == txdepth - 1, EBADSLT, -1);
+    MDB_ASSERT(txdepth > 0 && depth == (uint32_t)txdepth - 1, EBADSLT, -1);
 
     tx = txstack + depth;
 
index 13aef5e..e049f1f 100644 (file)
@@ -412,7 +412,7 @@ create_table: table_flags TKN_TABLE {
 
 
 table_definition: TKN_IDENTIFIER TKN_LEFT_PAREN column_defs TKN_RIGHT_PAREN {
-    if (mqi_create_table($1, table_flags, NULL, coldefs) < 0)
+    if (mqi_create_table($1, table_flags, NULL, coldefs) == MQI_HANDLE_INVALID)
         MQL_ERROR(errno, "Can't create table: %s\n", strerror(errno));
     else
         MQL_SUCCESS;
@@ -1405,7 +1405,7 @@ int yy_mql_input(void *dst, unsigned dstlen)
         if (mqlbuf) {
             if ((len = strlen(mqlbuf)) < 1)
                 len = 0;
-            else if (len + 1 <= dstlen) {
+            else if ((unsigned)len + 1 <= dstlen) {
                 memcpy(dst, mqlbuf, len + 1);
                 mqlbuf += len;
             }
@@ -1514,14 +1514,14 @@ static void print_query_result(mqi_column_desc_t *coldescs,
 
         clghs[j] = clgh;
 
-        if (clgh < sizeof(name))
+        if (clgh < (int)sizeof(name))
             name[clgh] = '\0';
 
         n += fprintf(mqlout, "%s%*s", j?" ":"", clgh,name);
 
     }
 
-    if (n > sizeof(name)-1)
+    if (n > (int)sizeof(name)-1)
         n = sizeof(name)-1;
     memset(name, '-', n);
     name[n] = '\0';
index a0b8b5f..9e47870 100644 (file)
@@ -175,7 +175,7 @@ mql_result_t *mql_result_error_create(int code, const char *fmt, ...)
     l = vsnprintf(buf, sizeof(buf), fmt, ap);
     va_end(ap);
 
-    if (l > sizeof(buf))
+    if (l > (int)sizeof(buf))
         l = sizeof(buf) - 1;
 
     if ((rslt = calloc(1, sizeof(result_error_t) + l + 1))) {
@@ -656,7 +656,7 @@ mql_result_t *mql_result_string_create_table_list(int n, char **names)
     char  *p;
     int    i;
 
-    MDB_CHECKARG(n >= 0 && n < MQI_DIMENSION(nlgh) && names, NULL);
+    MDB_CHECKARG(n >= 0 && n < (int)MQI_DIMENSION(nlgh) && names, NULL);
 
     len = 1;  /* zero terminator */
 
@@ -1153,7 +1153,7 @@ mql_result_t *mql_result_string_create_row_list(int                 ncol,
      */
     for (i = 0;   i < ncol;   i++) {
         if ((cwidth = cwidths[i])) {
-            if (cwidth <= (len = strlen(colnams[i]))) {
+            if (cwidth <= (int)(len = strlen(colnams[i]))) {
                 /* truncate */
                 memcpy(p, colnams[i], cwidth);
                 p[cwidth] = ' ';
index edc5574..d7533ec 100644 (file)
@@ -776,6 +776,8 @@ static mql_result_t *exec_show_tables(mql_result_type_t type,
     char         *names[4096];
     int           n;
 
+    MQI_UNUSED(type);
+
     if ((n = mqi_show_tables(st->flags, names, MQI_DIMENSION(names))) < 0) {
         rslt = mql_result_error_create(errno, "can't show tables: %s",
                                        strerror(errno));
index 116a985..1f2e2a2 100644 (file)
@@ -340,7 +340,7 @@ START_TEST(transaction_begin)
 {
     mqi_handle_t tx;
 
-    fail_if(txdepth >= MQI_DIMENSION(transactions), "too many nested "
+    fail_if(txdepth >= (int)MQI_DIMENSION(transactions), "too many nested "
             "transactions. Only %d allowed", MQI_DIMENSION(transactions));
 
     tx = MQI_BEGIN;
@@ -599,7 +599,7 @@ START_TEST(transaction_rollback)
     for (i = 0;  i < n;  i++) {
         r = rows + i;
 
-        for (found = 0, j = 0;  j < MQI_DIMENSION(artists)-1;  j++) {
+        for (found = 0, j = 0;  j < (int)MQI_DIMENSION(artists)-1;  j++) {
             a = artists[j];
 
             if (a->id == r->id &&
@@ -832,7 +832,7 @@ START_TEST(nested_transactions)
 
     PREREQUISITE(create_table_persons);
 
-    if (nnest > sizeof(txids) / sizeof(txids[0]))
+    if (nnest > (int)(sizeof(txids) / sizeof(txids[0])))
         nnest = sizeof(txids) / sizeof(txids[0]);
 
     for (cnt = 0; cnt < 16; cnt++) {
@@ -1003,7 +1003,7 @@ static void transaction_event_cb(mqi_event_t *evt, void *user_data)
  /* mqi_transact_event_t *te    = &evt->transact; */
     trigger_t            *trig;
 
-    if (ntrigger >= MQI_DIMENSION(triggers)) {
+    if (ntrigger >= (int)MQI_DIMENSION(triggers)) {
         if (verbose)
             printf("test framework error: trigger log overflow\n");
         return;
@@ -1033,7 +1033,7 @@ static void table_event_cb(mqi_event_t *evt, void *user_data)
     mqi_table_event_t *te    = &evt->table;
     trigger_t         *trig;
 
-    if (ntrigger >= MQI_DIMENSION(triggers)) {
+    if (ntrigger >= (int)MQI_DIMENSION(triggers)) {
         if (verbose)
             printf("test framework error: trigger log overflow\n");
         return;
@@ -1067,7 +1067,7 @@ static void row_event_cb(mqi_event_t *evt, void *user_data)
     trigger_t        *trig;
     query_t          *row;
 
-    if (ntrigger >= MQI_DIMENSION(triggers)) {
+    if (ntrigger >= (int)MQI_DIMENSION(triggers)) {
         if (verbose)
             printf("test framework error: trigger log overflow\n");
         return;
@@ -1112,7 +1112,7 @@ static void column_event_cb(mqi_event_t *evt, void *user_data)
     trigger_t          *trig;
     query_t            *row;
 
-    if (ntrigger >= MQI_DIMENSION(triggers)) {
+    if (ntrigger >= (int)MQI_DIMENSION(triggers)) {
         if (verbose)
             printf("test framework error: trigger log overflow\n");
         return;
index 9827731..543c1f1 100644 (file)
@@ -305,7 +305,7 @@ START_TEST(precompile_transaction_statements)
         fail_unless(MQI_DIMENSION(string) == MQI_DIMENSION(stmnt),
                     "internal error: dimension mismatch in %s()", __FILE__);
 
-        for (i = 0;  i < MQI_DIMENSION(string);  i++) {
+        for (i = 0;  i < (int)MQI_DIMENSION(string);  i++) {
             if (!(*(stmnt[i]) = mql_precompile(string[i]))) {
                 fail("precompilation error of '%s' (%s)",
                      string[i], strerror(errno));
@@ -914,6 +914,8 @@ static TCase *basic_tests(void)
 
 static void transaction_event_cb(mql_result_t *result, void *user_data)
 {
+    MQI_UNUSED(user_data);
+
     if (result->type == mql_result_string) {
         if (verbose)
             printf("---\n%s\n", mql_result_string_get(result));
@@ -928,6 +930,8 @@ static void transaction_event_cb(mql_result_t *result, void *user_data)
 
 static void table_event_cb(mql_result_t *result, void *user_data)
 {
+    MQI_UNUSED(user_data);
+
     if (result->type == mql_result_string) {
         if (verbose)
             printf("---\n%s\n", mql_result_string_get(result));
@@ -942,6 +946,8 @@ static void table_event_cb(mql_result_t *result, void *user_data)
 
 static void row_event_cb(mql_result_t *result, void *user_data)
 {
+    MQI_UNUSED(user_data);
+
     if (result->type == mql_result_string) {
         if (verbose)
             printf("---\n%s\n", mql_result_string_get(result));
@@ -956,6 +962,8 @@ static void row_event_cb(mql_result_t *result, void *user_data)
 
 static void column_event_cb(mql_result_t *result, void *user_data)
 {
+    MQI_UNUSED(user_data);
+
     if (result->type == mql_result_string) {
         if (verbose)
             printf("---\n%s\n", mql_result_string_get(result));