Print this page
5083 avoid undefined order of operations in assignments

@@ -22,12 +22,10 @@
 /*
  * Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
-#pragma ident   "%Z%%M% %I%     %E% SMI"
-
 /*
  * smq.c: to provide a message queue system for scadm functions (used in the
  * firmware download context where BP messages, received from the service
  * processor, are stored in the message queue)
  *

@@ -89,12 +87,11 @@
                 return (SMQ_ERROR);
 
         /* Copy messaged into queue */
         *msg = *smq->smq_head;
 
-        /* Increment Head */
-        smq->smq_head = smq->smq_head++;
+        smq->smq_head++;
         if ((unsigned long)smq->smq_head > ((unsigned long)smq->smq_msgBuffer +
             (unsigned long)(smq->smq_depth * sizeof (smq_msg_t)))) {
                 smq->smq_head = smq->smq_msgBuffer;
         }
         smq->smq_count--;

@@ -113,12 +110,11 @@
                 return (SMQ_FULL);
 
         /* Copy messaged into queue */
         *smq->smq_tail = *msg;
 
-        /* Increment Tail */
-        smq->smq_tail = smq->smq_tail++;
+        smq->smq_tail++;
         if ((unsigned long)smq->smq_tail > ((unsigned long)smq->smq_msgBuffer +
             (unsigned long)(smq->smq_depth * sizeof (smq_msg_t)))) {
                 smq->smq_tail = smq->smq_msgBuffer;
         }
 

@@ -173,12 +169,11 @@
                 return (SMQ_ERROR);
 
         /* Copy messaged into queue */
         *msg = *smq->smq_head;
 
-        /* Increment Head */
-        smq->smq_head = smq->smq_head++;
+        smq->smq_head++;
         if ((unsigned long)smq->smq_head > ((unsigned long)smq->smq_msgBuffer +
             (unsigned long)(smq->smq_depth * sizeof (smq_msg_t)))) {
                 smq->smq_head = smq->smq_msgBuffer;
         }
         smq->smq_count--;