summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndi Shyti <andi.shyti@samsung.com>2016-12-14 22:01:02 +0900
committerAndi Shyti <andi.shyti@samsung.com>2016-12-14 22:01:02 +0900
commitd0d2b6362d2b29df981474e528131fe3111263fd (patch)
treed8a6c3d97571309e795dc1a8ce975528ab6ababe
parentd320de7a5d67743437a1c71d9c7144478a0e09f8 (diff)
is: use sizeof() to calculate the size instead of hardcoding the size
Signed-off-by: Andi Shyti <andi.shyti@samsung.com>
-rw-r--r--is.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/is.c b/is.c
index 1f9b0c0..8358a05 100644
--- a/is.c
+++ b/is.c
@@ -5,8 +5,6 @@
#include <sys/ioctl.h>
#include <unistd.h>
-#define DSIZE 67
-
/*
unsigned int b[DSIZE] = { 0xab, 0xab, 16, 40, 16, 40, 16, 40,
16, 15, 16, 15, 16, 14, 16, 15,
@@ -20,7 +18,7 @@ unsigned int b[DSIZE] = { 0xab, 0xab, 16, 40, 16, 40, 16, 40,
};
*/
-unsigned int b[DSIZE] = { 171, 171, 22, 64, 22, 64, 22, 64,
+unsigned int b[67] = { 171, 171, 22, 64, 22, 64, 22, 64,
22, 21, 22, 21, 22, 20, 22, 21,
22, 21, 22, 64, 22, 64, 22, 64,
22, 21, 22, 21, 22, 21, 22, 21,
@@ -58,11 +56,11 @@ int main(void)
return -1;
}
- n = write(fd, b, DSIZE * sizeof(unsigned int));
+ n = write(fd, b, sizeof(b));
if (n < 0) {
fprintf(stderr, "unable to write to the device\n");
ret = -1;
- } else if (n != DSIZE) {
+ } else if (n != sizeof(b)) {
fprintf(stderr, "failed to write everything, wrote %ld instead\n", n);
ret = -1;
} else {