Prechádzať zdrojové kódy

fix some warnings when compiling for release type

Ioannis Koutras 11 rokov pred
rodič
commit
79b29ca1f3
2 zmenil súbory, kde vykonal 13 pridanie a 3 odobranie
  1. 3 1
      src/memalign.c
  2. 10 2
      src/release_memory.c

+ 3 - 1
src/memalign.c

@@ -54,6 +54,8 @@ void *memalign(size_t alignment, size_t size) {
     DEFAULT_RB_T *encapsulated_rb;
     raw_block_header_t *raw_block;
 
+    memptr = NULL;
+
     /* Search the available freelist-organized raw blocks for a block whose size
      * is size + alignment - 1 */
     SLIST_FOREACH(raw_block, &systemallocator.rb_head, pointers) {
@@ -77,7 +79,7 @@ void *memalign(size_t alignment, size_t size) {
              * happening and memcpy() is safe to be used, the alignment size is
              * increased until it is bigger than the header size.
              */
-            unsigned int counter;
+            unsigned int counter = 0;
             if(alignment < sizeof(raw_block_header_t)) {
                 size_t new_alignment = alignment;
                 for(counter = 0; new_alignment < sizeof(raw_block_header_t);

+ 10 - 2
src/release_memory.c

@@ -32,16 +32,24 @@
 #include <assert.h>
 
 void release_memory(raw_block_header_t *raw_block) {
+#ifdef WITH_DEBUG
     int error_code;
+#endif /* WITH_DEBUG */
 
     size_t pagesize = (size_t) sysconf(_SC_PAGESIZE);
     size_t padding = (uintptr_t) raw_block % pagesize;
 
     if(padding != 0) {
-        error_code = munmap((void *) ((uintptr_t) raw_block - padding),
+#ifdef WITH_DEBUG
+        error_code =
+#endif /* WITH_DEBUG */
+            munmap((void *) ((uintptr_t) raw_block - padding),
                     raw_block->size + padding);
     } else {
-        error_code = munmap((void *)raw_block, raw_block->size);
+#ifdef WITH_DEBUG
+        error_code =
+#endif /* WITH_DEBUG */
+            munmap((void *)raw_block, raw_block->size);
     }
     assert(error_code == 0);
 }