From d0d2b6362d2b29df981474e528131fe3111263fd Mon Sep 17 00:00:00 2001 From: Andi Shyti Date: Wed, 14 Dec 2016 22:01:02 +0900 Subject: is: use sizeof() to calculate the size instead of hardcoding the size Signed-off-by: Andi Shyti --- is.c | 8 +++----- 1 file 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 #include -#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 { -- cgit v1.2.3