Use memset instead of a for loop
authorThomas White <taw@bitwiz.org.uk>
Sun, 8 Nov 2009 21:51:44 +0000 (22:51 +0100)
committerThomas White <taw@bitwiz.org.uk>
Sun, 8 Nov 2009 21:51:44 +0000 (22:51 +0100)
gdrm-kms-addfb.c

index 5002932..765495f 100644 (file)
@@ -146,12 +146,17 @@ int main(int argc, char **argv)
        do {
 
                uint16_t val;
+               uint8_t expected[OBJECT_SIZE];
 
+               /* Write to object */
                val = random() & 0xff;
-               val += (random() & 0xff)<<8;
-               for ( i=0; i<OBJECT_SIZE/2; i++ ) {
-                       addr16[i] = val;
-               }
+               memset(addr, val, OBJECT_SIZE);
+
+               /* Write to test buffer */
+               memset(expected, val, OBJECT_SIZE);
+
+               /* Test */
+               assert(memcmp(addr, expected, OBJECT_SIZE) == 0);
 
                printf("Press <enter> to continue, q<enter> to finish...");
                fgets(tmp, 3, stdin);