Kaynağa Gözat

Add -O3 to regular build; fix some compiler warnings.

Stefano Cossu 2 yıl önce
ebeveyn
işleme
40aa33932e
4 değiştirilmiş dosya ile 12 ekleme ve 9 silme
  1. 5 4
      Makefile
  2. 1 1
      src/graph.c
  3. 3 3
      src/namespace.c
  4. 3 1
      src/store_mdb.c

+ 5 - 4
Makefile

@@ -20,8 +20,9 @@ CALLGRIND_DUMP = /tmp/lsup_callgrind.out
 INCLUDE_BASE ::= . -Iinclude -I$(MDB_DIR) -I$(XXHASH_DIR) \
 	-Iext/tpl/src -Iext/hashmap -Iext/log/src
 INCLUDE ::= -I$(INCLUDE_BASE)
-CFLAGS ::= -Wall -fPIC -MMD -DLOG_USE_COLOR $(INCLUDE)
-DBG_CFLAGS = -Itest -O0 -g3 -DDEBUG
+_CFLAGS ::= -Wall -fPIC -MMD -DLOG_USE_COLOR $(INCLUDE)
+CFLAGS = $(_CFLAGS) -O3
+DBG_CFLAGS = $(_CFLAGS) -Itest -O0 -g3 -DDEBUG
 # NOTE: -luuid is a Linux system library. Other OS's might need a different
 # link or a non-system library built.
 LDFLAGS ::= -L. -L$(libdir) -llmdb -lxxhash -luuid
@@ -112,7 +113,7 @@ liblsuprdf_dbg.so: $(DBG_OBJ)
 
 # Debug objects.
 %_dbg.o: %.c
-	$(CC) $(CFLAGS) $(DBG_CFLAGS) -c $^ -o $@
+	$(CC) $(DBG_CFLAGS) -c $^ -o $@
 
 
 # Codecs in a subfolder.
@@ -180,7 +181,7 @@ uninstall:
 
 # For testing, use debug symbols.
 bin/test: debug $(TEST_SRC)
-	$(CC) $(CFLAGS) $(DBG_CFLAGS) -Itest $(LDFLAGS) -llsuprdf_dbg \
+	$(CC) $(DBG_CFLAGS) $(LDFLAGS) -llsuprdf_dbg \
 		test.c -o bin/test
 
 

+ 1 - 1
src/graph.c

@@ -418,7 +418,7 @@ LSUP_rc
 LSUP_graph_iter_next (LSUP_GraphIterator *it, LSUP_Triple *spo)
 {
     LSUP_Buffer *ss, *sp, *so;
-    LSUP_BufferTriple *sspo;
+    LSUP_BufferTriple *sspo = NULL;
     if (it->graph->store->sif->features & LSUP_STORE_COW) {
         CALLOC_GUARD (ss, LSUP_MEM_ERR);
         CALLOC_GUARD (sp, LSUP_MEM_ERR);

+ 3 - 3
src/namespace.c

@@ -79,7 +79,7 @@ LSUP_nsmap_add (NSMap *map, const char *pfx, const char *nsstr)
         log_warn(
                 "Prefix `%s` is longer than the maximum allowed size "
                 "(%d characters). Truncating.", pfx, PFX_LEN - 1);
-    strncpy (entry_s.pfx, pfx, sizeof (entry_s.pfx));
+    strncpy (entry_s.pfx, pfx, PFX_LEN -1);
     char *ns = strdup (nsstr);
 
     NSEntry *ret = hashmap_get (map, &entry_s);
@@ -105,7 +105,7 @@ LSUP_rc
 LSUP_nsmap_remove (NSMap *map, const char *pfx)
 {
     NSEntry entry_s;
-    strncpy (entry_s.pfx, pfx, PFX_LEN);
+    strncpy (entry_s.pfx, pfx, PFX_LEN - 1);
     NSEntry *entry = hashmap_delete (map, &entry_s);
 
     if (!entry) return LSUP_NOACTION;
@@ -120,7 +120,7 @@ const char *
 LSUP_nsmap_get_ns (const NSMap *map, const char *pfx)
 {
     NSEntry entry_s;
-    strncpy (entry_s.pfx, pfx, PFX_LEN);
+    strncpy (entry_s.pfx, pfx, PFX_LEN - 1);
     NSEntry *entry = hashmap_get ((NSMap *)map, &entry_s);
 
     return (entry) ? entry->ns : NULL;

+ 3 - 1
src/store_mdb.c

@@ -984,7 +984,9 @@ mdbstore_remove (
         const LSUP_Buffer *so, const LSUP_Buffer *sc, void *th, size_t *ct)
 {
     MDBStore *store = h;
-    LSUP_rc rc = LSUP_NOACTION, db_rc;
+    LSUP_rc
+        rc = LSUP_NOACTION,
+        db_rc = 0;
 
     LSUP_Key ck = NULL_KEY;