EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: [PATCH 4/4] Drive-by refactoring in caserverio.c
From: Michael Abbott <[email protected]>
To: undisclosed-recipients:;
Date: Wed, 2 Jun 2010 10:11:58 +0100
Minor refactoring of code block in cas_copy_in_header() to gather
common header code.

Signed-off-by: Michael Abbott <[email protected]>
---
 src/rsrv/caserverio.c |   41 +++++++++++++++++------------------------
 1 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/src/rsrv/caserverio.c b/src/rsrv/caserverio.c
index 4d8b773..a073f42 100644
--- a/src/rsrv/caserverio.c
+++ b/src/rsrv/caserverio.c
@@ -292,32 +292,25 @@ int cas_copy_in_header (
         }
     }
 
-    if ( alignedPayloadSize < 0xffff && nElem < 0xffff ) {
-        caHdr *pMsg = ( caHdr * ) &pclient->send.buf[pclient->send.stk];        
-        pMsg->m_cmmd = htons ( response );   
-        pMsg->m_postsize = htons ( ( ( ca_uint16_t ) alignedPayloadSize ) ); 
-        pMsg->m_dataType = htons ( dataType );  
-        pMsg->m_count = htons ( ( ( ca_uint16_t ) nElem ) );      
-        pMsg->m_cid = htonl ( cid );          
-        pMsg->m_available = htonl ( responseSpecific );  
-        if ( ppPayload ) {
-            *ppPayload = ( void * ) ( pMsg + 1 );
-        }
+    caHdr *pMsg = (caHdr *) &pclient->send.buf[pclient->send.stk];
+    pMsg->m_cmmd = htons(response);
+    pMsg->m_dataType = htons(dataType);
+    pMsg->m_cid = htonl(cid);
+    pMsg->m_available = htonl(responseSpecific);
+    if (alignedPayloadSize < 0xffff && nElem < 0xffff) {
+        pMsg->m_postsize = htons(((ca_uint16_t) alignedPayloadSize));
+        pMsg->m_count = htons(((ca_uint16_t) nElem));
+        if (ppPayload)
+            *ppPayload = (void *) (pMsg + 1);
     }
     else {
-        caHdr *pMsg = ( caHdr * ) &pclient->send.buf[pclient->send.stk];
-        ca_uint32_t *pW32 = ( ca_uint32_t * ) ( pMsg + 1 );
-        pMsg->m_cmmd = htons ( response );   
-        pMsg->m_postsize = htons ( 0xffff ); 
-        pMsg->m_dataType = htons ( dataType );  
-        pMsg->m_count = htons ( 0u );      
-        pMsg->m_cid = htonl ( cid );          
-        pMsg->m_available = htonl ( responseSpecific ); 
-        pW32[0] = htonl ( alignedPayloadSize );
-        pW32[1] = htonl ( nElem );
-        if ( ppPayload ) {
-            *ppPayload = ( void * ) ( pW32 + 2 );
-        }
+        ca_uint32_t *pW32 = (ca_uint32_t *) (pMsg + 1);
+        pMsg->m_postsize = htons(0xffff);
+        pMsg->m_count = htons(0u);
+        pW32[0] = htonl(alignedPayloadSize);
+        pW32[1] = htonl(nElem);
+        if (ppPayload)
+            *ppPayload = (void *) (pW32 + 2);
     }
 
     /* zero out pad bytes */
-- 
1.6.6.1


References:
[PATCH 0/4] Adding dynamic arrays to EPICS Channel Access Michael Abbott

Navigate by Date:
Prev: [PATCH 2/4] Update rsrv to support V4.12 protocol extension. Michael Abbott
Next: EPICS protocol header Michael Abbott
Index: 2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: [PATCH 2/4] Update rsrv to support V4.12 protocol extension. Michael Abbott
Next: [PATCH 3/4] Add autosizing array support for caget and camonitor. Michael Abbott
Index: 2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·