ltp-aiodio: Move code & fix warnings
PATCH 1/1 ltp-aiodio: Move code & fix warnings
* Move check_zero() function to a common header
* Fix printf() format warnings in that funcition
Signed-off-by Cyril Hrubis <[email protected]>
--- testcases/kernel/io/ltp-aiodio/aiodio_append.c | 23 +----------- testcases/kernel/io/ltp-aiodio/common_checkzero.h | 45 +++++++++++++++++++++++ testcases/kernel/io/ltp-aiodio/common_sparse.h | 28 ++------------ testcases/kernel/io/ltp-aiodio/dio_append.c | 23 +----------- testcases/kernel/io/ltp-aiodio/read_checkzero.c | 23 +----------- 5 files changed, 52 insertions(+), 90 deletions(-) create mode 100644 testcases/kernel/io/ltp-aiodio/common_checkzero.h
testcases/kernel/io/ltp-aiodio/aiodio_append.c +1 -22
@@ -38,28 +38,7 @@#define NUM_CHILDREN 8 -char *check_zero (unsigned char *buf,int size) -{ -unsigned char *p; - - p = buf; - -while (size >0 ) { -if (*buf !=0 ) { -fprintf (stderr, -"non zero buffer at buf[%d] => 0x%02x,%02x,%02x,%02x\n" , - buf - p, (unsigned int )buf[0 ], - size >1 ? (unsigned int )buf[1 ] :0 , - size >2 ? (unsigned int )buf[2 ] :0 , - size >3 ? (unsigned int )buf[3 ] :0 ); -fprintf (stderr,"buf %p, p %p\n" , buf, p); -return buf; - } - buf++; - size--; - } -return 0 ;/* all zeros */ -} +#include "common_checkzero.h" int read_eof (char *filename) {
testcases/kernel/io/ltp-aiodio/common_checkzero.h new file +45 -0
45 lines not on this page · raw message
testcases/kernel/io/ltp-aiodio/common_sparse.h +4 -24
@@ -19,6 +19,8 @@#ifndef LTP_AIODIO_COMMON_SPARSE #define LTP_AIODIO_COMMON_SPARSE +#include "common_checkzero.h" +/* * This code tries to create dirty free blocks on * the HDD so there is a chance that blocks to be allocated
@@ -77,28 +79,6 @@ long long scale_by_kmg(long long value, char scale)return value; } -char *check_zero (char *buf,int size) -{ -char *p; - - p = buf; - -while (size >0 ) { -if (*buf !=0 ) { -fprintf (stderr,"non zero buffer at buf[%d] => 0x%02x,%02x,%02x,%02x\n" , - buf - p, (unsigned int )buf[0 ], - size >1 ? (unsigned int )buf[1 ] :0 , - size >2 ? (unsigned int )buf[2 ] :0 , - size >3 ? (unsigned int )buf[3 ] :0 ); -return buf; - } - buf++; - size--; - } - -return NULL ; -} -/* * Make sure we read only zeroes, * either there is a hole in the file,
@@ -134,8 +114,8 @@ static void read_sparse(char *filename, int filesize) r =read (fd, buf,sizeof (buf));if (r >0 ) {if ((badbuf =check_zero (buf, r))) { -fprintf (stderr,"non-zero read at offset %d\n" , - offset + badbuf - buf); +fprintf (stderr,"non-zero read at offset %u\n" , + (unsigned int )(offset + badbuf - buf));exit (10 ); } }
testcases/kernel/io/ltp-aiodio/dio_append.c +1 -22
@@ -45,28 +45,7 @@#include "test.h" #define NUM_CHILDREN 8 -char *check_zero (unsigned char *buf,int size) -{ -unsigned char *p; - - p = buf; - -while (size >0 ) { -if (*buf !=0 ) { -fprintf (stderr, -"non zero buffer at buf[%d] => 0x%02x,%02x,%02x,%02x\n" , - buf - p, (unsigned int )buf[0 ], - size >1 ? (unsigned int )buf[1 ] :0 , - size >2 ? (unsigned int )buf[2 ] :0 , - size >3 ? (unsigned int )buf[3 ] :0 ); -fprintf (stderr,"buf %p, p %p\n" , buf, p); -return buf; - } - buf++; - size--; - } -return 0 ;/* all zeros */ -} +#include "common_checkzero.h" int read_eof (char *filename) {
testcases/kernel/io/ltp-aiodio/read_checkzero.c +1 -22
@@ -33,28 +33,7 @@#include <stdio.h> #include <unistd.h> -char *check_zero (unsigned char *buf,int size) -{ -unsigned char *p; - - p = buf; - -while (size >0 ) { -if (*buf !=0 ) { -fprintf (stderr, -"non zero buffer at buf[%d] => 0x%02x,%02x,%02x,%02x\n" , - buf - p, (unsigned int )buf[0 ], - size >1 ? (unsigned int )buf[1 ] :0 , - size >2 ? (unsigned int )buf[2 ] :0 , - size >3 ? (unsigned int )buf[3 ] :0 ); -fprintf (stderr,"buf %p, p %p\n" , buf, p); -return buf; - } - buf++; - size--; - } -return 0 ;/* all zeros */ -} +#include "common_checkzero.h" int read_eof (char *filename) {
Signature · 1 line
2.10.2