Suren A. Chilingaryan пре 13 година
родитељ
комит
33edd4a542
1 измењених фајлова са 17 додато и 10 уклоњено
  1. 17 10
      tools.c

+ 17 - 10
tools.c

@@ -197,19 +197,26 @@ void *pcilib_datacpy32(void * dst, void const * src, uint8_t size, size_t n, pci
     uint32_t const * plSrc = (uint32_t const *) src;
 
     int swap = 0;
-    
-    if (endianess) swap = (endianess == PCILIB_BIG_ENDIAN)?(ntohs(1)!=1):(ntohs(1)==1);
-
-    assert(size == 4);	// only 32 bit at the moment
 
-    while (n > 0) {
-	if (swap) *plDst = ntohl(*plSrc);
-	else *plDst = *plSrc;
+    if (endianess) 
+        swap = (endianess == PCILIB_BIG_ENDIAN)?(ntohs(1)!=1):(ntohs(1)==1);
 
-        ++plSrc;
-        ++plDst;
+    assert(size == 4);	// only 32 bit at the moment
 
-        --n;
+    if (swap) {
+        while (n > 0) {
+            *plDst = ntohl(*plSrc);
+            ++plSrc;
+            ++plDst;
+            --n;
+        }
+    } else {
+        while (n > 0) {
+            *plDst = *plSrc;
+            ++plSrc;
+            ++plDst;
+            --n;
+        }
     }
 }