jiridanek commented on a change in pull request #1015:
URL: https://github.com/apache/qpid-dispatch/pull/1015#discussion_r569183788



##########
File path: src/alloc_pool.c
##########
@@ -435,7 +437,8 @@ void qd_dealloc(qd_alloc_type_desc_t *desc, qd_alloc_pool_t 
**tpool, char *p)
     assert (desc->header  == PATTERN_FRONT);
     assert (desc->trailer == PATTERN_BACK);
     assert (item->header  == PATTERN_FRONT);
-    assert (*((uint32_t*) (p + desc->total_size)) == PATTERN_BACK);
+    const uint32_t pb = PATTERN_BACK;

Review comment:
       ```
   /home/travis/build/apache/qpid-dispatch/src/alloc_pool.c:440:20: error: 
unused variable 'pb' [-Werror,-Wunused-variable]
   
       const uint32_t pb = PATTERN_BACK;
   ```

##########
File path: src/alloc_pool.c
##########
@@ -435,7 +437,8 @@ void qd_dealloc(qd_alloc_type_desc_t *desc, qd_alloc_pool_t 
**tpool, char *p)
     assert (desc->header  == PATTERN_FRONT);
     assert (desc->trailer == PATTERN_BACK);
     assert (item->header  == PATTERN_FRONT);
-    assert (*((uint32_t*) (p + desc->total_size)) == PATTERN_BACK);
+    const uint32_t pb = PATTERN_BACK;
+    assert (memcmp(p + desc->total_size, &pb, sizeof(pb)) == 0);

Review comment:
       I imagine Coverity will scream about this. Memcpy has side-efects and it 
is being used in an assert.

##########
File path: src/alloc_pool.c
##########
@@ -435,7 +437,8 @@ void qd_dealloc(qd_alloc_type_desc_t *desc, qd_alloc_pool_t 
**tpool, char *p)
     assert (desc->header  == PATTERN_FRONT);
     assert (desc->trailer == PATTERN_BACK);
     assert (item->header  == PATTERN_FRONT);
-    assert (*((uint32_t*) (p + desc->total_size)) == PATTERN_BACK);
+    const uint32_t pb = PATTERN_BACK;

Review comment:
       (That's because the next line is an assert, so it may not be always 
compiled in...)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to