Hi,

Some more cleanup on top of my previous patch with e-mail subject
"libssl pqueue minor cleanup" - no functional change intended.

Patches can be applied in this order (top is first):

* pqueue-nomagic.diff
* pqueue-simplify-pqueue-find.diff
* pqueue-remove-dead-code.diff
Index: pqueue.c
===================================================================
RCS file: /cvs/src/lib/libssl/src/crypto/pqueue/pqueue.c,v
retrieving revision 1.4
diff -u -p -r1.4 pqueue.c
--- pqueue.c    27 Apr 2014 20:20:59 -0000      1.4
+++ pqueue.c    28 Apr 2014 23:55:34 -0000
@@ -126,7 +126,8 @@ pqueue_insert(pqueue_s *pq, pitem *item)
            curr = next, next = next->next) {
                /* we can compare 64-bit value in big-endian encoding
                 * with memcmp:-) */
-               int cmp = memcmp(next->priority, item->priority, 8);
+               int cmp = memcmp(next->priority, item->priority,
+                                sizeof(item->priority));
                if (cmp > 0)            /* next > item */
                {
                        item->next = next;
Index: pqueue.c
===================================================================
RCS file: /cvs/src/lib/libssl/src/crypto/pqueue/pqueue.c,v
retrieving revision 1.4
diff -u -p -r1.4 pqueue.c
--- pqueue.c    27 Apr 2014 20:20:59 -0000      1.4
+++ pqueue.c    28 Apr 2014 23:58:08 -0000
@@ -173,18 +173,14 @@ pqueue_find(pqueue_s *pq, unsigned char 
        if (pq->items == NULL)
                return NULL;
 
-       for (next = pq->items; next->next != NULL; next = next->next) {
+       for (next = pq->items; next != NULL; next = next->next) {
                if (memcmp(next->priority, prio64be, 8) == 0) {
                        found = next;
                        break;
                }
        }
 
-       /* check the one last node */
-       if (memcmp(next->priority, prio64be, 8) ==0)
-               found = next;
-
-       if (! found)
+       if (!found)
                return NULL;
 
 #if 0 /* find works in peek mode */
Index: pqueue.c
===================================================================
RCS file: /cvs/src/lib/libssl/src/crypto/pqueue/pqueue.c,v
retrieving revision 1.4
diff -u -p -r1.4 pqueue.c
--- pqueue.c    27 Apr 2014 20:20:59 -0000      1.4
+++ pqueue.c    28 Apr 2014 23:59:50 -0000
@@ -187,13 +187,6 @@ pqueue_find(pqueue_s *pq, unsigned char 
        if (! found)
                return NULL;
 
-#if 0 /* find works in peek mode */
-       if (prev == NULL)
-               pq->items = next->next;
-       else
-               prev->next = next->next;
-#endif
-
        return found;
 }
 

Reply via email to