From: Arshad Hussain Date: Sun, 29 Sep 2019 15:34:37 +0000 (+0530) Subject: LU-6142 tests: Fix style issues for write_time_limit.c X-Git-Tag: 2.13.51~168 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=3cdaf5260440df5c9724a217f1d16fed455e3ee3 LU-6142 tests: Fix style issues for write_time_limit.c This patch fixes issues reported by checkpatch for file lustre/tests/write_time_limit.c Test-Parameters: trivial testlist=sanity-sec Signed-off-by: Arshad Hussain Change-Id: Id55ff1de3a4c05f04ebe446bfa394d9d0e32997c Reviewed-on: https://review.whamcloud.com/36390 Reviewed-by: Shaun Tancheff Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Ben Evans Reviewed-by: Petros Koutoupis Reviewed-by: James Simmons --- diff --git a/lustre/tests/write_time_limit.c b/lustre/tests/write_time_limit.c index a18d259..6384cf2 100644 --- a/lustre/tests/write_time_limit.c +++ b/lustre/tests/write_time_limit.c @@ -57,59 +57,62 @@ void catch_alarm(int sig) int main(int argc, char **argv) { - char *file; - unsigned char buf[BUFFERSIZE]; - int fd, i, rc; + char *file; + unsigned char buf[BUFFERSIZE]; + int fd, i, rc; unsigned int test_time; - mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH; - if (argc != 3) { - printf("Invalid number of arguments.\n"); - printf("Usage %s \n", argv[0]); - return -1; - } + mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH; - file = argv[1]; - test_time = atoi(argv[2]); + if (argc != 3) { + printf("Invalid number of arguments.\n"); + printf("Usage %s \n", argv[0]); + return -1; + } + + file = argv[1]; + test_time = atoi(argv[2]); /* Establish a handler for SIGALRM signals. */ signal(SIGALRM, catch_alarm); - /* Set an alarm to go off in a little while. */ - alarm(test_time); + /* Set an alarm to go off in a little while. */ + alarm(test_time); - fd = open(file, O_RDWR|O_TRUNC|O_CREAT|O_SYNC|O_LARGEFILE, mode); - if (fd < 0) { - fprintf(stderr, "Error: Cannot open file named "); - perror(file); - return -1; - } + fd = open(file, O_RDWR | O_TRUNC | O_CREAT | O_SYNC | O_LARGEFILE, + mode); + if (fd < 0) { + fprintf(stderr, "Error: Cannot open file named "); + perror(file); + return -1; + } - memset(buf, 1, BUFFERSIZE); + memset(buf, 1, BUFFERSIZE); while (keep_going) { - for (i = 0; i < 1024; i++) { - rc = write(fd, buf, BUFFERSIZE); + for (i = 0; i < 1024; i++) { + rc = write(fd, buf, BUFFERSIZE); if (rc < 0) { - fprintf(stderr, "Error: Write error "); - perror(file); + fprintf(stderr, "Error: Write error "); + perror(file); exit(-1); - } else if (rc != BUFFERSIZE) { - fprintf(stderr, "Error: Ddidn't write all data \n"); + } else if (rc != BUFFERSIZE) { + fprintf(stderr, + "Error: Ddidn't write all data\n"); } - } + } - if (ftruncate(fd, 0) < 0) { - fprintf(stderr, "Error: Truncate error "); - perror(file); + if (ftruncate(fd, 0) < 0) { + fprintf(stderr, "Error: Truncate error "); + perror(file); exit(-1); - } - } + } + } - if (close(fd) < 0) { - fprintf(stderr, "Error: Cannot close "); - perror(file); - return -1; - } + if (close(fd) < 0) { + fprintf(stderr, "Error: Cannot close "); + perror(file); + return -1; + } - return 0; + return 0; }