diff options
-rw-r--r-- | lib/dataascii.c | 26 | ||||
-rw-r--r-- | lib/databin.c | 26 | ||||
-rw-r--r-- | lib/datapid.c | 28 | ||||
-rw-r--r-- | lib/file_lock.c | 16 | ||||
-rw-r--r-- | lib/forker.c | 32 | ||||
-rw-r--r-- | lib/open_flags.c | 30 | ||||
-rw-r--r-- | lib/parse_opts.c | 170 | ||||
-rw-r--r-- | lib/random_range.c | 94 | ||||
-rw-r--r-- | lib/rmobj.c | 42 | ||||
-rw-r--r-- | lib/search_path.c | 38 | ||||
-rw-r--r-- | lib/str_to_bytes.c | 8 | ||||
-rw-r--r-- | lib/string_to_tokens.c | 8 | ||||
-rw-r--r-- | lib/tlibio.c | 352 | ||||
-rw-r--r-- | lib/tst_res.c | 2 | ||||
-rw-r--r-- | lib/tst_tmpdir.c | 36 | ||||
-rw-r--r-- | lib/write_log.c | 14 | ||||
-rw-r--r-- | pan/debug.c | 10 | ||||
-rw-r--r-- | pan/debug.h | 8 | ||||
-rw-r--r-- | pan/ltp-bump.c | 2 | ||||
-rw-r--r-- | pan/ltp-pan.c | 22 | ||||
-rw-r--r-- | pan/reporter.c | 30 | ||||
-rw-r--r-- | pan/splitstr.c | 34 | ||||
-rw-r--r-- | pan/symbol.c | 94 | ||||
-rw-r--r-- | pan/tag_report.c | 96 | ||||
-rw-r--r-- | pan/zoolib.c | 16 |
25 files changed, 617 insertions, 617 deletions
diff --git a/lib/dataascii.c b/lib/dataascii.c index 775eb48de..5bba30b14 100644 --- a/lib/dataascii.c +++ b/lib/dataascii.c @@ -59,7 +59,7 @@ int offset; chr=buffer; total=offset+bsize; - if ( listofchars == NULL ) { + if (listofchars == NULL) { charlist=CHARS; chars_size=CHARS_SIZE; } @@ -68,7 +68,7 @@ int offset; chars_size=strlen(listofchars); } - for(cnt=offset; cnt<total; cnt++) { + for (cnt=offset; cnt<total; cnt++) { ind=cnt%chars_size; *chr++=charlist[ind]; } @@ -95,7 +95,7 @@ char **errmsg; chr=buffer; total=offset+bsize; - if ( listofchars == NULL ) { + if (listofchars == NULL) { charlist=CHARS; chars_size=CHARS_SIZE; } @@ -104,13 +104,13 @@ char **errmsg; chars_size=strlen(listofchars); } - if ( errmsg != NULL ) { + if (errmsg != NULL) { *errmsg = Errmsg; } - for(cnt=offset; cnt<total; chr++, cnt++) { + for (cnt=offset; cnt<total; chr++, cnt++) { ind=cnt%chars_size; - if ( *chr != charlist[ind] ) { + if (*chr != charlist[ind]) { sprintf(Errmsg, "data mismatch at offset %d, exp:%#o, act:%#o", cnt, charlist[ind], *chr); @@ -140,7 +140,7 @@ char *buffer; int ret; char *errmsg; - if ((buffer=(char *)malloc(size)) == NULL ) { + if ((buffer=(char *)malloc(size)) == NULL) { perror("malloc"); exit(2); } @@ -152,7 +152,7 @@ char *errmsg; printf("dataasciichk(NULL, buffer, %d, 0, &errmsg) returned %d %s\n", size, ret, errmsg); - if ( ret == -1 ) + if (ret == -1) printf("\tPASS return value is -1 as expected\n"); else printf("\tFAIL return value is %d, expected -1\n", ret); @@ -161,7 +161,7 @@ char *errmsg; printf("dataasciichk(NULL, &buffer[1], %d, 1, &errmsg) returned %d %s\n", size-1, ret, errmsg); - if ( ret == -1 ) + if (ret == -1) printf("\tPASS return value is -1 as expected\n"); else printf("\tFAIL return value is %d, expected -1\n", ret); @@ -173,7 +173,7 @@ char *errmsg; printf("dataasciichk(NULL, &buffer[1], %d, 1, &errmsg) returned %d %s\n", size-1, ret, errmsg); - if ( ret == 25 ) + if (ret == 25) printf("\tPASS return value is 25 as expected\n"); else printf("\tFAIL return value is %d, expected 25\n", ret); @@ -185,7 +185,7 @@ char *errmsg; printf("dataasciichk(\"this is a test of the my string\", buffer, %d, 0, &errmsg) returned %d %s\n", size, ret, errmsg); - if ( ret == -1 ) + if (ret == -1) printf("\tPASS return value is -1 as expected\n"); else printf("\tFAIL return value is %d, expected -1\n", ret); @@ -194,7 +194,7 @@ char *errmsg; printf("dataasciichk(\"this is a test of the my string\", &buffer[1], %d, 1, &errmsg) returned %d %s\n", size-1, ret, errmsg); - if ( ret == -1 ) + if (ret == -1) printf("\tPASS return value is -1 as expected\n"); else printf("\tFAIL return value is %d, expected -1\n", ret); @@ -206,7 +206,7 @@ char *errmsg; printf("dataasciichk(\"this is a test of the my string\", &buffer[1], %d, 1, &errmsg) returned %d %s\n", size-1, ret, errmsg); - if ( ret == 25 ) + if (ret == 25) printf("\tPASS return value is 25 as expected\n"); else printf("\tFAIL return value is %d, expected 25\n", ret); diff --git a/lib/databin.c b/lib/databin.c index 2017cb72b..95649a6f1 100644 --- a/lib/databin.c +++ b/lib/databin.c @@ -105,7 +105,7 @@ char **errmsg; chr=buffer; total=bsize; - if ( errmsg != NULL ) { + if (errmsg != NULL) { *errmsg = Errmsg; } @@ -124,7 +124,7 @@ char **errmsg; for (cnt=0;cnt< bsize;cnt++) { expbits = ((offset+cnt)%8 & 0177); - if ( buffer[cnt] != expbits ) { + if (buffer[cnt] != expbits) { sprintf(Errmsg, "data mismatch at offset %d, exp:%#lo, act:%#o", offset+cnt, expbits, buffer[cnt]); @@ -149,7 +149,7 @@ char **errmsg; for (cnt=0; cnt<bsize; chr++, cnt++) { actbits = (long)*chr; - if ( actbits != expbits ) { + if (actbits != expbits) { sprintf(Errmsg, "data mismatch at offset %d, exp:%#lo, act:%#lo", offset+cnt, expbits, actbits); return offset+cnt; @@ -178,7 +178,7 @@ char **ag; int ret; char *errmsg; - if ((buffer=(unsigned char *)malloc(size)) == NULL ) { + if ((buffer=(unsigned char *)malloc(size)) == NULL) { perror("malloc"); exit(2); } @@ -191,7 +191,7 @@ printf("***** for a ****************************\n"); ret=databinchk('a', buffer, size, 0, &errmsg); printf("databinchk('a', buffer, %d, 0, &errmsg) returned %d: %s\n", size, ret, errmsg); - if ( ret == -1 ) + if (ret == -1) printf("\tPASS return value of -1 as expected\n"); else printf("\tFAIL return value %d, expected -1\n", ret); @@ -200,7 +200,7 @@ printf("***** for a ****************************\n"); ret=databinchk('a', &buffer[1], size-1, offset, &errmsg); printf("databinchk('a', &buffer[1], %d, %d, &errmsg) returned %d: %s\n", size, offset, ret, errmsg); - if ( ret == -1 ) + if (ret == -1) printf("\tPASS return value of -1 as expected\n"); else printf("\tFAIL return value %d, expected -1\n", ret); @@ -212,7 +212,7 @@ printf("***** for a ****************************\n"); ret=databinchk('a', &buffer[1], size-1, offset+1, &errmsg); printf("databinchk('a', &buffer[1], %d, %d, &errmsg) returned %d: %s\n", size-1, offset+1, ret, errmsg); - if ( ret == number ) + if (ret == number) printf("\tPASS return value of %d as expected\n", number); else printf("\tFAIL return value %d, expected %d\n", ret, number); @@ -226,7 +226,7 @@ printf("***** for c ****************************\n"); ret=databinchk('c', buffer, size, 0, &errmsg); printf("databinchk('c', buffer, %d, 0, &errmsg) returned %d: %s\n", size, ret, errmsg); - if ( ret == -1 ) + if (ret == -1) printf("\tPASS return value of -1 as expected\n"); else printf("\tFAIL return value %d, expected -1\n", ret); @@ -235,7 +235,7 @@ printf("***** for c ****************************\n"); ret=databinchk('c', &buffer[1], size-1, offset, &errmsg); printf("databinchk('c', &buffer[1], %d, %d, &errmsg) returned %d: %s\n", size, offset, ret, errmsg); - if ( ret == -1 ) + if (ret == -1) printf("\tPASS return value of -1 as expected\n"); else printf("\tFAIL return value %d, expected -1\n", ret); @@ -247,7 +247,7 @@ printf("***** for c ****************************\n"); ret=databinchk('c', &buffer[1], size-1, offset+1, &errmsg); printf("databinchk('c', &buffer[1], %d, %d, &errmsg) returned %d: %s\n", size-1, offset+1, ret, errmsg); - if ( ret == number ) + if (ret == number) printf("\tPASS return value of %d as expected\n", number); else printf("\tFAIL return value %d, expected %d\n", ret, number); @@ -260,7 +260,7 @@ printf("***** for C ****************************\n"); ret=databinchk('C', buffer, size, 0, &errmsg); printf("databinchk('C', buffer, %d, 0, &errmsg) returned %d: %s\n", size, ret, errmsg); - if ( ret == -1 ) + if (ret == -1) printf("\tPASS return value of -1 as expected\n"); else printf("\tFAIL return value %d, expected -1\n", ret); @@ -269,7 +269,7 @@ printf("***** for C ****************************\n"); ret=databinchk('C', &buffer[18], size-18, 18, &errmsg); printf("databinchk('C', &buffer[18], %d, 18, &errmsg) returned %d: %s\n", size-18, ret, errmsg); - if ( ret == -1 ) + if (ret == -1) printf("\tPASS return value of -1 as expected\n"); else printf("\tFAIL return value %d, expected -1\n", ret); @@ -283,7 +283,7 @@ printf("***** for C ****************************\n"); printf("databinchk('C', &buffer[18], %d, 18, &errmsg) returned %d: %s\n", size-18, ret, errmsg); - if ( ret == 20 || ret == 21 ) + if (ret == 20 || ret == 21) printf("\tPASS return value of %d or %d as expected\n", 20, 21); else diff --git a/lib/datapid.c b/lib/datapid.c index c047792e0..bc4ec710d 100644 --- a/lib/datapid.c +++ b/lib/datapid.c @@ -103,7 +103,7 @@ int offset; num_full_words = bsize/NBPW; boff = 0; - if ( cnt=(offset % NBPW) ) { /* partial word */ + if (cnt=(offset % NBPW)) { /* partial word */ woff = offset - cnt; #if DEBUG @@ -131,12 +131,12 @@ printf("partial at beginning, cnt = %d, woff = %d\n", cnt, woff); woff = offset+boff; - for (cnt=0; cnt<num_full_words; woff += NBPW, cnt++ ) { + for (cnt=0; cnt<num_full_words; woff += NBPW, cnt++) { word = ((LOWER16BITS(pid) << 48) | (LOWER32BITS(woff) << 16) | LOWER16BITS(pid)); chr = (char *)&word; - for(tmp=0; tmp<NBPW; tmp++, chr++) { + for (tmp=0; tmp<NBPW; tmp++, chr++) { buffer[boff++] = *chr; } /****** Only if wptr is a word ellined @@ -151,7 +151,7 @@ printf("partial at beginning, cnt = %d, woff = %d\n", cnt, woff); * partial word at end of buffer */ - if ( cnt=((bsize-boff) % NBPW) ) { + if (cnt=((bsize-boff) % NBPW)) { #if DEBUG printf("partial at end\n"); #endif @@ -197,7 +197,7 @@ char **errmsg; int num_full_words; - if ( errmsg != NULL ) { + if (errmsg != NULL) { *errmsg = Errmsg; } @@ -205,7 +205,7 @@ char **errmsg; num_full_words = bsize/NBPW; boff = 0; - if ( cnt=(offset % NBPW) ) { /* partial word */ + if (cnt=(offset % NBPW)) { /* partial word */ woff = offset - cnt; word = ((LOWER16BITS(pid) << 48) | (LOWER32BITS(woff) << 16) | LOWER16BITS(pid)); @@ -232,12 +232,12 @@ char **errmsg; woff = offset+boff; - for (cnt=0; cnt<num_full_words; woff += NBPW, cnt++ ) { + for (cnt=0; cnt<num_full_words; woff += NBPW, cnt++) { word = ((LOWER16BITS(pid) << 48) | (LOWER32BITS(woff) << 16) | LOWER16BITS(pid)); chr = (char *)&word; - for(tmp=0; tmp<NBPW; tmp++, boff++, chr++) { - if ( buffer[boff] != *chr ) { + for (tmp=0; tmp<NBPW; tmp++, boff++, chr++) { + if (buffer[boff] != *chr) { sprintf(Errmsg, "Data mismatch at offset %d, exp:%#o, act:%#o", woff, *chr, buffer[boff]); return woff; @@ -246,7 +246,7 @@ char **errmsg; /****** only if a word elined wptr = (long *)&buffer[boff]; - if ( *wptr != word ) { + if (*wptr != word) { sprintf(Errmsg, "Data mismatch at offset %d, exp:%#o, act:%#o", woff, word, *wptr); return woff; @@ -259,7 +259,7 @@ char **errmsg; * partial word at end of buffer */ - if ( cnt=((bsize-boff) % NBPW) ) { + if (cnt=((bsize-boff) % NBPW)) { #if DEBUG printf("partial at end\n"); #endif @@ -269,7 +269,7 @@ printf("partial at end\n"); for (tmp=0; tmp<cnt && boff<bsize; boff++, tmp++, chr++) { - if ( buffer[boff] != *chr ) { + if (buffer[boff] != *chr) { sprintf(Errmsg, "Data mismatch at offset %d, exp:%#o, act:%#o", offset+boff, *chr, buffer[boff]); return offset+boff; @@ -282,7 +282,7 @@ printf("partial at end\n"); #else - if ( errmsg != NULL ) { + if (errmsg != NULL) { *errmsg = Errmsg; } sprintf(Errmsg, "Not supported on this OS."); @@ -309,7 +309,7 @@ char *buffer; int ret; char *errmsg; - if ((buffer=(char *)malloc(size)) == NULL ) { + if ((buffer=(char *)malloc(size)) == NULL) { perror("malloc"); exit(2); } diff --git a/lib/file_lock.c b/lib/file_lock.c index 8b66ab584..f0a98f369 100644 --- a/lib/file_lock.c +++ b/lib/file_lock.c @@ -87,7 +87,7 @@ char **errormsg; flocks.l_type = F_RDLCK; else { errno = EINVAL; - if ( errormsg != NULL ) { + if (errormsg != NULL) { sprintf(errmsg, "Programmer error, called file_lock with in valid flags\n"); *errormsg = errmsg; @@ -103,8 +103,8 @@ char **errormsg; while (1) { ret = fcntl(fd, cmd, &flocks); - if ( ret < 0 ) { - if ( cmd == F_SETLK ) + if (ret < 0) { + if (cmd == F_SETLK) switch (errno) { /* these errors are okay */ case EACCES: /* Permission denied */ @@ -115,7 +115,7 @@ char **errormsg; case EFSEXCLWR: /* File is write protected */ continue; /* retry getting lock */ } - if ( errormsg != NULL ) { + if (errormsg != NULL) { sprintf(errmsg, "fcntl(%d, %d, &flocks): errno:%d %s\n", fd, cmd, errno, strerror(errno)); *errormsg = errmsg; @@ -164,7 +164,7 @@ char **errormsg; flocks.l_type = F_RDLCK; else { errno = EINVAL; - if ( errormsg != NULL ) { + if (errormsg != NULL) { sprintf(errmsg, "Programmer error, called record_lock with in valid flags\n"); *errormsg = errmsg; @@ -180,8 +180,8 @@ char **errormsg; while (1) { ret = fcntl(fd, cmd, &flocks); - if ( ret < 0 ) { - if ( cmd == F_SETLK ) + if (ret < 0) { + if (cmd == F_SETLK) switch (errno) { /* these errors are okay */ case EACCES: /* Permission denied */ @@ -192,7 +192,7 @@ char **errormsg; case EFSEXCLWR: /* File is write protected */ continue; /* retry getting lock */ } - if ( errormsg != NULL ) { + if (errormsg != NULL) { sprintf(errmsg, "fcntl(%d, %d, &flocks): errno:%d %s\n", fd, cmd, errno, strerror(errno)); *errormsg = errmsg; diff --git a/lib/forker.c b/lib/forker.c index ad3ffbfe0..84d176f7e 100644 --- a/lib/forker.c +++ b/lib/forker.c @@ -136,7 +136,7 @@ char *prefix; { switch (fork()) { case -1: - if ( prefix != NULL ) + if (prefix != NULL) fprintf(stderr, "%s: In %s background(), fork() failed, errno:%d %s\n", prefix, __FILE__, errno, strerror(errno)); exit(errno); @@ -170,12 +170,12 @@ char *prefix; /* if ! NULL, an message will be printed to stderr */ Forker_pids[ind]=0; - for ( cnt=1; cnt < ncopies; cnt++ ) { + for (cnt=1; cnt < ncopies; cnt++) { switch ( mode ) { case 1 : /* only 1 direct child */ - if ( (pid = fork()) == -1 ) { - if ( prefix != NULL ) + if ((pid = fork()) == -1) { + if (prefix != NULL) fprintf(stderr, "%s: %s,forker(): fork() failed, errno:%d %s\n", prefix, __FILE__, errno, strerror(errno)); return 0; @@ -185,12 +185,12 @@ char *prefix; /* if ! NULL, an message will be printed to stderr */ switch (pid ) { case 0: /* child - continues the forking */ - if ( Forker_npids < FORKER_MAX_PIDS ) + if (Forker_npids < FORKER_MAX_PIDS) Forker_pids[Forker_npids-1]=getpid(); break; default: /* parent - stop the forking */ - if ( Forker_npids < FORKER_MAX_PIDS ) + if (Forker_npids < FORKER_MAX_PIDS) Forker_pids[Forker_npids-1]=pid; return cnt-1; } @@ -198,8 +198,8 @@ char *prefix; /* if ! NULL, an message will be printed to stderr */ break; default : /* all new processes are childern of parent */ - if ( (pid = fork()) == -1 ) { - if ( prefix != NULL ) + if ((pid = fork()) == -1) { + if (prefix != NULL) fprintf(stderr, "%s: %s,forker(): fork() failed, errno:%d %s\n", prefix, __FILE__, errno, strerror(errno)); return cnt-1; @@ -208,12 +208,12 @@ char *prefix; /* if ! NULL, an message will be printed to stderr */ switch (pid ) { case 0: /* child - stops the forking */ - if ( Forker_npids < FORKER_MAX_PIDS ) + if (Forker_npids < FORKER_MAX_PIDS) Forker_pids[Forker_npids-1]=getpid(); return cnt; default: /* parent - continues the forking */ - if ( Forker_npids < FORKER_MAX_PIDS ) + if (Forker_npids < FORKER_MAX_PIDS) Forker_pids[Forker_npids-1]=pid; break; } @@ -221,7 +221,7 @@ char *prefix; /* if ! NULL, an message will be printed to stderr */ } } - if ( Forker_npids < FORKER_MAX_PIDS ) + if (Forker_npids < FORKER_MAX_PIDS) Forker_pids[Forker_npids]=0; return cnt-1; @@ -245,18 +245,18 @@ char **argv; int ret; int ind; - if ( argc == 1 ) { + if (argc == 1) { printf("Usage: %s ncopies [mode]\n", argv[0]); exit(1); } - if ( sscanf(argv[1], "%i", &ncopies) != 1 ) { + if (sscanf(argv[1], "%i", &ncopies) != 1) { printf("%s: ncopies argument must be integer\n", argv[0]); exit(1); } - if ( argc == 3 ) - if ( sscanf(argv[2], "%i", &mode) != 1 ) { + if (argc == 3) + if (sscanf(argv[2], "%i", &mode) != 1) { printf("%s: mode argument must be integer\n", argv[0]); exit(1); } @@ -273,7 +273,7 @@ char **argv; printf("%d My version of Forker_pids[], Forker_npids = %d\n", getpid(), Forker_npids); - for (ind=0; ind<Forker_npids; ind++){ + for (ind=0; ind<Forker_npids; ind++) { printf("%d ind:%-2d pid:%d\n", getpid(), ind, Forker_pids[ind]); } diff --git a/lib/open_flags.c b/lib/open_flags.c index eaa8051f1..6c593aa68 100644 --- a/lib/open_flags.c +++ b/lib/open_flags.c @@ -202,14 +202,14 @@ parse_open_flags(char *string, char **badname) while ( 1 ) { - for(; ((*cc != ',') && (*cc != '\0')); cc++); + for (; ((*cc != ',') && (*cc != '\0')); cc++); savecc = *cc; *cc = '\0'; found = 0; - for(ind=0; ind < sizeof(Open_flags)/sizeof(struct open_flag_t); ind++) { - if ( strcmp(name, Open_flags[ind].symbol) == 0 ) { + for (ind=0; ind < sizeof(Open_flags)/sizeof(struct open_flag_t); ind++) { + if (strcmp(name, Open_flags[ind].symbol) == 0) { bits |= Open_flags[ind].flag; found=1; break; @@ -218,13 +218,13 @@ parse_open_flags(char *string, char **badname) *cc = savecc; /* restore string */ - if ( found == 0 ) { /* invalid name */ - if ( badname != NULL ) + if (found == 0) { /* invalid name */ + if (badname != NULL) *badname = name; return -1; } - if ( savecc == '\0' ) + if (savecc == '\0') break; name = ++cc; @@ -253,7 +253,7 @@ openflags2symbols(int openflags, char *sep, int mode) * bits are not set, assume O_RDONLY. */ - if ( (bits & (O_WRONLY | O_RDWR)) == 0 ) { + if ((bits & (O_WRONLY | O_RDWR)) == 0) { strcat(Open_symbols, "O_RDONLY"); havesome=1; } @@ -261,10 +261,10 @@ openflags2symbols(int openflags, char *sep, int mode) /* * Loop through all but O_RDONLY elments of Open_flags */ - for(ind=1; ind < size; ind++) { + for (ind=1; ind < size; ind++) { - if ( (bits & Open_flags[ind].flag) == Open_flags[ind].flag ) { - if ( havesome ) + if ((bits & Open_flags[ind].flag) == Open_flags[ind].flag) { + if (havesome) strcat(Open_symbols, sep); strcat(Open_symbols, Open_flags[ind].symbol); @@ -279,8 +279,8 @@ openflags2symbols(int openflags, char *sep, int mode) * If not all bits were identified and mode was equal to 1, * added UNKNOWN_SYMBOL to return string */ - if ( bits && mode == 1 ) { /* not all bits were identified */ - if ( havesome ) + if (bits && mode == 1) { /* not all bits were identified */ + if (havesome) strcat(Open_symbols, sep); strcat(Open_symbols, UNKNOWN_SYMBOL); } @@ -306,18 +306,18 @@ char **argv; int ret; char *err; - if (argc == 1 ) { + if (argc == 1) { printf("Usage: %s openflagsbits\n\t%s symbols\n", argv[0], argv[0]); exit(1); } - if ( sscanf(argv[1], "%i", &bits) == 1 ) { + if (sscanf(argv[1], "%i", &bits) == 1) { printf("openflags2symbols(%#o, \",\", 1) returned %s\n", bits, openflags2symbols(bits, ",", 1)); } else { ret=parse_open_flags(argv[1], &err); - if ( ret == -1 ) + if (ret == -1) printf("parse_open_flags(%s, &err) returned -1, err = %s\n", argv[0], err); else diff --git a/lib/parse_opts.c b/lib/parse_opts.c index e4de709a8..0bbeb0385 100644 --- a/lib/parse_opts.c +++ b/lib/parse_opts.c @@ -220,7 +220,7 @@ parse_opts(int ac, char **av, const option_t *user_optarr, void (*uhf)()) * vector. */ - if ( STD_opt_arr != NULL ) { + if (STD_opt_arr != NULL) { free(STD_opt_arr); STD_opt_arr=NULL; } @@ -258,7 +258,7 @@ parse_opts(int ac, char **av, const option_t *user_optarr, void (*uhf)()) /* * Loop through av parsing options. */ - while ( (opt = getopt(ac, av, optionstr)) > 0) { + while ((opt = getopt(ac, av, optionstr)) > 0) { STD_argind = optind; #if DEBUG > 0 @@ -284,7 +284,7 @@ parse_opts(int ac, char **av, const option_t *user_optarr, void (*uhf)()) case 'I': /* Time duration */ options |= OPT_duration; STD_LOOP_DURATION = atof(optarg); - if ( STD_LOOP_DURATION == 0.0 ) STD_INFINITE=1; + if (STD_LOOP_DURATION == 0.0) STD_INFINITE=1; break; case 'c': /* Copies */ options |= OPT_copies; @@ -315,24 +315,24 @@ parse_opts(int ac, char **av, const option_t *user_optarr, void (*uhf)()) /* Check all the user specified options */ found=0; - for(i = 0; user_optarr[i].option; ++i) { + for (i = 0; user_optarr[i].option; ++i) { if (opt == user_optarr[i].option[0]) { /* Yup, This is a user option, set the flag and look for argument */ - if ( user_optarr[i].flag ) { + if (user_optarr[i].flag) { *user_optarr[i].flag=1; } found++; /* save the argument at the user's location */ - if ( user_optarr[i].option[strlen(user_optarr[i].option)-1] == ':' ) { + if (user_optarr[i].option[strlen(user_optarr[i].option)-1] == ':') { *user_optarr[i].arg=optarg; } break; /* option found - break out of the for loop */ } } /* This condition "should never happen". SO CHECK FOR IT!!!! */ - if ( ! found ) { + if (! found) { sprintf(Mesg2, "parse_opts: ERROR - option:\"%c\" NOT FOUND... INTERNAL ERROR", opt); return(Mesg2); @@ -347,11 +347,11 @@ parse_opts(int ac, char **av, const option_t *user_optarr, void (*uhf)()) /* * Turn on debug */ - if ( (ptr=getenv("USC_DEBUG")) != NULL ) { + if ((ptr=getenv("USC_DEBUG")) != NULL) { Debug=1; printf("env USC_DEBUG is defined, turning on debug\n"); } - if ( (ptr=getenv("USC_VERBOSE")) != NULL ) { + if ((ptr=getenv("USC_VERBOSE")) != NULL) { Debug=1; printf("env USC_VERBOSE is defined, turning on debug\n"); } @@ -361,16 +361,16 @@ parse_opts(int ac, char **av, const option_t *user_optarr, void (*uhf)()) * a number, use that number as iteration count (same as -c option). * The -c option with arg will be used even if this env var is set. */ - if ( !(options & OPT_iteration) && (ptr=getenv(USC_ITERATION_ENV)) != NULL ) { - if ( sscanf(ptr, "%i", &k) == 1) { - if ( k == 0 ) { /* if arg is 0, set infinite loop flag */ + if (!(options & OPT_iteration) && (ptr=getenv(USC_ITERATION_ENV)) != NULL) { + if (sscanf(ptr, "%i", &k) == 1) { + if (k == 0) { /* if arg is 0, set infinite loop flag */ STD_INFINITE=1; - if ( Debug ) + if (Debug) printf("Using env %s, set STD_INFINITE to 1\n", USC_ITERATION_ENV); } else { /* else, set the loop count to the arguement */ STD_LOOP_COUNT=k; - if ( Debug ) + if (Debug) printf("Using env %s, set STD_LOOP_COUNT to %d\n", USC_ITERATION_ENV, k); } @@ -381,9 +381,9 @@ parse_opts(int ac, char **av, const option_t *user_optarr, void (*uhf)()) * If the USC_NO_FUNC_CHECK environmental variable is set, we'll * unset the STD_FUNCTIONAL_TEST variable. */ - if ( !(options & OPT_nofunccheck) && (ptr=getenv(USC_NO_FUNC_CHECK)) != NULL ) { + if (!(options & OPT_nofunccheck) && (ptr=getenv(USC_NO_FUNC_CHECK)) != NULL) { STD_FUNCTIONAL_TEST=0; /* Turn off functional testing */ - if ( Debug ) + if (Debug) printf("Using env %s, set STD_FUNCTIONAL_TEST to 0\n", USC_NO_FUNC_CHECK); } @@ -394,27 +394,27 @@ parse_opts(int ac, char **av, const option_t *user_optarr, void (*uhf)()) * The -I option with arg will be used even if this env var is set. */ - if ( !(options & OPT_duration) && (ptr=getenv(USC_LOOP_WALLTIME)) != NULL ) { - if ( sscanf(ptr, "%f", &ftmp) == 1 && ftmp >= 0.0 ) { + if (!(options & OPT_duration) && (ptr=getenv(USC_LOOP_WALLTIME)) != NULL) { + if (sscanf(ptr, "%f", &ftmp) == 1 && ftmp >= 0.0) { STD_LOOP_DURATION=ftmp; - if ( Debug ) + if (Debug) printf("Using env %s, set STD_LOOP_DURATION to %f\n", USC_LOOP_WALLTIME, ftmp); - if ( STD_LOOP_DURATION == 0.0 ) { /* if arg is 0, set infinite loop flag */ + if (STD_LOOP_DURATION == 0.0) { /* if arg is 0, set infinite loop flag */ STD_INFINITE=1; - if ( Debug ) + if (Debug) printf("Using env %s, set STD_INFINITE to 1\n", USC_LOOP_WALLTIME); } } } - if ( !(options & OPT_duration) && (ptr=getenv("USC_DURATION")) != NULL ) { - if ( sscanf(ptr, "%f", &ftmp) == 1 && ftmp >= 0.0 ) { + if (!(options & OPT_duration) && (ptr=getenv("USC_DURATION")) != NULL) { + if (sscanf(ptr, "%f", &ftmp) == 1 && ftmp >= 0.0) { STD_LOOP_DURATION=ftmp; - if ( Debug ) + if (Debug) printf("Using env USC_DURATION, set STD_LOOP_DURATION to %f\n", ftmp); - if ( STD_LOOP_DURATION == 0.0 ) { /* if arg is 0, set infinite loop flag */ + if (STD_LOOP_DURATION == 0.0) { /* if arg is 0, set infinite loop flag */ STD_INFINITE=1; - if ( Debug ) + if (Debug) printf("Using env USC_DURATION, set STD_INFINITE to 1\n"); } } @@ -424,10 +424,10 @@ parse_opts(int ac, char **av, const option_t *user_optarr, void (*uhf)()) * use that number as delay in factional seconds (same as -P option). * The -P option with arg will be used even if this env var is set. */ - if ( !(options & OPT_delay) && (ptr=getenv(USC_LOOP_DELAY)) != NULL ) { - if ( sscanf(ptr, "%f", &ftmp) == 1 && ftmp >= 0.0 ) { + if (!(options & OPT_delay) && (ptr=getenv(USC_LOOP_DELAY)) != NULL) { + if (sscanf(ptr, "%f", &ftmp) == 1 && ftmp >= 0.0) { STD_LOOP_DELAY=ftmp; - if ( Debug ) + if (Debug) printf("Using env %s, set STD_LOOP_DELAY = %f\n", USC_LOOP_DELAY, ftmp); } @@ -438,9 +438,9 @@ parse_opts(int ac, char **av, const option_t *user_optarr, void (*uhf)()) * use that number as copies (same as -c option). * The -c option with arg will be used even if this env var is set. */ - if ( !(options & OPT_copies) && (ptr=getenv(USC_COPIES)) != NULL ) { - if ( sscanf(ptr, "%d", &STD_COPIES) == 1 && STD_COPIES >= 0 ) { - if ( Debug ) + if (!(options & OPT_copies) && (ptr=getenv(USC_COPIES)) != NULL) { + if (sscanf(ptr, "%d", &STD_COPIES) == 1 && STD_COPIES >= 0) { + if (Debug) printf("Using env %s, set STD_COPIES = %d\n", USC_COPIES, STD_COPIES); } @@ -450,94 +450,94 @@ parse_opts(int ac, char **av, const option_t *user_optarr, void (*uhf)()) * The following are special system testing envs to turn on special * hooks in the code. */ - if ( (ptr=getenv("USC_TP_BARRIER")) != NULL ) { - if ( sscanf(ptr, "%i", &k) == 1 && k >= 0 ) { + if ((ptr=getenv("USC_TP_BARRIER")) != NULL) { + if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { STD_TP_barrier=k; } else STD_TP_barrier=1; - if ( Debug ) + if (Debug) printf("using env USC_TP_BARRIER, Set STD_TP_barrier to %d\n", STD_TP_barrier); } - if ( (ptr=getenv("USC_LP_BARRIER")) != NULL ) { - if ( sscanf(ptr, "%i", &k) == 1 && k >= 0 ) { + if ((ptr=getenv("USC_LP_BARRIER")) != NULL) { + if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { STD_LP_barrier=k; } else STD_LP_barrier=1; - if ( Debug ) + if (Debug) printf("using env USC_LP_BARRIER, Set STD_LP_barrier to %d\n", STD_LP_barrier); } - if ( (ptr=getenv("USC_TP_SHMEM")) != NULL ) { - if ( sscanf(ptr, "%i", &k) == 1 && k >= 0 ) { + if ((ptr=getenv("USC_TP_SHMEM")) != NULL) { + if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { STD_TP_shmem_sz=k; - if ( Debug ) + if (Debug) printf("Using env USC_TP_SHMEM, Set STD_TP_shmem_sz to %d\n", STD_TP_shmem_sz); } } - if ( (ptr=getenv("USC_LP_SHMEM")) != NULL ) { - if ( sscanf(ptr, "%i", &k) == 1 && k >= 0 ) { + if ((ptr=getenv("USC_LP_SHMEM")) != NULL) { + if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { STD_LP_shmem=k; - if ( Debug ) + if (Debug) printf("Using env USC_LP_SHMEM, Set STD_LP_shmem to %d\n", STD_LP_shmem); } } - if ( (ptr=getenv("USC_LD_SHMEM")) != NULL ) { - if ( sscanf(ptr, "%i", &k) == 1 && k >= 0 ) { + if ((ptr=getenv("USC_LD_SHMEM")) != NULL) { + if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { STD_LD_shmem=k; - if ( Debug ) + if (Debug) printf("Using env USC_LD_SHMEM, Set STD_LD_shmem to %d\n", STD_LD_shmem); } } - if ( (ptr=getenv("USC_TP_SBRK")) != NULL ) { - if ( sscanf(ptr, "%i", &k) == 1 && k >= 0 ) { + if ((ptr=getenv("USC_TP_SBRK")) != NULL) { + if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { STD_TP_sbrk=k; - if ( Debug ) + if (Debug) printf("Using env USC_TP_SBRK, Set STD_TP_sbrk to %d\n", STD_TP_sbrk); } } #if !defined(UCLINUX) - if ( (ptr=getenv("USC_LP_SBRK")) != NULL ) { - if ( sscanf(ptr, "%i", &k) == 1 && k >= 0 ) { + if ((ptr=getenv("USC_LP_SBRK")) != NULL) { + if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { STD_LP_sbrk=k; - if ( Debug ) + if (Debug) printf("Using env USC_LP_SBRK, Set STD_LP_sbrk to %d\n", STD_LP_sbrk); } } #endif /* if !defined(UCLINUX) */ - if ( (ptr=getenv("USC_LP_RECFUN")) != NULL ) { - if ( sscanf(ptr, "%i", &k) == 1 && k >= 0 ) { + if ((ptr=getenv("USC_LP_RECFUN")) != NULL) { + if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { STD_LP_recfun=k; - if ( STD_bigstack != (struct usc_bigstack_t *)NULL ) + if (STD_bigstack != NULL) STD_bigstack=(struct usc_bigstack_t *) malloc(sizeof(struct usc_bigstack_t)); - if ( Debug ) + if (Debug) printf("Using env USC_LP_RECFUN, Set STD_LP_recfun to %d\n", STD_LP_recfun); } } - if ( (ptr=getenv("USC_LD_RECFUN")) != NULL ) { - if ( sscanf(ptr, "%i", &k) == 1 && k >= 0 ) { + if ((ptr=getenv("USC_LD_RECFUN")) != NULL) { + if (sscanf(ptr, "%i", &k) == 1 && k >= 0) { STD_LD_recfun=k; - if ( STD_bigstack != (struct usc_bigstack_t *)NULL ) + if (STD_bigstack != NULL) STD_bigstack=(struct usc_bigstack_t *) malloc(sizeof(struct usc_bigstack_t)); - if ( Debug ) + if (Debug) printf("Using env USC_LD_RECFUN, Set STD_LD_recfun to %d\n", STD_LD_recfun); } @@ -578,7 +578,7 @@ STD_opts_help() { int i; - for(i = 0; std_options[i].optstr; ++i) { + for (i = 0; std_options[i].optstr; ++i) { if (std_options[i].help) printf("%s", std_options[i].help); } @@ -610,7 +610,7 @@ usc_global_setup_hook() /* * Fork STD_COPIES-1 copies. */ - for(cnt=1;cnt<STD_COPIES;cnt++) { + for (cnt=1;cnt<STD_COPIES;cnt++) { switch(fork() ) { case -1: fprintf(stderr, "%s: fork() failed, errno:%d %s\n", @@ -628,7 +628,7 @@ usc_global_setup_hook() /* * pause waiting for sigusr1. */ - if ( STD_PAUSE ) { + if (STD_PAUSE) { _TMP_FUNC = (int (*)())signal(SIGUSR1, STD_go); pause(); signal(SIGUSR1, (void (*)())_TMP_FUNC); @@ -636,13 +636,13 @@ usc_global_setup_hook() #if !defined(UCLINUX) - if ( STD_TP_sbrk || STD_LP_sbrk) { + if (STD_TP_sbrk || STD_LP_sbrk) { STD_start_break=sbrk(0); /* get original sbreak size */ } - if ( STD_TP_sbrk ) { + if (STD_TP_sbrk) { sbrk(STD_TP_sbrk); - if ( Debug ) + if (Debug) printf("after sbrk(%d)\n", STD_TP_sbrk); } @@ -710,10 +710,10 @@ int counter; * duration of STD_LOOP_DURATION seconds (fractional) or * doing loop delays, get the clocks per second. */ - if ( first_time ) { + if (first_time) { first_time=0; - if ( STD_LOOP_DELAY || STD_LOOP_DURATION ) { + if (STD_LOOP_DELAY || STD_LOOP_DURATION) { hertz = get_timepersec(); } @@ -722,7 +722,7 @@ int counter; * clocks. */ - if ( STD_LOOP_DURATION) { + if (STD_LOOP_DURATION) { ct=get_current_time(); stop_time=(int)((float)hertz * STD_LOOP_DURATION) + ct; } @@ -731,7 +731,7 @@ int counter; * If doing delay each iteration, calcuate the number * of clocks for each delay. */ - if ( STD_LOOP_DELAY ) { + if (STD_LOOP_DELAY) { delay=(int)((float)hertz * STD_LOOP_DELAY); } @@ -743,15 +743,15 @@ int counter; * The delay will happen before determining if * there will be another iteration. */ - else if ( STD_LOOP_DELAY ) { + else if (STD_LOOP_DELAY) { ct=get_current_time(); end=ct+delay; - while ( ct < end ) { + while (ct < end) { /* * The following are special test hooks in the delay loop. */ - if ( STD_LD_recfun ) { - if ( Debug ) + if (STD_LD_recfun) { + if (Debug) printf("calling usc_recressive_func(0, %d, *STD_bigstack)\n", STD_LD_recfun); usc_recressive_func(0, STD_LD_recfun, *STD_bigstack); @@ -761,27 +761,27 @@ int counter; } } - if ( STD_INFINITE ) { + if (STD_INFINITE) { keepgoing++; } - if ( STD_LOOP_COUNT && counter < STD_LOOP_COUNT ) { + if (STD_LOOP_COUNT && counter < STD_LOOP_COUNT) { keepgoing++; } - if ( STD_LOOP_DURATION != 0.0 && get_current_time() < stop_time ) { + if (STD_LOOP_DURATION != 0.0 && get_current_time() < stop_time) { keepgoing++; } - if ( keepgoing == 0 ) + if (keepgoing == 0) return 0; /* * The following code allows special system testing hooks. */ - if ( STD_LP_recfun ) { - if ( Debug ) + if (STD_LP_recfun) { + if (Debug) printf("calling usc_recressive_func(0, %d, *STD_bigstack)\n", STD_LP_recfun); usc_recressive_func(0, STD_LP_recfun, *STD_bigstack); @@ -789,15 +789,15 @@ int counter; #if !defined(UCLINUX) - if ( STD_LP_sbrk ) { - if ( Debug ) + if (STD_LP_sbrk) { + if (Debug) printf("about to do sbrk(%d)\n", STD_LP_sbrk); sbrk(STD_LP_sbrk); } #endif - if ( keepgoing ) + if (keepgoing) return 1; else return 0; /* done - stop iterating */ @@ -813,7 +813,7 @@ int cnt; int max; struct usc_bigstack_t bstack; { - if ( cnt < max ) + if (cnt < max) usc_recressive_func(cnt+1, max, bstack); } diff --git a/lib/random_range.c b/lib/random_range.c index 9c05cf727..2e4761e00 100644 --- a/lib/random_range.c +++ b/lib/random_range.c @@ -357,7 +357,7 @@ char **errp; * If max is less than 2gb, then the value can fit in 32 bits * and the standard lrand48() routine can be used. */ - if ( max <= (long)2147483647 ) { + if (max <= (long)2147483647) { return (long) (min + (((long)lrand48() % nmults) * mult)); } else { /* @@ -449,7 +449,7 @@ char **errp; * If max is less than 2gb, then the value can fit in 32 bits * and the standard lrand48() routine can be used. */ - if ( max <= (long)2147483647 ) { + if (max <= (long)2147483647) { return (long) (min + (((long)lrand48() % nmults) * mult)); } else { /* @@ -540,7 +540,7 @@ char **errp; * If max is less than 2gb, then the value can fit in 32 bits * and the standard lrand48() routine can be used. */ - if ( max <= (long)2147483647 ) { + if (max <= (long)2147483647) { return (long long) (min + (((long long)lrand48() % nmults) * mult)); } else { /* @@ -577,19 +577,19 @@ divider(long long min, long long max, long long cnt, long long rand) * if we get to a count of more than 32, we should have gotten * to 2gb. */ - if ( cnt > 32 ) + if (cnt > 32) return -1; /* * Only get a random number the first time. */ - if ( cnt == 0 || rand < -1 ) { + if (cnt == 0 || rand < -1) { rand = (long long)lrand48(); /* 32 bit random number */ } diff = max - min; - if ( diff <= 2147483647 ) + if (diff <= 2147483647) return min + rand; half = diff/(long long)2; /* half the distance between min and max */ @@ -600,13 +600,13 @@ printf("divider: min=%lld, max=%lld, cnt=%lld, rand=%lld\n", min, max, cnt, rand printf(" diff = %lld, half = %lld, med = %lld\n", diff, half, med); #endif - if ( half <= 2147483647 ) { + if (half <= 2147483647) { /* * If half is smaller than 2gb, we can use the random number * to pick the number within the min to med or med to max * if the cnt bit of rand is zero or one, respectively. */ - if ( rand & (1<<cnt) ) + if (rand & (1<<cnt)) return med + rand; else return min + rand; @@ -615,7 +615,7 @@ printf(" diff = %lld, half = %lld, med = %lld\n", diff, half, med); * recursively call ourself to reduce the value to the bottom half * or top half (bit cnt is set). */ - if ( rand & (1<<cnt) ) { + if (rand & (1<<cnt)) { return divider(med, max, cnt+1, rand); } else { return divider(min, med, cnt+1, rand); @@ -656,7 +656,7 @@ random_bit(long mask) long bit; /* used to count bits and num of set bits choosen */ int nshift; /* used to count bit shifts */ - if ( mask == 0 ) + if (mask == 0) return 0; /* @@ -665,8 +665,8 @@ random_bit(long mask) #ifndef CRAY bit=1L; - for ( nshift=0; (unsigned int)nshift<sizeof(long)*8; nshift++) { - if ( mask & bit ) + for (nshift=0; (unsigned int)nshift<sizeof(long)*8; nshift++) { + if (mask & bit) nbits++; bit=bit<<1; } @@ -688,7 +688,7 @@ random_bit(long mask) nshift=0; while (bit) { /* check if the current one's bit is set */ - if ( mask & 1L ) { + if (mask & 1L) { bit--; } mask = mask >> 1; @@ -721,7 +721,7 @@ char **argv; ret=random_bit(mask); printf("random_bit(%#o) returned %#o\n", mask, ret); - if ( argc >= 3 ) { + if (argc >= 3) { iter=atoi(argv[1]); for (ind=2; ind<argc; ind++) { printf("Calling random_bit %d times for mask %#o\n", iter, mask); @@ -775,17 +775,17 @@ char **argv; long valbound[PARTNUM]; long long lvalbound[PARTNUM]; - for (ind=0; ind<PARTNUM; ind++ ) + for (ind=0; ind<PARTNUM; ind++) cntarr[ind]=0; - if ( argc < 2 ) { + if (argc < 2) { printf("Usage: %s func [iterations] \n", argv[0]); printf("func can be random_range, random_rangel, random_rangell\n"); exit(1); } - if ( argc >= 3 ) { - if ( sscanf(argv[2], "%i", &iter) != 1 ) { + if (argc >= 3) { + if (sscanf(argv[2], "%i", &iter) != 1) { printf("Usage: %s [func iterations] \n", argv[0]); printf("argv[2] is not a number\n"); exit(1); @@ -796,32 +796,32 @@ char **argv; /* * random_rangel () */ - if ( strcmp(argv[1], "random_rangel") == 0 ) { + if (strcmp(argv[1], "random_rangel") == 0) { ltmin=lmax; part = lmax/PARTNUM; - for(ind=0; ind<PARTNUM; ind++) { + for (ind=0; ind<PARTNUM; ind++) { valbound[ind]=part*ind; } - for(cnt=0; cnt<iter; cnt++) { + for (cnt=0; cnt<iter; cnt++) { lret=random_rangel(lmin, lmax, lmult, NULL); - if ( iter < 100 ) + if (iter < 100) printf("%ld\n", lret); - if ( lret < ltmin ) + if (lret < ltmin) ltmin = lret; - if ( lret > ltmax ) + if (lret > ltmax) ltmax = lret; - for(ind=0; ind<PARTNUM-1; ind++) { - if ( valbound[ind] < lret && lret <= valbound[ind+1] ) { + for (ind=0; ind<PARTNUM-1; ind++) { + if (valbound[ind] < lret && lret <= valbound[ind+1]) { cntarr[ind]++; break; } } - if ( lret > valbound[PARTNUM-1] ) { + if (lret > valbound[PARTNUM-1]) { cntarr[PARTNUM-1]++; } } - for(ind=0; ind<PARTNUM-1; ind++) { + for (ind=0; ind<PARTNUM-1; ind++) { printf("%2d %-13ld to %-13ld %5ld %4.4f\n", ind+1, valbound[ind], valbound[ind+1], cntarr[ind], (float)(cntarr[ind]/(float)iter)); @@ -831,36 +831,36 @@ char **argv; (float)(cntarr[PARTNUM-1]/(float)iter)); printf(" min=%ld, max=%ld\n", ltmin, ltmax); - } else if ( strcmp(argv[1], "random_rangell") == 0 ) { + } else if (strcmp(argv[1], "random_rangell") == 0) { /* * random_rangell() unit test */ lltmin=llmax; lpart = llmax/PARTNUM; - for(ind=0; ind<PARTNUM; ind++) { + for (ind=0; ind<PARTNUM; ind++) { lvalbound[ind]=(long long)(lpart*ind); } - for(cnt=0; cnt<iter; cnt++) { + for (cnt=0; cnt<iter; cnt++) { llret=random_rangell(llmin, llmax, llmult, NULL); - if ( iter < 100 ) + if (iter < 100) printf("random_rangell returned %lld\n", llret); - if ( llret < lltmin ) + if (llret < lltmin) lltmin = llret; - if ( llret > lltmax ) + if (llret > lltmax) lltmax = llret; - for(ind=0; ind<PARTNUM-1; ind++) { - if ( lvalbound[ind] < llret && llret <= lvalbound[ind+1] ) { + for (ind=0; ind<PARTNUM-1; ind++) { + if (lvalbound[ind] < llret && llret <= lvalbound[ind+1]) { cntarr[ind]++; break; } } - if ( llret > lvalbound[PARTNUM-1] ) { + if (llret > lvalbound[PARTNUM-1]) { cntarr[PARTNUM-1]++; } } - for(ind=0; ind<PARTNUM-1; ind++) { + for (ind=0; ind<PARTNUM-1; ind++) { printf("%2d %-13lld to %-13lld %5ld %4.4f\n", ind+1, lvalbound[ind], lvalbound[ind+1], cntarr[ind], (float)(cntarr[ind]/(float)iter)); @@ -876,30 +876,30 @@ char **argv; */ itmin=imax; part = imax/PARTNUM; - for(ind=0; ind<PARTNUM; ind++) { + for (ind=0; ind<PARTNUM; ind++) { valbound[ind]=part*ind; } - for(cnt=0; cnt<iter; cnt++) { + for (cnt=0; cnt<iter; cnt++) { lret=random_range(imin, imax, imult, NULL); - if ( iter < 100 ) + if (iter < 100) printf("%ld\n", lret); - if ( lret < itmin ) + if (lret < itmin) itmin = lret; - if ( lret > itmax ) + if (lret > itmax) itmax = lret; - for(ind=0; ind<PARTNUM-1; ind++) { - if ( valbound[ind] < lret && lret <= valbound[ind+1] ) { + for (ind=0; ind<PARTNUM-1; ind++) { + if (valbound[ind] < lret && lret <= valbound[ind+1]) { cntarr[ind]++; break; } } - if ( lret > valbound[PARTNUM-1] ) { + if (lret > valbound[PARTNUM-1]) { cntarr[PARTNUM-1]++; } } - for(ind=0; ind<PARTNUM-1; ind++) { + for (ind=0; ind<PARTNUM-1; ind++) { printf("%2d %-13ld to %-13ld %5ld %4.4f\n", ind+1, valbound[ind], valbound[ind+1], cntarr[ind], (float)(cntarr[ind]/(float)iter)); diff --git a/lib/rmobj.c b/lib/rmobj.c index a779060a0..03f4fcfc7 100644 --- a/lib/rmobj.c +++ b/lib/rmobj.c @@ -101,8 +101,8 @@ rmobj(char *obj, char **errmsg) static char err_msg[1024]; /* error message */ /* Determine the file type */ - if ( lstat(obj, &statbuf) < 0 ) { - if ( errmsg != NULL ) { + if (lstat(obj, &statbuf) < 0) { + if (errmsg != NULL) { sprintf(err_msg, "lstat(%s) failed; errno=%d: %s", obj, errno, SYSERR); *errmsg = err_msg; @@ -111,12 +111,12 @@ rmobj(char *obj, char **errmsg) } /* Take appropriate action, depending on the file type */ - if ( (statbuf.st_mode & S_IFMT) == S_IFDIR ) { + if ((statbuf.st_mode & S_IFMT) == S_IFDIR) { /* object is a directory */ /* Do NOT perform the request if the directory is "/" */ - if ( !strcmp(obj, "/") ) { - if ( errmsg != NULL ) { + if (!strcmp(obj, "/")) { + if (errmsg != NULL) { sprintf(err_msg, "Cannot remove /"); *errmsg = err_msg; } @@ -124,9 +124,9 @@ rmobj(char *obj, char **errmsg) } /* Open the directory to get access to what is in it */ - if ( (dir = opendir(obj)) == NULL ) { - if ( rmdir(obj) != 0 ) { - if ( errmsg != NULL ) { + if ((dir = opendir(obj)) == NULL) { + if (rmdir(obj) != 0) { + if (errmsg != NULL) { sprintf(err_msg, "rmdir(%s) failed; errno=%d: %s", obj, errno, SYSERR); *errmsg = err_msg; @@ -138,17 +138,17 @@ rmobj(char *obj, char **errmsg) } /* Loop through the entries in the directory, removing each one */ - for ( dir_ent = (struct dirent *)readdir(dir); + for (dir_ent = (struct dirent *)readdir(dir); dir_ent != NULL; dir_ent = (struct dirent *)readdir(dir)) { /* Don't remove "." or ".." */ - if ( !strcmp(dir_ent->d_name, ".") || !strcmp(dir_ent->d_name, "..") ) + if (!strcmp(dir_ent->d_name, ".") || !strcmp(dir_ent->d_name, "..")) continue; /* Recursively call this routine to remove the current entry */ sprintf(dirobj, "%s/%s", obj, dir_ent->d_name); - if ( rmobj(dirobj, errmsg) != 0 ) + if (rmobj(dirobj, errmsg) != 0) ret_val = -1; } @@ -157,12 +157,12 @@ rmobj(char *obj, char **errmsg) /* If there were problems removing an entry, don't attempt to remove the directory itself */ - if ( ret_val == -1 ) + if (ret_val == -1) return -1; /* Get the link count, now that all the entries have been removed */ - if ( lstat(obj, &statbuf) < 0 ) { - if ( errmsg != NULL ) { + if (lstat(obj, &statbuf) < 0) { + if (errmsg != NULL) { sprintf(err_msg, "lstat(%s) failed; errno=%d: %s", obj, errno, SYSERR); *errmsg = err_msg; @@ -171,10 +171,10 @@ rmobj(char *obj, char **errmsg) } /* Remove the directory itself */ - if ( statbuf.st_nlink >= 3 ) { + if (statbuf.st_nlink >= 3) { /* The directory is linked; unlink() must be used */ - if ( unlink(obj) < 0 ) { - if ( errmsg != NULL ) { + if (unlink(obj) < 0) { + if (errmsg != NULL) { sprintf(err_msg, "unlink(%s) failed; errno=%d: %s", obj, errno, SYSERR); *errmsg = err_msg; @@ -183,8 +183,8 @@ rmobj(char *obj, char **errmsg) } } else { /* The directory is not linked; remove() can be used */ - if ( remove(obj) < 0 ) { - if ( errmsg != NULL ) { + if (remove(obj) < 0) { + if (errmsg != NULL) { sprintf(err_msg, "remove(%s) failed; errno=%d: %s", obj, errno, SYSERR); *errmsg = err_msg; @@ -194,8 +194,8 @@ rmobj(char *obj, char **errmsg) } } else { /* object is not a directory; just use unlink() */ - if ( unlink(obj) < 0 ) { - if ( errmsg != NULL ) { + if (unlink(obj) < 0) { + if (errmsg != NULL) { sprintf(err_msg, "unlink(%s) failed; errno=%d: %s", obj, errno, SYSERR); *errmsg = err_msg; diff --git a/lib/search_path.c b/lib/search_path.c index a35f0463b..444a1fbe7 100644 --- a/lib/search_path.c +++ b/lib/search_path.c @@ -108,13 +108,13 @@ char **argv; char path[PATH_MAX]; int ind; - if (argc <= 1 ) { + if (argc <= 1) { printf("missing argument\n"); exit(1); } - for(ind=1;ind < argc; ind++) { - if ( search_path(argv[ind], path, F_OK, 0) < 0 ) { + for (ind=1;ind < argc; ind++) { + if (search_path(argv[ind], path, F_OK, 0) < 0) { printf("ERROR: %s\n", path); } else { @@ -151,15 +151,15 @@ printf("search_path: cmd = %s, access_mode = %d, fullpath = %d\n", cmd, access_m /* * full or relative path was given */ - if ( (cmd[0] == '/') || ( (cp=strchr(cmd, '/')) != NULL )) { - if ( access(cmd, access_mode) == 0 ) { + if ((cmd[0] == '/') || ( (cp=strchr(cmd, '/')) != NULL )) { + if (access(cmd, access_mode) == 0) { - if ( cmd[0] != '/' ) { /* relative path */ - if ( getcwd(curpath, PATH_MAX) == NULL ) { + if (cmd[0] != '/') { /* relative path */ + if (getcwd(curpath, PATH_MAX) == NULL) { strcpy(res_path, curpath); return -1; } - if ( (strlen(curpath) + strlen(cmd) + 1) > (size_t)PATH_MAX ) { + if ((strlen(curpath) + strlen(cmd) + 1) > (size_t)PATH_MAX) { sprintf(res_path, "cmd (as relative path) and cwd is longer than %d", PATH_MAX); return -1; @@ -177,7 +177,7 @@ printf("search_path: cmd = %s, access_mode = %d, fullpath = %d\n", cmd, access_m } /* get the PATH variable */ - if ( (pathenv=getenv("PATH")) == NULL) { + if ((pathenv=getenv("PATH")) == NULL) { /* no path to scan, return */ sprintf(res_path, "Unable to get PATH env. variable"); return -1; @@ -198,10 +198,10 @@ printf("search_path: cmd = %s, access_mode = %d, fullpath = %d\n", cmd, access_m lastpath = 0; for (;;) { - if ( lastpath ) + if (lastpath) break; - if ( cp != pathenv ) + if (cp != pathenv) path = ++cp; /* already set on first iteration */ /* find end of current path */ @@ -218,11 +218,11 @@ printf("search_path: cmd = %s, access_mode = %d, fullpath = %d\n", cmd, access_m printf("search_path: tmppath = %s\n", tmppath); #endif - if ( *cp == '\0' ) + if (*cp == '\0') lastpath=1; /* this is the last path entry */ /* Check lengths so not to overflow res_path */ - if ( strlen(tmppath) + strlen(cmd) + 2 > (size_t)PATH_MAX ) { + if (strlen(tmppath) + strlen(cmd) + 2 > (size_t)PATH_MAX) { toolong++; continue; } @@ -239,14 +239,14 @@ printf("search_path: res_path = '%s'\n", res_path); * directory. */ - if ( fullpath && res_path[0] != '/' ) { /* not a full path */ - if ( curpath[0] == '\0' ) { - if ( getcwd(curpath, PATH_MAX) == NULL ) { + if (fullpath && res_path[0] != '/') { /* not a full path */ + if (curpath[0] == '\0') { + if (getcwd(curpath, PATH_MAX) == NULL) { strcpy(res_path, curpath); return -1; } } - if ( (strlen(curpath) + strlen(res_path) + 2) > (size_t)PATH_MAX ) { + if ((strlen(curpath) + strlen(res_path) + 2) > (size_t)PATH_MAX) { toolong++; continue; } @@ -259,7 +259,7 @@ printf("search_path: full res_path= '%s'\n", res_path); } - if ( (ret=access(res_path, access_mode)) == 0 ) { + if ((ret=access(res_path, access_mode)) == 0) { #if DEBUG printf("search_path: found res_path = %s\n", res_path); #endif @@ -268,7 +268,7 @@ printf("search_path: found res_path = %s\n", res_path); } /* return failure */ - if ( toolong ) + if (toolong) sprintf(res_path, "Unable to find file, %d path/file strings were too long", toolong); else diff --git a/lib/str_to_bytes.c b/lib/str_to_bytes.c index 5bbfb8dd5..a45e3f9f4 100644 --- a/lib/str_to_bytes.c +++ b/lib/str_to_bytes.c @@ -82,7 +82,7 @@ char *s; float num; nconv = sscanf(s, "%f%c%c", &num, &mult, &junk); - if (nconv == 0 || nconv == 3 ) + if (nconv == 0 || nconv == 3) return -1; if (nconv == 1) @@ -117,7 +117,7 @@ char *s; float num; nconv = sscanf(s, "%f%c%c", &num, &mult, &junk); - if (nconv == 0 || nconv == 3 ) + if (nconv == 0 || nconv == 3) return -1; if (nconv == 1) @@ -157,7 +157,7 @@ char *s; double num; nconv = sscanf(s, "%lf%c%c", &num, &mult, &junk); - if (nconv == 0 || nconv == 3 ) + if (nconv == 0 || nconv == 3) return -1; if (nconv == 1) @@ -189,7 +189,7 @@ main(int argc, char **argv) { int ind; - if (argc == 1 ) { + if (argc == 1) { fprintf(stderr, "missing str_to_bytes() parameteres\n"); exit(1); } diff --git a/lib/string_to_tokens.c b/lib/string_to_tokens.c index 09be8c037..fceeed6c7 100644 --- a/lib/string_to_tokens.c +++ b/lib/string_to_tokens.c @@ -82,23 +82,23 @@ string_to_tokens(char *arg_string, char *arg_array[], int array_size, char *sepa int num_toks = 0; /* number of tokens found */ char *strtok(); - if ( arg_array == NULL || array_size <= 1 || separator == NULL ) + if (arg_array == NULL || array_size <= 1 || separator == NULL) return -1; /* * Use strtok() to parse 'arg_string', placing pointers to the * individual tokens into the elements of 'arg_array'. */ - if ( (arg_array[num_toks] = strtok(arg_string, separator)) == NULL ) { + if ((arg_array[num_toks] = strtok(arg_string, separator)) == NULL) { return 0; } for (num_toks=1;num_toks<array_size; num_toks++) { - if ( (arg_array[num_toks] = strtok(NULL, separator)) == NULL ) + if ((arg_array[num_toks] = strtok(NULL, separator)) == NULL) break; } - if ( num_toks == array_size ) + if (num_toks == array_size) arg_array[num_toks] = NULL; /* diff --git a/lib/tlibio.c b/lib/tlibio.c index 7ea4fd114..09c1fbbb5 100644 --- a/lib/tlibio.c +++ b/lib/tlibio.c @@ -290,15 +290,15 @@ lio_parse_io_arg1(char *string) /* * Determine if token is a valid string. */ - for(ind=0; ind<sizeof(Lio_info1)/sizeof(struct lio_info_type); ind++) { - if ( strcmp(string, Lio_info1[ind].token) == 0 ) { + for (ind=0; ind<sizeof(Lio_info1)/sizeof(struct lio_info_type); ind++) { + if (strcmp(string, Lio_info1[ind].token) == 0) { mask |= Lio_info1[ind].bits; found = 1; break; } } - if ( found == 0 ) { + if (found == 0) { return -1; } @@ -317,7 +317,7 @@ lio_help1(char *prefix) { unsigned int ind; - for(ind=0; ind<sizeof(Lio_info1)/sizeof(struct lio_info_type); ind++) { + for (ind=0; ind<sizeof(Lio_info1)/sizeof(struct lio_info_type); ind++) { printf("%s %s : %s\n", prefix, Lio_info1[ind].token, Lio_info1[ind].desc); } @@ -347,7 +347,7 @@ lio_parse_io_arg2(char *string, char **badtoken) unsigned int ind; char chr; - if ( token == NULL ) + if (token == NULL) return -1; for (;;) { @@ -361,8 +361,8 @@ lio_parse_io_arg2(char *string, char **badtoken) * Determine if token is a valid string or number and if * so, add the bits to the mask. */ - for(ind=0; ind<sizeof(Lio_info2)/sizeof(struct lio_info_type); ind++) { - if ( strcmp(token, Lio_info2[ind].token) == 0 ) { + for (ind=0; ind<sizeof(Lio_info2)/sizeof(struct lio_info_type); ind++) { + if (strcmp(token, Lio_info2[ind].token) == 0) { mask |= Lio_info2[ind].bits; found = 1; break; @@ -373,8 +373,8 @@ lio_parse_io_arg2(char *string, char **badtoken) * If token does not match one of the defined tokens, determine * if it is a number, if so, add the bits. */ - if ( !found ) { - if (sscanf(token, "%i%c", &tmp, &chr) == 1 ) { + if (!found) { + if (sscanf(token, "%i%c", &tmp, &chr) == 1) { mask |= tmp; found=1; } @@ -383,7 +383,7 @@ lio_parse_io_arg2(char *string, char **badtoken) *cc = savecc; if (!found) { /* token is not valid */ - if ( badtoken != NULL) + if (badtoken != NULL) *badtoken = token; return(-1); } @@ -409,7 +409,7 @@ lio_help2(char *prefix) { unsigned int ind; - for(ind=0; ind<sizeof(Lio_info2)/sizeof(struct lio_info_type); ind++) { + for (ind=0; ind<sizeof(Lio_info2)/sizeof(struct lio_info_type); ind++) { printf("%s %s : %s\n", prefix, Lio_info2[ind].token, Lio_info2[ind].desc); } @@ -424,7 +424,7 @@ lio_help2(char *prefix) static void lio_async_signal_handler(int sig) { - if ( Debug_level ) + if (Debug_level) printf("DEBUG %s/%d: received signal %d, a signal caught %d times\n", __FILE__, __LINE__, sig, Received_signal+1); @@ -442,7 +442,7 @@ lio_async_signal_handler(int sig) static void lio_async_callback_handler(sigval_t sigval) { - if ( Debug_level ) + if (Debug_level) printf("DEBUG %s/%d: received callback, nbytes=%ld, a callback called %d times\n", __FILE__, __LINE__, (long)sigval.sival_int, Received_callback+1); @@ -567,15 +567,15 @@ long wrd; /* to allow future features, use zero for now */ /* * If LIO_RANDOM bit specified, get new method randomly. */ - if ( method & LIO_RANDOM ) { - if( Debug_level > 3 ) + if (method & LIO_RANDOM) { + if (Debug_level > 3) printf("DEBUG %s/%d: method mask to choose from: %#o\n", __FILE__, __LINE__, method ); method = lio_random_methods(method); - if ( Debug_level > 2 ) + if (Debug_level > 2) printf("DEBUG %s/%d: random chosen method %#o\n", __FILE__, __LINE__, method); } - if ( errmsg != NULL ) + if (errmsg != NULL) *errmsg = Errormsg; Rec_signal=Received_signal; /* get the current number of signals received */ @@ -614,22 +614,22 @@ long wrd; /* to allow future features, use zero for now */ #endif aiolist[0] = &aiocbp; - if( (ret = lseek( fd, 0, SEEK_CUR )) == -1 ){ + if ((ret = lseek( fd, 0, SEEK_CUR )) == -1) { ret = 0; /* If there is an error and it is not ESPIPE then kick out the error. * If the fd is a fifo then we have to make sure that * lio_random_methods() didn't select pwrite/pread; if it did then * switch to write/read. */ - if( errno == ESPIPE ){ - if( method & LIO_IO_SYNCP ){ - if( omethod & LIO_RANDOM ){ + if (errno == ESPIPE) { + if (method & LIO_IO_SYNCP) { + if (omethod & LIO_RANDOM) { method &= ~LIO_IO_SYNCP; method |= LIO_IO_SYNC; - if( Debug_level > 2 ) + if (Debug_level > 2) printf("DEBUG %s/%d: random chosen method switched to %#o for fifo\n", __FILE__, __LINE__, method ); } - else if( Debug_level ){ + else if (Debug_level) { printf("DEBUG %s/%d: pwrite will fail when it writes to a fifo\n", __FILE__, __LINE__ ); } @@ -655,14 +655,14 @@ long wrd; /* to allow future features, use zero for now */ * Otherwise there is not necessary a signal handler to trap * the signal. */ - if ( sig && !(method & LIO_USE_SIGNAL) && - ! (method & LIO_WAIT_SIGTYPES) ){ + if (sig && !(method & LIO_USE_SIGNAL) && + ! (method & LIO_WAIT_SIGTYPES) ) { sig=0; /* ignore signal parameter */ } #if defined(sgi) || (defined(__linux__) && !defined(__UCLIBC__)) - if ( sig && (method & LIO_WAIT_CBTYPES) ) + if (sig && (method & LIO_WAIT_CBTYPES)) sig=0; /* ignore signal parameter */ #endif @@ -674,7 +674,7 @@ long wrd; /* to allow future features, use zero for now */ *** restoring the signal handler could be added *** */ - if ( sig && (method & LIO_WAIT_SIGTYPES) ){ + if (sig && (method & LIO_WAIT_SIGTYPES)) { #ifdef CRAY sigctl(SCTL_REG, sig, lio_async_signal_handler); #endif @@ -685,7 +685,7 @@ long wrd; /* to allow future features, use zero for now */ #endif /* sgi */ } #if defined(sgi) - else if( method & LIO_WAIT_CBTYPES ){ + else if (method & LIO_WAIT_CBTYPES) { /* sival_int just has to be something that I can use * to identify the callback, and "size" happens to be handy... */ @@ -695,7 +695,7 @@ long wrd; /* to allow future features, use zero for now */ } #endif #if defined(__linux__) && !defined(__UCLIBC__) - else if( method & LIO_WAIT_CBTYPES ){ + else if (method & LIO_WAIT_CBTYPES) { /* sival_int just has to be something that I can use * to identify the callback, and "size" happens to be handy... */ @@ -713,7 +713,7 @@ long wrd; /* to allow future features, use zero for now */ * bytes written/read. */ - if ( (method & LIO_IO_SYNC) || (method & (LIO_IO_TYPES | LIO_IO_ATYPES)) == 0 ){ + if ((method & LIO_IO_SYNC) || (method & (LIO_IO_TYPES | LIO_IO_ATYPES)) == 0) { /* * write(2) is used if LIO_IO_SYNC bit is set or not none * of the LIO_IO_TYPES bits are set (default). @@ -723,10 +723,10 @@ long wrd; /* to allow future features, use zero for now */ "write(%d, buf, %d)", fd, size); io_type="write"; - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } - while(1) { + while (1) { if (((ret = write(fd, buffer, size)) == -1) && errno!=EAGAIN && errno!=EINTR) { sprintf(Errormsg, "%s/%d write(%d, buf, %d) ret:-1, errno=%d %s", __FILE__, __LINE__, @@ -734,8 +734,8 @@ long wrd; /* to allow future features, use zero for now */ return -errno; } - if(ret!=-1) { - if ( ret != size ) { + if (ret!=-1) { + if (ret != size) { sprintf(Errormsg, "%s/%d write(%d, buf, %d) returned=%d", __FILE__, __LINE__, @@ -744,7 +744,7 @@ long wrd; /* to allow future features, use zero for now */ buffer+=ret; } else { - if ( Debug_level > 1 ) + if (Debug_level > 1) printf("DEBUG %s/%d: write completed without error (ret %d)\n", __FILE__, __LINE__, ret); @@ -756,13 +756,13 @@ long wrd; /* to allow future features, use zero for now */ } - else if ( method & LIO_IO_ASYNC ) { + else if (method & LIO_IO_ASYNC) { #ifdef CRAY sprintf(Lio_SysCall, "writea(%d, buf, %d, &status, %d)", fd, size, sig); io_type="writea"; - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } @@ -781,25 +781,25 @@ long wrd; /* to allow future features, use zero for now */ "aio_write(fildes=%d, buf, nbytes=%d, signo=%d)", fd, size, sig); io_type="aio_write"; - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } - if( sig ) + if (sig) sighold( sig ); if ((ret = aio_write(&aiocbp)) == -1) { sprintf(Errormsg, "%s/%d aio_write(fildes=%d, buf, nbytes=%d, signo=%d) ret:-1, errno=%d %s", __FILE__, __LINE__, fd, size, sig, errno, strerror(errno)); - if( sig ) + if (sig) sigrelse( sig ); return -errno; } #endif } /* LIO_IO_ASYNC */ - else if ( method & LIO_IO_SLISTIO ) { + else if (method & LIO_IO_SLISTIO) { #ifdef CRAY request.li_opcode = LO_WRITE; request.li_fildes = fd; @@ -818,12 +818,12 @@ long wrd; /* to allow future features, use zero for now */ "listio(LC_WAIT, &req, 1) LO_WRITE, fd:%d, nbyte:%d", fd, size); - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } sigoff(); - if ( listio(listio_cmd, &request, 1) == -1 ) { + if (listio(listio_cmd, &request, 1) == -1) { sprintf(Errormsg, "%s/%d %s failed, fd:%d, nbyte:%d errno=%d %s", __FILE__, __LINE__, Lio_SysCall, fd, size, errno, strerror(errno)); @@ -831,7 +831,7 @@ long wrd; /* to allow future features, use zero for now */ return -errno; } - if ( Debug_level > 1 ) + if (Debug_level > 1) printf("DEBUG %s/%d: %s did not return -1\n", __FILE__, __LINE__, Lio_SysCall); @@ -849,22 +849,22 @@ long wrd; /* to allow future features, use zero for now */ "lio_listio(LIO_WAIT, aiolist, 1, NULL) LIO_WRITE, fd:%d, nbyte:%d, sig:%d", fd, size, sig ); - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } - if( sig ) + if (sig) sighold( sig ); - if ( lio_listio(listio_cmd, aiolist, 1, NULL) == -1 ) { + if (lio_listio(listio_cmd, aiolist, 1, NULL) == -1) { sprintf(Errormsg, "%s/%d %s failed, fd:%d, nbyte:%d errno=%d %s", __FILE__, __LINE__, Lio_SysCall, fd, size, errno, strerror(errno)); - if( sig ) + if (sig) sigrelse( sig ); return -errno; } - if ( Debug_level > 1 ) + if (Debug_level > 1) printf("DEBUG %s/%d: %s did not return -1\n", __FILE__, __LINE__, Lio_SysCall); @@ -873,7 +873,7 @@ long wrd; /* to allow future features, use zero for now */ #endif } /* LIO_IO_SLISTIO */ - else if ( method & LIO_IO_ALISTIO ) { + else if (method & LIO_IO_ALISTIO) { #ifdef CRAY request.li_opcode = LO_WRITE; request.li_fildes = fd; @@ -892,12 +892,12 @@ long wrd; /* to allow future features, use zero for now */ "listio(LC_START, &req, 1) LO_WRITE, fd:%d, nbyte:%d", fd, size); - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } sigoff(); - if ( listio(listio_cmd, &request, 1) == -1 ) { + if (listio(listio_cmd, &request, 1) == -1) { sprintf(Errormsg, "%s/%d %s failed, fd:%d, nbyte:%d errno=%d %s", __FILE__, __LINE__, Lio_SysCall, fd, size, errno, strerror(errno)); @@ -914,17 +914,17 @@ long wrd; /* to allow future features, use zero for now */ "lio_listio(LIO_NOWAIT, aiolist, 1, NULL) LIO_WRITE, fd:%d, nbyte:%d", fd, size); - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } - if( sig ) + if (sig) sighold( sig ); - if ( lio_listio(listio_cmd, aiolist, 1, NULL) == -1 ) { + if (lio_listio(listio_cmd, aiolist, 1, NULL) == -1) { sprintf(Errormsg, "%s/%d %s failed, fd:%d, nbyte:%d errno=%d %s", __FILE__, __LINE__, Lio_SysCall, fd, size, errno, strerror(errno)); - if( sig ) + if (sig) sigrelse( sig ); return -errno; } @@ -932,13 +932,13 @@ long wrd; /* to allow future features, use zero for now */ }/* LIO_IO_ALISTIO */ #ifndef CRAY - else if ( method & LIO_IO_SYNCV ) { + else if (method & LIO_IO_SYNCV) { io_type="writev(2)"; sprintf(Lio_SysCall, "writev(%d, &iov, 1) nbyte:%d", fd, size); - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } if ((ret = writev(fd, &iov, 1)) == -1) { @@ -948,13 +948,13 @@ long wrd; /* to allow future features, use zero for now */ return -errno; } - if ( ret != size ) { + if (ret != size) { sprintf(Errormsg, "%s/%d writev(%d, iov, 1) nbyte:%d returned=%d", __FILE__, __LINE__, fd, size, ret); } - else if ( Debug_level > 1 ) + else if (Debug_level > 1) printf("DEBUG %s/%d: writev completed without error (ret %d)\n", __FILE__, __LINE__, ret); @@ -963,13 +963,13 @@ long wrd; /* to allow future features, use zero for now */ #endif #if defined(sgi) || (defined(__linux__) && !defined(__UCLIBC__)) - else if ( method & LIO_IO_SYNCP ) { + else if (method & LIO_IO_SYNCP) { io_type="pwrite(2)"; sprintf(Lio_SysCall, "pwrite(%d, buf, %d, %lld)", fd, size, (long long)poffset); - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } if ((ret = pwrite(fd, buffer, size, poffset)) == -1) { @@ -979,13 +979,13 @@ long wrd; /* to allow future features, use zero for now */ return -errno; } - if ( ret != size ) { + if (ret != size) { sprintf(Errormsg, "%s/%d pwrite(%d, buf, %d, %lld) returned=%d", __FILE__, __LINE__, fd, size, (long long)poffset, ret); } - else if ( Debug_level > 1 ) + else if (Debug_level > 1) printf("DEBUG %s/%d: pwrite completed without error (ret %d)\n", __FILE__, __LINE__, ret); @@ -1013,7 +1013,7 @@ long wrd; /* to allow future features, use zero for now */ * return the error value (errno) to the caller. * Note: Errormsg should already have been updated. */ - if ( ret < 0 ) { + if (ret < 0) { return ret; } @@ -1021,7 +1021,7 @@ long wrd; /* to allow future features, use zero for now */ * If i/o was not waited for (may not have been completed at this time), * return the size that was requested. */ - if ( ret == 1 ) + if (ret == 1) return size; /* @@ -1117,15 +1117,15 @@ long wrd; /* to allow future features, use zero for now */ /* * If LIO_RANDOM bit specified, get new method randomly. */ - if ( method & LIO_RANDOM ) { - if( Debug_level > 3 ) + if (method & LIO_RANDOM) { + if (Debug_level > 3) printf("DEBUG %s/%d: method mask to choose from: %#o\n", __FILE__, __LINE__, method ); method = lio_random_methods(method); - if ( Debug_level > 2 ) + if (Debug_level > 2) printf("DEBUG %s/%d: random chosen method %#o\n", __FILE__, __LINE__, method); } - if ( errmsg != NULL ) + if (errmsg != NULL) *errmsg = Errormsg; Rec_signal=Received_signal; /* get the current number of signals received */ @@ -1164,22 +1164,22 @@ long wrd; /* to allow future features, use zero for now */ #endif aiolist[0] = &aiocbp; - if( (ret = lseek( fd, 0, SEEK_CUR )) == -1 ){ + if ((ret = lseek( fd, 0, SEEK_CUR )) == -1) { ret = 0; /* If there is an error and it is not ESPIPE then kick out the error. * If the fd is a fifo then we have to make sure that * lio_random_methods() didn't select pwrite/pread; if it did then * switch to write/read. */ - if( errno == ESPIPE ){ - if( method & LIO_IO_SYNCP ){ - if( omethod & LIO_RANDOM ){ + if (errno == ESPIPE) { + if (method & LIO_IO_SYNCP) { + if (omethod & LIO_RANDOM) { method &= ~LIO_IO_SYNCP; method |= LIO_IO_SYNC; - if( Debug_level > 2 ) + if (Debug_level > 2) printf("DEBUG %s/%d: random chosen method switched to %#o for fifo\n", __FILE__, __LINE__, method ); } - else if( Debug_level ){ + else if (Debug_level) { printf("DEBUG %s/%d: pread will fail when it reads from a fifo\n", __FILE__, __LINE__ ); } @@ -1205,14 +1205,14 @@ long wrd; /* to allow future features, use zero for now */ * Otherwise there is not necessarily a signal handler to trap * the signal. */ - if ( sig && !(method & LIO_USE_SIGNAL) && - ! (method & LIO_WAIT_SIGTYPES) ){ + if (sig && !(method & LIO_USE_SIGNAL) && + ! (method & LIO_WAIT_SIGTYPES) ) { sig=0; /* ignore signal parameter */ } #if defined(sgi) || (defined(__linux__)&& !defined(__UCLIBC__)) - if ( sig && (method & LIO_WAIT_CBTYPES) ) + if (sig && (method & LIO_WAIT_CBTYPES)) sig=0; /* ignore signal parameter */ #endif @@ -1224,7 +1224,7 @@ long wrd; /* to allow future features, use zero for now */ *** restoring the signal handler could be added *** */ - if ( sig && (method & LIO_WAIT_SIGTYPES) ){ + if (sig && (method & LIO_WAIT_SIGTYPES)) { #ifdef CRAY sigctl(SCTL_REG, sig, lio_async_signal_handler); #endif @@ -1235,7 +1235,7 @@ long wrd; /* to allow future features, use zero for now */ #endif /* CRAY */ } #if defined(sgi) - else if( method & LIO_WAIT_CBTYPES ){ + else if (method & LIO_WAIT_CBTYPES) { aiocbp.aio_sigevent.sigev_notify = SIGEV_CALLBACK; aiocbp.aio_sigevent.sigev_func = lio_async_callback_handler; /* sival_int just has to be something that I can use @@ -1245,7 +1245,7 @@ long wrd; /* to allow future features, use zero for now */ } #endif #if defined(__linux__) && !defined(__UCLIBC__) - else if( method & LIO_WAIT_CBTYPES ){ + else if (method & LIO_WAIT_CBTYPES) { aiocbp.aio_sigevent.sigev_notify = SIGEV_THREAD; aiocbp.aio_sigevent.sigev_notify_function = lio_async_callback_handler; /* sival_int just has to be something that I can use @@ -1264,7 +1264,7 @@ long wrd; /* to allow future features, use zero for now */ * bytes written/read. */ - if ( (method & LIO_IO_SYNC) || (method & (LIO_IO_TYPES | LIO_IO_ATYPES)) == 0 ){ + if ((method & LIO_IO_SYNC) || (method & (LIO_IO_TYPES | LIO_IO_ATYPES)) == 0) { /* * read(2) is used if LIO_IO_SYNC bit is set or not none * of the LIO_IO_TYPES bits are set (default). @@ -1274,11 +1274,11 @@ long wrd; /* to allow future features, use zero for now */ "read(%d, buf, %d)", fd, size); io_type="read"; - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } - while(1) { + while (1) { if (((ret = read(fd, buffer, size)) == -1) && errno!=EINTR && errno!=EAGAIN) { sprintf(Errormsg, "%s/%d read(%d, buf, %d) ret:-1, errno=%d %s", __FILE__, __LINE__, @@ -1286,9 +1286,9 @@ long wrd; /* to allow future features, use zero for now */ return -errno; } - if(ret==0) return 0; - if(ret!=-1) { - if ( ret != size ) { + if (ret==0) return 0; + if (ret!=-1) { + if (ret != size) { sprintf(Errormsg, "%s/%d read(%d, buf, %d) returned=%d", __FILE__, __LINE__, @@ -1297,7 +1297,7 @@ long wrd; /* to allow future features, use zero for now */ buffer+=ret; } else { - if ( Debug_level > 1 ) + if (Debug_level > 1) printf("DEBUG %s/%d: read completed without error (ret %d)\n", __FILE__, __LINE__, ret); @@ -1309,13 +1309,13 @@ long wrd; /* to allow future features, use zero for now */ } - else if ( method & LIO_IO_ASYNC ) { + else if (method & LIO_IO_ASYNC) { #ifdef CRAY sprintf(Lio_SysCall, "reada(%d, buf, %d, &status, %d)", fd, size, sig); io_type="reada"; - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } @@ -1334,25 +1334,25 @@ long wrd; /* to allow future features, use zero for now */ "aio_read(fildes=%d, buf, nbytes=%d, signo=%d)", fd, size, sig); io_type="aio_read"; - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } - if( sig ) + if (sig) sighold( sig ); if ((ret = aio_read(&aiocbp)) == -1) { sprintf(Errormsg, "%s/%d aio_read(fildes=%d, buf, nbytes=%d, signo=%d) ret:-1, errno=%d %s", __FILE__, __LINE__, fd, size, sig, errno, strerror(errno)); - if( sig ) + if (sig) sigrelse( sig ); return -errno; } #endif } /* LIO_IO_ASYNC */ - else if ( method & LIO_IO_SLISTIO ) { + else if (method & LIO_IO_SLISTIO) { #ifdef CRAY request.li_opcode = LO_READ; request.li_fildes = fd; @@ -1371,12 +1371,12 @@ long wrd; /* to allow future features, use zero for now */ "listio(LC_WAIT, &req, 1) LO_READ, fd:%d, nbyte:%d", fd, size); - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } sigoff(); - if ( listio(listio_cmd, &request, 1) == -1 ) { + if (listio(listio_cmd, &request, 1) == -1) { sprintf(Errormsg, "%s/%d %s failed, fd:%d, nbyte:%d errno=%d %s", __FILE__, __LINE__, Lio_SysCall, fd, size, errno, strerror(errno)); @@ -1384,7 +1384,7 @@ long wrd; /* to allow future features, use zero for now */ return -errno; } - if ( Debug_level > 1 ) + if (Debug_level > 1) printf("DEBUG %s/%d: %s did not return -1\n", __FILE__, __LINE__, Lio_SysCall); @@ -1400,22 +1400,22 @@ long wrd; /* to allow future features, use zero for now */ "lio_listio(LIO_WAIT, aiolist, 1, NULL) LIO_READ, fd:%d, nbyte:%d", fd, size); - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } - if( sig ) + if (sig) sighold( sig ); - if ( lio_listio(listio_cmd, aiolist, 1, NULL) == -1 ) { + if (lio_listio(listio_cmd, aiolist, 1, NULL) == -1) { sprintf(Errormsg, "%s/%d %s failed, fd:%d, nbyte:%d errno=%d %s", __FILE__, __LINE__, Lio_SysCall, fd, size, errno, strerror(errno)); - if( sig ) + if (sig) sigrelse( sig ); return -errno; } - if ( Debug_level > 1 ) + if (Debug_level > 1) printf("DEBUG %s/%d: %s did not return -1\n", __FILE__, __LINE__, Lio_SysCall); @@ -1424,7 +1424,7 @@ long wrd; /* to allow future features, use zero for now */ #endif }/* LIO_IO_SLISTIO */ - else if ( method & LIO_IO_ALISTIO ) { + else if (method & LIO_IO_ALISTIO) { #ifdef CRAY request.li_opcode = LO_READ; request.li_fildes = fd; @@ -1443,12 +1443,12 @@ long wrd; /* to allow future features, use zero for now */ "listio(LC_START, &req, 1) LO_READ, fd:%d, nbyte:%d", fd, size); - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } sigoff(); - if ( listio(listio_cmd, &request, 1) == -1 ) { + if (listio(listio_cmd, &request, 1) == -1) { sprintf(Errormsg, "%s/%d %s failed, fd:%d, nbyte:%d errno=%d %s", __FILE__, __LINE__, Lio_SysCall, fd, size, errno, strerror(errno)); @@ -1465,17 +1465,17 @@ long wrd; /* to allow future features, use zero for now */ "lio_listio(LIO_NOWAIT, aiolist, 1, NULL) LIO_READ, fd:%d, nbyte:%d", fd, size); - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } - if( sig ) + if (sig) sighold( sig ); - if ( lio_listio(listio_cmd, aiolist, 1, NULL) == -1 ) { + if (lio_listio(listio_cmd, aiolist, 1, NULL) == -1) { sprintf(Errormsg, "%s/%d %s failed, fd:%d, nbyte:%d errno=%d %s", __FILE__, __LINE__, Lio_SysCall, fd, size, errno, strerror(errno)); - if( sig ) + if (sig) sigrelse( sig ); return -errno; } @@ -1483,13 +1483,13 @@ long wrd; /* to allow future features, use zero for now */ } /* LIO_IO_ALISTIO */ #ifndef CRAY - else if ( method & LIO_IO_SYNCV ) { + else if (method & LIO_IO_SYNCV) { io_type="readv(2)"; sprintf(Lio_SysCall, "readv(%d, &iov, 1) nbyte:%d", fd, size); - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } if ((ret = readv(fd, &iov, 1)) == -1) { @@ -1499,13 +1499,13 @@ long wrd; /* to allow future features, use zero for now */ return -errno; } - if ( ret != size ) { + if (ret != size) { sprintf(Errormsg, "%s/%d readv(%d, iov, 1) nbyte:%d returned=%d", __FILE__, __LINE__, fd, size, ret); } - else if ( Debug_level > 1 ) + else if (Debug_level > 1) printf("DEBUG %s/%d: readv completed without error (ret %d)\n", __FILE__, __LINE__, ret); @@ -1514,13 +1514,13 @@ long wrd; /* to allow future features, use zero for now */ #endif #if defined(sgi) || (defined(__linux__) && !defined(__UCLIBC__)) - else if ( method & LIO_IO_SYNCP ) { + else if (method & LIO_IO_SYNCP) { io_type="pread(2)"; sprintf(Lio_SysCall, "pread(%d, buf, %d, %lld)", fd, size, (long long)poffset); - if ( Debug_level ) { + if (Debug_level) { printf("DEBUG %s/%d: %s\n", __FILE__, __LINE__, Lio_SysCall); } if ((ret = pread(fd, buffer, size, poffset)) == -1) { @@ -1530,13 +1530,13 @@ long wrd; /* to allow future features, use zero for now */ return -errno; } - if ( ret != size ) { + if (ret != size) { sprintf(Errormsg, "%s/%d pread(%d, buf, %d, %lld) returned=%d", __FILE__, __LINE__, fd, size, (long long)poffset, ret); } - else if ( Debug_level > 1 ) + else if (Debug_level > 1) printf("DEBUG %s/%d: pread completed without error (ret %d)\n", __FILE__, __LINE__, ret); @@ -1565,7 +1565,7 @@ long wrd; /* to allow future features, use zero for now */ * return the error value (errno) to the caller. * Note: Errormsg should already have been updated. */ - if ( ret < 0 ) { + if (ret < 0) { return ret; } @@ -1573,7 +1573,7 @@ long wrd; /* to allow future features, use zero for now */ * If i/o was not waited for (may not have been completed at this time), * return the size that was requested. */ - if ( ret == 1 ) + if (ret == 1) return size; /* @@ -1617,20 +1617,20 @@ int lio_check_asyncio(char *io_type, int size, struct iosw *status) int ret; #ifdef CRAY - if ( status->sw_error ) { + if (status->sw_error) { sprintf(Errormsg, "%s/%d %s, sw_error set = %d %s, sw_count = %d", __FILE__, __LINE__, io_type, status->sw_error, strerror(status->sw_error), status->sw_count); return -status->sw_error; } - else if ( status->sw_count != size ) { + else if (status->sw_count != size) { sprintf(Errormsg, "%s/%d %s, sw_count not as expected(%d), but actual:%d", __FILE__, __LINE__, io_type, size, status->sw_count); } - else if ( Debug_level > 1 ) { + else if (Debug_level > 1) { printf("DEBUG %s/%d: %s completed without error (sw_error == 0, sw_count == %d)\n", __FILE__, __LINE__, io_type, status->sw_count); } @@ -1646,16 +1646,16 @@ int lio_check_asyncio(char *io_type, int size, struct iosw *status) * completion signal here otherwise it'll hang around and bite us * later. */ - if( aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL ) + if (aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL) sigrelse( aiocbp->aio_sigevent.sigev_signo ); ret = aio_error( aiocbp ); - while( ret == EINPROGRESS ){ + while (ret == EINPROGRESS) { ret = aio_error( aiocbp ); ++cnt; } - if( cnt > 1 ){ + if (cnt > 1) { sprintf(Errormsg, "%s/%d %s, aio_error had to loop on EINPROGRESS, cnt=%d; random method %#o; sigev_notify=%s", __FILE__, __LINE__, io_type, cnt, method, @@ -1669,7 +1669,7 @@ int lio_check_asyncio(char *io_type, int size, struct iosw *status) return -ret; } - if( ret != 0 ){ + if (ret != 0) { sprintf(Errormsg, "%s/%d %s, aio_error = %d %s; random method %#o", __FILE__, __LINE__, io_type, @@ -1678,16 +1678,16 @@ int lio_check_asyncio(char *io_type, int size, struct iosw *status) return -ret; } ret = aio_return( aiocbp ); - if( ret != size ){ + if (ret != size) { sprintf(Errormsg, "%s/%d %s, aio_return not as expected(%d), but actual:%d", __FILE__, __LINE__, io_type, size, ret); #ifdef BUG1_workaround - if( ret == 0 ){ + if (ret == 0) { ret = size; - if( Debug_level > 1 ){ + if (Debug_level > 1) { printf("WARN %s/%d: %s completed with bug1_workaround (aio_error == 0, aio_return now == %d)\n", __FILE__, __LINE__, io_type, ret); } @@ -1695,7 +1695,7 @@ int lio_check_asyncio(char *io_type, int size, struct iosw *status) #endif /* BUG1_workaround */ } - else if( Debug_level > 1 ){ + else if (Debug_level > 1) { printf("DEBUG %s/%d: %s completed without error (aio_error == 0, aio_return == %d)\n", __FILE__, __LINE__, io_type, ret); } @@ -1741,28 +1741,28 @@ int lio_wait4asyncio(int method, int fd, struct iosw **statptr) const struct aiocb *aioary[1]; #endif - if ( (method & LIO_WAIT_RECALL) + if ((method & LIO_WAIT_RECALL) #if defined(sgi) || (defined(__linux__)&& !defined(__UCLIBC__)) || (method & LIO_WAIT_CBSUSPEND) || (method & LIO_WAIT_SIGSUSPEND) #endif - || ((method & LIO_WAIT_TYPES) == 0) ){ + || ((method & LIO_WAIT_TYPES) == 0) ) { /* * If method has LIO_WAIT_RECALL bit set or method does * not have any wait method bits set (default), use recall/aio_suspend. */ #ifdef CRAY - if ( Debug_level > 2 ) + if (Debug_level > 2) printf("DEBUG %s/%d: wait method : recall\n", __FILE__, __LINE__); sigon(); - if ( recall(fd, 1, statptr) ) { + if (recall(fd, 1, statptr)) { sprintf(Errormsg, "%s/%d recall(%d, 1, stat) failed, errno:%d %s", __FILE__, __LINE__, fd, errno, strerror(errno)); return -errno; } #else - if ( Debug_level > 2 ) + if (Debug_level > 2) printf("DEBUG %s/%d: wait method : aio_suspend, sigev_notify=%s\n", __FILE__, __LINE__, (aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL ? "signal" : aiocbp->aio_sigevent.sigev_notify == SIGEV_NONE ? "none" : @@ -1774,9 +1774,9 @@ int lio_wait4asyncio(int method, int fd, struct iosw **statptr) aioary[0] = aiocbp; ret = aio_suspend( aioary, 1, NULL ); - if( (ret == -1) && (errno == EINTR) ){ - if( aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL ){ - if( Debug_level > 2 ){ + if ((ret == -1) && (errno == EINTR)) { + if (aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL) { + if (Debug_level > 2) { printf("DEBUG %s/%d: aio_suspend received EINTR, sigev_notify=SIGEV_SIGNAL -- ok\n", __FILE__, __LINE__ ); } @@ -1794,7 +1794,7 @@ int lio_wait4asyncio(int method, int fd, struct iosw **statptr) return -errno; } } - else if ( ret ) { + else if (ret) { sprintf(Errormsg, "%s/%d aio_suspend(fildes=%d, aioary, 1, NULL) failed, errno:%d %s", __FILE__, __LINE__, fd, errno, strerror(errno)); @@ -1802,8 +1802,8 @@ int lio_wait4asyncio(int method, int fd, struct iosw **statptr) } #endif - } else if ( method & LIO_WAIT_ACTIVE ) { - if ( Debug_level > 2 ) + } else if (method & LIO_WAIT_ACTIVE) { + if (Debug_level > 2) printf("DEBUG %s/%d: wait method : active\n", __FILE__, __LINE__); #ifdef CRAY sigon(); @@ -1812,7 +1812,7 @@ int lio_wait4asyncio(int method, int fd, struct iosw **statptr) * change to non-zero. */ cnt=0; - while ( (*statptr)->sw_flag == 0 && + while ((*statptr)->sw_flag == 0 && (*statptr)->sw_count == 0 && (*statptr)->sw_error == 0 ) { cnt++; @@ -1820,25 +1820,25 @@ int lio_wait4asyncio(int method, int fd, struct iosw **statptr) #else /* loop while aio_error() returns EINPROGRESS */ cnt=0; - while(1){ + while (1) { ret = aio_error( aiocbp ); - if( (ret == 0) || (ret != EINPROGRESS) ){ + if ((ret == 0) || (ret != EINPROGRESS)) { break; } ++cnt; } #endif - if ( Debug_level > 5 && cnt && (cnt % 50) == 0 ) + if (Debug_level > 5 && cnt && (cnt % 50) == 0) printf("DEBUG %s/%d: wait active cnt = %d\n", __FILE__, __LINE__, cnt); - } else if ( method & LIO_WAIT_SIGPAUSE ) { - if ( Debug_level > 2 ) + } else if (method & LIO_WAIT_SIGPAUSE) { + if (Debug_level > 2) printf("DEBUG %s/%d: wait method : sigpause\n", __FILE__, __LINE__); #ifdef sgi /* note: don't do the sigon() for CRAY in this case. why? -- roehrich 6/11/97 */ - if( aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL ) + if (aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL) sigrelse( aiocbp->aio_sigevent.sigev_signo ); else { printf("DEBUG %s/%d: sigev_notify != SIGEV_SIGNAL\n", __FILE__, __LINE__ ); @@ -1847,13 +1847,13 @@ int lio_wait4asyncio(int method, int fd, struct iosw **statptr) #endif pause(); - } else if ( method & LIO_WAIT_SIGACTIVE ) { - if ( Debug_level > 2 ) + } else if (method & LIO_WAIT_SIGACTIVE) { + if (Debug_level > 2) printf("DEBUG %s/%d: wait method : sigactive\n", __FILE__, __LINE__); #ifdef CRAY sigon(); #else - if( aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL ) + if (aiocbp->aio_sigevent.sigev_notify == SIGEV_SIGNAL) sigrelse( aiocbp->aio_sigevent.sigev_signo ); else { printf("DEBUG %s/%d: sigev_notify != SIGEV_SIGNAL\n", __FILE__, __LINE__ ); @@ -1861,7 +1861,7 @@ int lio_wait4asyncio(int method, int fd, struct iosw **statptr) } #endif /* loop waiting for signal */ - while ( Received_signal == Rec_signal ){ + while (Received_signal == Rec_signal) { #ifdef CRAY sigon(); #else @@ -1869,8 +1869,8 @@ int lio_wait4asyncio(int method, int fd, struct iosw **statptr) #endif } - } else if ( method & LIO_WAIT_NONE ) { - if ( Debug_level > 2 ) + } else if (method & LIO_WAIT_NONE) { + if (Debug_level > 2) printf("DEBUG %s/%d: wait method : none\n", __FILE__, __LINE__); /* It's broken because the aiocb/iosw is an automatic variable in * lio_{read,write}_buffer, so when the function returns and the @@ -1888,7 +1888,7 @@ int lio_wait4asyncio(int method, int fd, struct iosw **statptr) return -1; } else { - if( Debug_level > 2 ) + if (Debug_level > 2) printf("DEBUG %s/%d: no wait method was chosen\n", __FILE__, __LINE__ ); return -1; } @@ -1952,35 +1952,35 @@ char **argv; char *symbols = NULL; int die_on_err = 0; - while( (c = getopt(argc,argv,"s:di:")) != -1 ){ - switch(c){ + while ((c = getopt(argc,argv,"s:di:")) != -1) { + switch(c) { case 's': symbols = optarg; break; case 'd': ++die_on_err; break; case 'i': iter = atoi(optarg); break; } } - if ((fd=open("unit_test_file", O_CREAT|O_RDWR|O_TRUNC, 0777)) == -1 ) { + if ((fd=open("unit_test_file", O_CREAT|O_RDWR|O_TRUNC, 0777)) == -1) { perror("open(unit_test_file, O_CREAT|O_RDWR|O_TRUNC, 0777) failed"); exit(1); } Debug_level=9; - if ( symbols != NULL ) { - if ( (method=lio_parse_io_arg2(symbols, &err)) == -1 ){ + if (symbols != NULL) { + if ((method=lio_parse_io_arg2(symbols, &err)) == -1) { printf("lio_parse_io_arg2(%s, &err) failed, bad token starting at %s\n", symbols, err); - if( die_on_err ) + if (die_on_err) exit(1); } else printf("lio_parse_io_arg2(%s, &err) returned %#o\n", symbols, method); exit_status = 0; - for(ind=0; ind < iter; ind++ ) { + for (ind=0; ind < iter; ind++) { memset( buffer, 'A', 4096 ); - if( lseek(fd, 0, 0) == -1 ){ + if (lseek(fd, 0, 0) == -1) { printf("lseek(fd,0,0), %d, failed, errno %d\n", __LINE__, errno ); ++exit_status; @@ -1992,7 +1992,7 @@ char **argv; printf("lio_write_buffer returned %d\n", ret); memset( buffer, 'B', 4096 ); - if( lseek(fd, 0, 0) == -1 ){ + if (lseek(fd, 0, 0) == -1) { printf("lseek(fd,0,0), %d, failed, errno %d\n", __LINE__, errno ); ++exit_status; @@ -2003,15 +2003,15 @@ char **argv; } else printf("lio_read_buffer returned %d\n", ret); - for( i = 0; i < 4096; ++i ){ - if( buffer[i] != 'A' ){ + for (i = 0; i < 4096; ++i) { + if (buffer[i] != 'A') { printf(" buffer[%d] = %d\n", i, buffer[i] ); ++exit_status; break; } } - if( exit_status ) + if (exit_status) exit(exit_status); } @@ -2020,10 +2020,10 @@ char **argv; exit(0); } - for(ind=0; ind < sizeof(Unit_info)/sizeof(struct unit_info_t); ind++ ) { + for (ind=0; ind < sizeof(Unit_info)/sizeof(struct unit_info_t); ind++) { printf("\n********* write %s ***************\n", Unit_info[ind].str); - if( lseek(fd, 0, 0) == -1 ){ + if (lseek(fd, 0, 0) == -1) { printf("lseek(fd,0,0), %d, failed, errno %d\n", __LINE__, errno ); ++exit_status; @@ -2035,14 +2035,14 @@ char **argv; printf(">>>>> lio_write_buffer(fd,0%x,buffer,%d,%d,err,0) returned -1,\n err = %s\n", Unit_info[ind].method, size, Unit_info[ind].sig, err); ++exit_status; - if( die_on_err ) + if (die_on_err) exit(exit_status); } else{ printf("lio_write_buffer returned %d\n", ret); } printf("\n********* read %s ***************\n", Unit_info[ind].str); - if( lseek(fd, 0, 0) == -1 ){ + if (lseek(fd, 0, 0) == -1) { printf("lseek(fd,0,0), %d, failed, errno %d\n", __LINE__, errno ); ++exit_status; @@ -2053,17 +2053,17 @@ char **argv; printf(">>>>> lio_read_buffer(fd,0%x,buffer,%d,%d,err,0) returned -1,\n err = %s\n", Unit_info[ind].method, size, Unit_info[ind].sig, err); ++exit_status; - if( die_on_err ) + if (die_on_err) exit(exit_status); } else { printf("lio_read_buffer returned %d\n", ret); } - for( i = 0; i < 4096; ++i ){ - if( buffer[i] != 'A' ){ + for (i = 0; i < 4096; ++i) { + if (buffer[i] != 'A') { printf(" buffer[%d] = %d\n", i, buffer[i] ); ++exit_status; - if( die_on_err ) + if (die_on_err) exit(exit_status); break; } diff --git a/lib/tst_res.c b/lib/tst_res.c index 0d19f691e..a24b3ecf3 100644 --- a/lib/tst_res.c +++ b/lib/tst_res.c @@ -655,7 +655,7 @@ void tst_brk(int ttype, char *fname, void (*func)(void), char *arg_fmt, ...) tst_res(ttype, NULL, "Remaining cases not appropriate for configuration"); } else { - if ( ttype == TRETR ) + if (ttype == TRETR) tst_res(ttype, NULL, "Remaining cases retired"); else tst_res(TBROK, NULL, "Remaining cases broken"); diff --git a/lib/tst_tmpdir.c b/lib/tst_tmpdir.c index 9c9809efd..06dbe00fd 100644 --- a/lib/tst_tmpdir.c +++ b/lib/tst_tmpdir.c @@ -170,7 +170,7 @@ void tst_tmpdir(void) tst_brkm(TBROK, tmpdir_cleanup, "%s: mkdtemp(%s) failed; errno = %d: %s", FN_NAME, template, errno, strerror(errno)); - if ( (TESTDIR = strdup(template)) == NULL ) { //Error Handling for strdup() + if ((TESTDIR = strdup(template)) == NULL ) { //Error Handling for strdup() tst_brkm(TBROK, tmpdir_cleanup, "%s: strdup(%s) failed; errno = %d: %s", FN_NAME, template, errno, strerror(errno)); @@ -183,17 +183,17 @@ void tst_tmpdir(void) tst_brkm(TBROK, tmpdir_cleanup, "%s: mkstemp(%s) failed; errno = %d: %s", FN_NAME, template, errno, strerror(errno)); - if ( close(tfd) == -1 ) { + if (close(tfd) == -1) { tst_brkm(TBROK, tmpdir_cleanup, "%s: close() failed; errno = %d: %s", FN_NAME, errno, strerror(errno)); } - if ( unlink(template) == -1) { + if (unlink(template) == -1) { tst_brkm(TBROK, tmpdir_cleanup, "%s: unlink(%s) failed; errno = %d: %s", FN_NAME, template, errno, strerror(errno)); } - if ( (TESTDIR = strdup(template)) == NULL ) { + if ((TESTDIR = strdup(template)) == NULL) { tst_brkm(TBROK, tmpdir_cleanup, "%s: strdup(%s) failed; errno = %d: %s", FN_NAME, template, errno, strerror(errno)); @@ -213,11 +213,11 @@ void tst_tmpdir(void) * Change the group on this temporary directory to be that of the * gid of the person running the tests and permissions to 777. */ - if ( chown(TESTDIR, -1, getgid()) == -1 ) + if (chown(TESTDIR, -1, getgid()) == -1) tst_brkm(TBROK, tmpdir_cleanup, "chown(%s, -1, %d) failed; errno = %d: %s", TESTDIR, getgid(), errno, strerror(errno)); - if ( chmod(TESTDIR,S_IRWXU | S_IRWXG | S_IRWXO) == -1 ) + if (chmod(TESTDIR,S_IRWXU | S_IRWXG | S_IRWXO) == -1) tst_brkm(TBROK, tmpdir_cleanup, "chmod(%s,777) failed; errno %d: %s", TESTDIR, errno, strerror(errno)); @@ -233,12 +233,12 @@ void tst_tmpdir(void) * directory (if it was created), and exit. If the removal also * fails, also issue a TWARN message. */ - if ( chdir(TESTDIR) == -1 ) { + if (chdir(TESTDIR) == -1) { tst_brkm(TBROK, NULL, "%s: chdir(%s) failed; errno = %d: %s", FN_NAME, TESTDIR, errno, strerror(errno) ); /* Try to remove the directory */ - if ( !no_cleanup && rmdir(TESTDIR) == -1 ) + if (!no_cleanup && rmdir(TESTDIR) == -1) tst_resm(TWARN, "%s: rmdir(%s) failed; errno = %d: %s", FN_NAME, TESTDIR, errno, strerror(errno) ); @@ -280,7 +280,7 @@ void tst_rmdir(void) * temp dir was created by tst_tmpdir(). Thus no cleanup will be * necessary. */ - if ( (tdirectory = getenv(TDIRECTORY)) != NULL ) { + if ((tdirectory = getenv(TDIRECTORY)) != NULL) { #if UNIT_TEST printf("\"TDIRECORY\" env variable is set; no cleanup was performed\n"); #endif @@ -290,7 +290,7 @@ void tst_rmdir(void) /* * Check that TESTDIR is not NULL. */ - if ( TESTDIR == NULL ) { + if (TESTDIR == NULL) { tst_resm(TWARN, "%s: TESTDIR was NULL; no removal attempted", FN_NAME); return; @@ -300,14 +300,14 @@ void tst_rmdir(void) * Check that the value of TESTDIR is not "*" or "/". These could * have disastrous effects in a test run by root. */ - if ( strcmp(TESTDIR, "/") == 0 ) { + if (strcmp(TESTDIR, "/") == 0) { tst_resm(TWARN, "%s: Recursive remove of root directory not attempted", FN_NAME); return; } - if ( strchr(TESTDIR, '*') != NULL ) { + if (strchr(TESTDIR, '*') != NULL) { tst_resm(TWARN, "%s: Recursive remove of '*' not attempted", FN_NAME); return; @@ -317,22 +317,22 @@ void tst_rmdir(void) * Get the directory name of TESTDIR. If TESTDIR is a relative path, * get full path. */ - if ( TESTDIR[0] != '/' ) { - if ( getcwd(current_dir,PATH_MAX) == NULL ) + if (TESTDIR[0] != '/') { + if (getcwd(current_dir,PATH_MAX) == NULL) strcpy(parent_dir, TESTDIR); else sprintf(parent_dir, "%s/%s", current_dir, TESTDIR); } else { strcpy(parent_dir, TESTDIR); } - if ( (basename = strrchr(parent_dir, '/')) != NULL ) { + if ((basename = strrchr(parent_dir, '/')) != NULL) { *basename='\0'; /* terminate at end of parent_dir */ } /* * Change directory to parent_dir (The dir above TESTDIR). */ - if ( chdir(parent_dir) != 0 ) + if (chdir(parent_dir) != 0) tst_resm(TWARN, "%s: chdir(%s) failed; errno = %d: %s\nAttempting to remove temp dir anyway", FN_NAME, parent_dir, errno, strerror(errno)); @@ -340,7 +340,7 @@ void tst_rmdir(void) /* * Attempt to remove the "TESTDIR" directory, using rmobj(). */ - if ( rmobj(TESTDIR, &errmsg) == -1 ) + if (rmobj(TESTDIR, &errmsg) == -1) tst_resm(TWARN, "%s: rmobj(%s) failed: %s", FN_NAME, TESTDIR, errmsg); @@ -404,6 +404,6 @@ main() tst_rmdir(); break; } /* switch() */ - } /* while() */ + } /* while () */ } #endif /* UNIT_TEST */ diff --git a/lib/write_log.c b/lib/write_log.c index 0600b1057..5fced89fc 100644 --- a/lib/write_log.c +++ b/lib/write_log.c @@ -226,14 +226,14 @@ long offset; wbuf[reclen+1] = reclen % 256; reclen += 2; - if ( write(wfile->w_afd, wbuf, reclen) == -1 ) { + if (write(wfile->w_afd, wbuf, reclen) == -1) { sprintf(Wlog_Error_String, "Could not write log - write(%s, %s, %d) failed: %s\n", wfile->w_file, wbuf, reclen, strerror(errno)); return -1; } else { offset = lseek(wfile->w_afd, 0, SEEK_CUR) - reclen; - if ( offset == -1 ) { + if (offset == -1) { sprintf(Wlog_Error_String, "Could not reposition file pointer - lseek(%s, 0, SEEK_CUR) failed: %s\n", wfile->w_file, strerror(errno)); @@ -241,13 +241,13 @@ long offset; } } } else { - if ( (lseek(wfile->w_rfd, offset, SEEK_SET)) == -1 ) { + if ((lseek(wfile->w_rfd, offset, SEEK_SET)) == -1) { sprintf(Wlog_Error_String, "Could not reposition file pointer - lseek(%s, %ld, SEEK_SET) failed: %s\n", wfile->w_file, offset, strerror(errno)); return -1; } else { - if ( (write(wfile->w_rfd, wbuf, reclen)) == -1 ) { + if ((write(wfile->w_rfd, wbuf, reclen)) == -1) { sprintf(Wlog_Error_String, "Could not write log - write(%s, %s, %d) failed: %s\n", wfile->w_file, wbuf, reclen, strerror(errno)); @@ -285,14 +285,14 @@ long data; * Move to EOF. offset will always hold the current file offset */ - if ( (lseek(fd, 0, SEEK_END)) == -1 ) { + if ((lseek(fd, 0, SEEK_END)) == -1) { sprintf(Wlog_Error_String, "Could not reposition file pointer - lseek(%s, 0, SEEK_END) failed: %s\n", wfile->w_file, strerror(errno)); return -1; } offset = lseek(fd, 0, SEEK_CUR); - if ( (offset == -1) ) { + if ((offset == -1)) { sprintf(Wlog_Error_String, "Could not reposition file pointer - lseek(%s, 0, SEEK_CUR) failed: %s\n", wfile->w_file, strerror(errno)); @@ -320,7 +320,7 @@ long data; /* * Move to the proper file offset, and read into buf */ - if ( (lseek(fd, offset, SEEK_SET)) ==-1 ) { + if ((lseek(fd, offset, SEEK_SET)) ==-1) { sprintf(Wlog_Error_String, "Could not reposition file pointer - lseek(%s, %d, SEEK_SET) failed: %s\n", wfile->w_file, offset, strerror(errno)); diff --git a/pan/debug.c b/pan/debug.c index a89303cd6..d67c46f60 100644 --- a/pan/debug.c +++ b/pan/debug.c @@ -56,26 +56,26 @@ set_debug(char *optarg) d_area = optarg; - while(*d_area) { + while (*d_area) { d_level= strchr(d_area,':'); *d_level++ = '\0'; db_level= atoi(d_level); db_area=atoi(d_area); - if(db_area > MAXDEBUG) { + if (db_area > MAXDEBUG) { printf("Error - Debug area %s > maximum of %d\n", d_area, MAXDEBUG); exit(-1); } - while(d_area != NULL) { + while (d_area != NULL) { db_area = atoi(d_area); printf("Debug area %d set to %d\n", db_area, db_level); Debug[db_area] = db_level; - if((d_area = strchr(d_area, ',')) != NULL) + if ((d_area = strchr(d_area, ',')) != NULL) d_area++; } - if( (d_area = strchr(d_level, ',')) == NULL ) + if ((d_area = strchr(d_level, ',')) == NULL) break; } #else diff --git a/pan/debug.h b/pan/debug.h index d0fa145b3..996c9646d 100644 --- a/pan/debug.h +++ b/pan/debug.h @@ -45,13 +45,13 @@ int set_debug( char * ); extern int Debug[]; #define MAXDEBUG 30 -#define DEBUG(a,l) if(Debug[a] >= l) -#define DEBUGO(a,l,c) if(Debug[a] >= l || c) +#define DEBUG(a,l) if (Debug[a] >= l) +#define DEBUGO(a,l,c) if (Debug[a] >= l || c) #else -#define DEBUG(a,l) if(0) -#define DEBUGO(a,l,c) if(0) +#define DEBUG(a,l) if (0) +#define DEBUGO(a,l,c) if (0) #endif diff --git a/pan/ltp-bump.c b/pan/ltp-bump.c index 5ab6584db..29d3480b0 100644 --- a/pan/ltp-bump.c +++ b/pan/ltp-bump.c @@ -50,7 +50,7 @@ int main(int argc, char **argv) zoo_t zoo; int sig = SIGINT; - while((c = getopt(argc, argv, "a:s:12")) != -1) { + while ((c = getopt(argc, argv, "a:s:12")) != -1) { switch(c) { case 'a': active = (char*)malloc(strlen(optarg)+1); diff --git a/pan/ltp-pan.c b/pan/ltp-pan.c index 86cd1542c..c894de701 100644 --- a/pan/ltp-pan.c +++ b/pan/ltp-pan.c @@ -323,7 +323,7 @@ main(int argc, char **argv) } coll = get_collection(filename, optind, argc, argv); - if(!coll) + if (!coll) exit(1); if (coll->cnt == 0) { fprintf(stderr, @@ -501,7 +501,7 @@ main(int argc, char **argv) if (++c >= coll->cnt) c = 0; - } /* while( (num_active < keep_active) && (starts != 0) ) */ + } /* while ((num_active < keep_active) && (starts != 0)) */ if (starts == 0) { @@ -942,7 +942,7 @@ run_child(struct coll_entry *colle, struct tag_pgrp *active, int quiet_mode) /* if the child couldn't go through with the exec, * clean up the mess, note it, and move on */ - if(read(errpipe[0], &errlen, sizeof(errlen))) { + if (read(errpipe[0], &errlen, sizeof(errlen))) { int status; time_t end_time; int termid; @@ -1033,7 +1033,7 @@ get_collection(char *file, int optind, int argc, char **argv) int i; buf = slurp(file); - if(!buf) + if (!buf) return NULL; coll = (struct collection *) malloc(sizeof(struct collection)); @@ -1295,21 +1295,21 @@ wait_handler( int sig ) { static int lastsent = 0; - if( sig == 0 ){ + if (sig == 0) { lastsent = 0; } else { rec_signal = sig; - if( sig == SIGUSR2 ) + if (sig == SIGUSR2) return; - if( lastsent == 0 ) + if (lastsent == 0) send_signal = sig; - else if( lastsent == SIGUSR1 ) + else if (lastsent == SIGUSR1) send_signal = SIGINT; - else if( lastsent == sig ) + else if (lastsent == sig) send_signal = SIGTERM; - else if( lastsent == SIGTERM ) + else if (lastsent == SIGTERM) send_signal = SIGHUP; - else if( lastsent == SIGHUP ) + else if (lastsent == SIGHUP) send_signal = SIGKILL; lastsent = send_signal; } diff --git a/pan/reporter.c b/pan/reporter.c index 114eeeedf..1c970c67c 100644 --- a/pan/reporter.c +++ b/pan/reporter.c @@ -110,7 +110,7 @@ scanner_reporter(tags) tl = taglist; sym_seq(tags, &Key, &Data, R_FIRST); do { - if(tagcount == ntags) { + if (tagcount == ntags) { /* exceeded tag array size -- realloc */ ntags += NTAGS_START; taglist= (char **)realloc(taglist, sizeof(char *) * ntags); @@ -119,9 +119,9 @@ scanner_reporter(tags) *tl++ = Key.data; tagcount++; - } while(sym_seq(tags, &Key, &Data, R_NEXT)==0); + } while (sym_seq(tags, &Key, &Data, R_NEXT)==0); - if(tagcount == ntags) { + if (tagcount == ntags) { /* exceeded tag array size -- realloc */ ntags += NTAGS_START; taglist= (char **)realloc(taglist, sizeof(char *) * ntags); @@ -131,10 +131,10 @@ scanner_reporter(tags) *tl++ = NULL; ntags = tagcount; /* Retrieve one "stime" to get the date. */ - for(tl=taglist; *tl != NULL; tl++) { + for (tl=taglist; *tl != NULL; tl++) { strcpy(key_get, *tl); strcat(key_get, ",_keys,stime"); - if((info = (char *)sym_get(tags, key_get)) != NULL) { + if ((info = (char *)sym_get(tags, key_get)) != NULL) { clock = atoi(info); tm = gmtime(&clock); strftime(key_get, KEYSIZE, "%x", tm); @@ -150,18 +150,18 @@ scanner_reporter(tags) * internals of the sym_* data structure. */ /* dump 'em all */ - for(tl=taglist; *tl != NULL; tl++) { - if(!strcmp(*tl, "_RTS")) + for (tl=taglist; *tl != NULL; tl++) { + if (!strcmp(*tl, "_RTS")) continue; strcpy(key_get, *tl); strcat(key_get, ",_keys"); - if((Keys = sym_get(tags, key_get)) == NULL) { + if ((Keys = sym_get(tags, key_get)) == NULL) { return 0; } strcpy(key_get, *tl); - if((Tag = sym_get(tags, key_get)) != NULL) { + if ((Tag = sym_get(tags, key_get)) != NULL) { tag_report(NULL, Tag, Keys); } } @@ -192,14 +192,14 @@ scanner_test_end(alltags, ctag, keys) SYM rm; /* pointer to old tag -- to remove it */ - if(alltags == NULL || keys == NULL || ctag == NULL) + if (alltags == NULL || keys == NULL || ctag == NULL) return -1; /* for really messed up test output */ /* insert keys into tag */ sym_put(ctag, "_keys", (void *)keys, 0); /* get the tag, or build a new one */ - if((tag=(char *)sym_get(keys, "tag")) == NULL) { + if ((tag=(char *)sym_get(keys, "tag")) == NULL) { /* this is an "impossible" situation: test_output checks for this * and creates a dummy tag. */ sprintf(tagname, "no_tag_%d", notag++); @@ -212,9 +212,9 @@ scanner_test_end(alltags, ctag, keys) * Special case: duplicate tag that has an initiation_status failure * is thrown away. */ - if((rm=(SYM)sym_get(alltags, tag)) != NULL) { - if( (status=(char *)sym_get(keys, "initiation_status")) != NULL ) { - if(strcmp(status, "ok")) { + if ((rm=(SYM)sym_get(alltags, tag)) != NULL) { + if ((status=(char *)sym_get(keys, "initiation_status")) != NULL) { + if (strcmp(status, "ok")) { /* do not take new data. remove new data */ sym_rm(ctag, RM_KEY | RM_DATA); return 1; @@ -247,7 +247,7 @@ static int iscanner_test_end(alltags, ctag, keys) SYM alltags, ctag, keys; { - if(alltags == NULL || keys == NULL || ctag == NULL) + if (alltags == NULL || keys == NULL || ctag == NULL) return -1; /* for really messed up test output */ /* insert keys into tag */ diff --git a/pan/splitstr.c b/pan/splitstr.c index 6c4cea8a1..14f2f000e 100644 --- a/pan/splitstr.c +++ b/pan/splitstr.c @@ -73,9 +73,9 @@ splitstr(const char *str, const char *separator, int *argcount) * In most recoverable errors, if argcount is not NULL, * set argcount to 0. Then return NULL. */ - if ( str == NULL ) + if (str == NULL) { - if ( argcount != NULL ) + if (argcount != NULL) *argcount = 0; return(NULL); } @@ -85,9 +85,9 @@ splitstr(const char *str, const char *separator, int *argcount) */ arg_string = strdup( str ); - if ( arg_string == NULL ) + if (arg_string == NULL) { - if ( argcount != NULL ) + if (argcount != NULL) *argcount = 0; return(NULL); } @@ -97,14 +97,14 @@ splitstr(const char *str, const char *separator, int *argcount) */ arg_array = (char **)malloc( sizeof(char *) * max_toks ); - if ( arg_array == NULL ) + if (arg_array == NULL) { - if ( argcount != NULL ) + if (argcount != NULL) *argcount = 0; return(NULL); } - if(separator==NULL) + if (separator==NULL) separator = " \t"; /* @@ -113,11 +113,11 @@ splitstr(const char *str, const char *separator, int *argcount) * 'arg_array' if necessary. */ cur_tok = strtok(arg_string, separator); - while ( cur_tok != NULL ) + while (cur_tok != NULL) { arg_array[num_toks++] = cur_tok; cur_tok = strtok(NULL, separator); - if ( num_toks == max_toks ) + if (num_toks == max_toks) { max_toks += 20; arg_array = (char **)realloc((void *)arg_array, sizeof(char *)*max_toks ); @@ -128,14 +128,14 @@ splitstr(const char *str, const char *separator, int *argcount) /* * If there are any spaces left in our array, make them NULL */ - for(i=num_toks+1;i<max_toks;i++) + for (i=num_toks+1;i<max_toks;i++) arg_array[i] = NULL; /* This seems nice, but since memory is allocated on a page basis, this * isn't really helpful: * arg_array = (char **)realloc((void *)arg_array, sizeof(char *)*num_toks+1 );*/ - if ( argcount != NULL ) + if (argcount != NULL) *argcount = num_toks; /* @@ -154,9 +154,9 @@ splitstr(const char *str, const char *separator, int *argcount) */ void splitstr_free( const char **p_return ) { - if ( *p_return != NULL ) + if (*p_return != NULL) free( (char *)*p_return ); - if ( p_return != NULL ) + if (p_return != NULL) free( (char **)p_return ); } @@ -170,23 +170,23 @@ int main() char *test_str_array[test_size]; const char **ret; - for(i=0;i<test_size;i++) + for (i=0;i<test_size;i++) { snprintf(buf,16,"arg%d",i); test_str_array[i] = strdup(buf); } - for(i=0;i<test_size;i++) + for (i=0;i<test_size;i++) { test_str[0]='\0'; - for(y=0;y<i;y++) + for (y=0;y<i;y++) { snprintf(buf,16,"arg%d ",y); strncat(test_str,buf,16); } ret = splitstr(test_str,NULL,&size_ret); assert(size_ret == i); - for(y=0;y<i;y++) + for (y=0;y<i;y++) assert( strcmp(ret[y],test_str_array[y])==0 ); splitstr_free(ret); diff --git a/pan/symbol.c b/pan/symbol.c index fa9e8aa58..bdd5843c1 100644 --- a/pan/symbol.c +++ b/pan/symbol.c @@ -86,7 +86,7 @@ SYM newsym() { SYM h; - if((h=(SYM)malloc(sizeof(struct symh))) == NULL) { + if ((h=(SYM)malloc(sizeof(struct symh))) == NULL) { sym_error="sym header malloc failed!"; return(NULL); } @@ -102,7 +102,7 @@ mknode(struct sym *next, char *key, void *data) { struct sym *n; - if((n=(struct sym *)malloc(sizeof(struct sym))) == NULL) { + if ((n=(struct sym *)malloc(sizeof(struct sym))) == NULL) { sym_error="sym node malloc failed!"; return(NULL); } @@ -111,7 +111,7 @@ mknode(struct sym *next, char *key, void *data) n->key = strdup(key); n->data = data; - if(n->key == NULL) { + if (n->key == NULL) { sym_error="sym node strdup(key) failed!"; return(NULL); } @@ -124,8 +124,8 @@ mknode(struct sym *next, char *key, void *data) static struct sym * find_key1(struct sym *sym, char *key) { - while(sym != NULL) - if(strcmp(sym->key, key) == 0) + while (sym != NULL) + if (strcmp(sym->key, key) == 0) return(sym); else sym=sym->next; @@ -140,20 +140,20 @@ add_key(SYM sym, char *key, void *data) { register struct sym *sn; - if(sym->sym == NULL) + if (sym->sym == NULL) { sym->sym = mknode(NULL, key, data); - if(sym->sym == NULL) + if (sym->sym == NULL) { return(-1); } } else { - for( sn=sym->sym; sn!=NULL && sn->next != NULL; sn=sn->next ); + for (sn=sym->sym; sn!=NULL && sn->next != NULL; sn=sn->next); sn->next = mknode(NULL, key, data); assert(sn->next != NULL); - if(sn->next == NULL) + if (sn->next == NULL) return(-1); } return(0); @@ -206,39 +206,39 @@ sym_put(SYM sym, char *key, void *data, int flags) SYM csym, ncsym; /* search: current symbol table */ struct sym *nsym = NULL; /* search: found symbol entry */ - if(sym == NULL) + if (sym == NULL) return(EINVAL); nkey = strdup(key); keys = splitstr(key, ",",NULL); - if(keys == NULL) + if (keys == NULL) return(EINVAL); - for(kk=(char **)keys, csym = sym; + for (kk=(char **)keys, csym = sym; *kk != NULL && (nsym=find_key1(csym->sym, *kk)) != NULL; csym=nsym->data) { - if(*++kk == NULL) + if (*++kk == NULL) break; - if(nsym->data == NULL) { /* fatal error */ + if (nsym->data == NULL) { /* fatal error */ free(nkey); splitstr_free(keys); return(ENOTDIR); } - if( ((SYM) (nsym->data))->magic != SYM_MAGIC ) { + if (((SYM) (nsym->data))->magic != SYM_MAGIC) { free(nkey); splitstr_free(keys); return(ENOTDIR); } } - if(*kk == NULL) { /* found a complete match */ + if (*kk == NULL) { /* found a complete match */ free(nkey); splitstr_free(keys); - if(flags == PUT_REPLACE) { + if (flags == PUT_REPLACE) { nsym->data = data; return(0); } else { @@ -247,8 +247,8 @@ sym_put(SYM sym, char *key, void *data, int flags) } /* csym is a ptr to a list */ - for(;*kk != NULL; kk++) { - if(*(kk+1) != NULL) { + for (;*kk != NULL; kk++) { + if (*(kk+1) != NULL) { add_key(csym, *kk, (void *)(ncsym=newsym())); csym = ncsym; } else { @@ -275,34 +275,34 @@ void * sym_get(SYM sym, char *key) SYM csym; /* search: current symbol table */ struct sym *nsym = NULL; /* search: found symbol entry */ - if(sym == NULL) + if (sym == NULL) return(NULL); nkey=strdup(key); keys = splitstr(nkey, ",", NULL); - if(keys == NULL) + if (keys == NULL) return(NULL); - for(kk=(char **)keys, csym = sym; + for (kk=(char **)keys, csym = sym; *kk != NULL && (nsym=find_key1(csym->sym, *kk)) != NULL; csym=nsym->data) { - if(*++kk == NULL) + if (*++kk == NULL) break; - if(nsym->data == NULL) { /* fatal error */ + if (nsym->data == NULL) { /* fatal error */ free(nkey); splitstr_free(keys); return(NULL); } - if( ((SYM)(nsym->data))->magic != SYM_MAGIC ) { + if (((SYM)(nsym->data))->magic != SYM_MAGIC) { free(nkey); splitstr_free(keys); return(NULL); } } - if(*kk == NULL) { /* found a complete match */ + if (*kk == NULL) { /* found a complete match */ splitstr_free(keys); free(nkey); return(nsym->data); @@ -338,11 +338,11 @@ int */ case R_CURSOR: csym = (SYM) sym_get(sym, (char *)key->data); - if( csym == NULL || csym->magic != SYM_MAGIC ) { + if (csym == NULL || csym->magic != SYM_MAGIC) { return(2); } sym->cursor = csym->sym; - if(sym->cursor == NULL) + if (sym->cursor == NULL) return(1); key->data = sym->cursor->key; data->data = sym->cursor->data; @@ -351,7 +351,7 @@ int case R_FIRST: sym->cursor = sym->sym; - if(sym->cursor == NULL) + if (sym->cursor == NULL) return(1); key->data = sym->cursor->key; data->data = sym->cursor->data; @@ -359,11 +359,11 @@ int return(0); case R_NEXT: - if(sym->cursor == NULL) + if (sym->cursor == NULL) return(1); sym->cursor = sym->cursor->next; - if(sym->cursor == NULL) + if (sym->cursor == NULL) return(1); key->data = sym->cursor->key; @@ -390,11 +390,11 @@ sym_dump(SYM sym, int depth) register struct sym *se; /* symbol entry */ register int d; - if(sym == NULL || sym->magic != SYM_MAGIC) + if (sym == NULL || sym->magic != SYM_MAGIC) return -1; - for(se=sym->sym;se != NULL;se=se->next) { - for(d=0;d < depth; d++) { + for (se=sym->sym;se != NULL;se=se->next) { + for (d=0;d < depth; d++) { putchar('"'); putchar(' '); } printf("%s\n", se->key); @@ -413,23 +413,23 @@ sym_dump_s(SYM sym, int depth) register struct sym *se; /* symbol entry */ register int d; - if(sym == NULL) + if (sym == NULL) return 0; - if(sym->magic != SYM_MAGIC) { - for(d=0;d < depth; d++) { + if (sym->magic != SYM_MAGIC) { + for (d=0;d < depth; d++) { putchar('"'); putchar(' '); } printf(" = %s\n", (char *)sym); return 0; } - for(se=sym->sym;se != NULL;se=se->next) { - for(d=0;d < depth; d++) { + for (se=sym->sym;se != NULL;se=se->next) { + for (d=0;d < depth; d++) { putchar('"'); putchar(' '); } printf("%s", se->key); - if(((SYM)se->data)->magic == SYM_MAGIC) { + if (((SYM)se->data)->magic == SYM_MAGIC) { putchar('\n'); sym_dump_s((SYM)se->data, depth+1); } else { @@ -447,26 +447,26 @@ sym_rm(SYM sym, int flags) { register struct sym *se, *nse; /* symbol entry */ - if(sym == NULL) + if (sym == NULL) return 0; - if(sym->magic != SYM_MAGIC) { - if(!(flags&RM_DATA)) + if (sym->magic != SYM_MAGIC) { + if (!(flags&RM_DATA)) free(sym); return 0; } - for(se=sym->sym;se != NULL;) { + for (se=sym->sym;se != NULL;) { sym_rm((SYM)se->data, flags); nse=se->next; - if(flags & RM_KEY) + if (flags & RM_KEY) free(se->key); - if(flags & RM_DATA) + if (flags & RM_DATA) free(se->data); free(se); se=nse; } - if(!(flags&RM_DATA)) + if (!(flags&RM_DATA)) free(sym); return 0; } diff --git a/pan/tag_report.c b/pan/tag_report.c index 0389e715d..9065f50e0 100644 --- a/pan/tag_report.c +++ b/pan/tag_report.c @@ -63,33 +63,33 @@ test_result(tag, tcid, tc, result, tags) char **cont; const char **cont_save; - if(tcid == NULL) + if (tcid == NULL) tcid = "-"; - if(tc == NULL) + if (tc == NULL) tc = "-"; - if(tag == NULL) + if (tag == NULL) tag = "test_result: no tag"; - if(result == NULL) + if (result == NULL) result = "(RESULT IS NULL)"; strcpy(expkey, "contacts"); /* note: the sym_get here does _not_ change the "cursor" */ - if((expert = (char *)sym_get(tags, expkey)) == NULL) { + if ((expert = (char *)sym_get(tags, expkey)) == NULL) { expert = "UNKNOWN"; } /* ' tr " " "_" ' */ - for(c = result; *c; c++) { - if(*c == ' ') { + for (c = result; *c; c++) { + if (*c == ' ') { *c = '_'; } } - if(*result == '\0') + if (*result == '\0') result = "?"; /* split contacts on "," and print out a line for each */ cont_save = splitstr(expert, ",", NULL); - for(cont=(char **)cont_save;*cont != NULL; cont++) { + for (cont=(char **)cont_save;*cont != NULL; cont++) { printf(FORMAT, tag, tcid, tc, result, *cont); } splitstr_free(cont_save); @@ -133,7 +133,7 @@ cuts_report(tags, keys, at, tag ) /* parse analysis type: cuts:tc-count */ ant = splitstr((dat=strdup(at)), ":",NULL); - if(ant[1] != NULL) + if (ant[1] != NULL) tccount=atoi(ant[1]); else tccount=0; @@ -148,22 +148,22 @@ cuts_report(tags, keys, at, tag ) tl = taglist; sym_seq(tags, &Key, &Data, R_FIRST); do { - if(tagcount == ntags) { + if (tagcount == ntags) { /* exceeded tag array size -- realloc */ ntags += NTCID_START; taglist= (char **)realloc(taglist, sizeof(char *) * ntags); tl = taglist+tagcount; } - if(strcmp((char *)Key.data, "_keys")==0) + if (strcmp((char *)Key.data, "_keys")==0) continue; DEBUG(D_REPORT, 10) printf("cuts_report: tcid %s\n", (char *)Key.data); *tl++ = Key.data; tagcount++; - } while(sym_seq(tags, &Key, &Data, R_NEXT)==0); + } while (sym_seq(tags, &Key, &Data, R_NEXT)==0); - if(tagcount == ntags) { + if (tagcount == ntags) { /* exceeded tag array size -- realloc */ ntags++; /* need just one more */ taglist= (char **)realloc(taglist, sizeof(char *) * ntags); @@ -176,7 +176,7 @@ cuts_report(tags, keys, at, tag ) /* dump all found records */ tcnum=0; - for(tl=taglist; *tl != NULL; tl++) { + for (tl=taglist; *tl != NULL; tl++) { strcpy(key_get, *tl); Key.data = (void *) key_get; @@ -190,14 +190,14 @@ cuts_report(tags, keys, at, tag ) (char *)Data.data); result = worst_case(result, (char *)Data.data); test_result(tag, *tl, (char *)Key.data, (char *)Data.data, keys); - if(atoi((char *)Key.data)) + if (atoi((char *)Key.data)) tcnum++; - } while(sym_seq(tags, &Key, &Data, R_NEXT)==0); + } while (sym_seq(tags, &Key, &Data, R_NEXT)==0); } test_result(tag, "*", "*", result, keys); - if(tccount != 0 && tccount != tcnum) + if (tccount != 0 && tccount != tcnum) test_result(tag, "-", "-", "TC count wrong", keys); free(taglist); @@ -243,39 +243,39 @@ tag_report(alltags, ctag, keys) /* Check all driver-level status first */ strcpy(key_get, "tag"); - if((tag = (char *)sym_get(keys, key_get)) == NULL) { + if ((tag = (char *)sym_get(keys, key_get)) == NULL) { return -1; } /* Check all driver-level status first */ strcpy(key_get, "initiation_status"); - if((is = (char *)sym_get(keys, key_get)) == NULL) { + if ((is = (char *)sym_get(keys, key_get)) == NULL) { test_result(tag, NULL, NULL, "no init status", keys); return -1; } - if(strcmp(is, "ok")) { + if (strcmp(is, "ok")) { test_result(tag, NULL, NULL, is, keys); } else { strcpy(key_get, "corefile"); - if((info = (char *)sym_get(keys, key_get)) != NULL) - if(strcmp(info, "no") != 0) { + if ((info = (char *)sym_get(keys, key_get)) != NULL) + if (strcmp(info, "no") != 0) { test_result(tag, NULL, NULL, "coredump", keys); } strcpy(key_get, "termination_type"); - if((tt = (char *)sym_get(keys, key_get))==NULL) { + if ((tt = (char *)sym_get(keys, key_get))==NULL) { test_result(tag, NULL, NULL, "no Term Type", keys); return -1; } - if(strcmp(tt, "exited")) { + if (strcmp(tt, "exited")) { test_result(tag, NULL, NULL, tt, keys); } strcpy(key_get, "analysis"); - if((info = (char *)sym_get(keys, key_get)) == NULL) { + if ((info = (char *)sym_get(keys, key_get)) == NULL) { test_result(tag, NULL, NULL, "no Analysis Type", keys); return -1; } @@ -284,25 +284,25 @@ tag_report(alltags, ctag, keys) * errors. Do the kind of reporting requested by the test. */ - if(strncmp(info, "none", 4) == 0 ) { + if (strncmp(info, "none", 4) == 0) { /* * If analysis is 'none', alway report the test as * a pass regardless of output or exit status. */ test_result(tag, NULL, NULL, "pass", keys); - } else if(strncmp(info, "cuts", 4)) { + } else if (strncmp(info, "cuts", 4)) { /* * If analysis is not cuts, assume it is 'exit', thus * the termination_id is used to determine pass/fail result. */ - if ( strcmp(tt, "timeout") ) { + if (strcmp(tt, "timeout")) { strcpy(key_get, "termination_id"); - if((info = (char *)sym_get(keys, key_get)) == NULL) { + if ((info = (char *)sym_get(keys, key_get)) == NULL) { test_result(tag, NULL, NULL, "no_Term_Id", keys); } else { - if(strcmp(info, "0")) { + if (strcmp(info, "0")) { test_result(tag, NULL, NULL, "fail", keys); } else { test_result(tag, NULL, NULL, "pass", keys); @@ -328,40 +328,40 @@ tag_report(alltags, ctag, keys) * End Line */ - if(extended) { + if (extended) { strcpy(key_get, "termination_id"); - if((ti = (char *)sym_get(keys, key_get)) == NULL) { + if ((ti = (char *)sym_get(keys, key_get)) == NULL) { ti = "No_Termination_ID"; } strcpy(key_get, "termination_type"); - if((tt = (char *)sym_get(keys, key_get)) == NULL) { + if ((tt = (char *)sym_get(keys, key_get)) == NULL) { tt = "No_Termination_Type"; } strcpy(key_get, "duration"); - if((duration = (char *)sym_get(keys, key_get)) == NULL) { + if ((duration = (char *)sym_get(keys, key_get)) == NULL) { duration = "No_Duration"; } strcpy(key_get, "_Start_line"); - if((sl = (char *)sym_get(keys, key_get)) == NULL) { + if ((sl = (char *)sym_get(keys, key_get)) == NULL) { sl = "No_Start_line"; } strcpy(key_get, "_End_line"); - if((el = (char *)sym_get(keys, key_get)) == NULL) { + if ((el = (char *)sym_get(keys, key_get)) == NULL) { el = "No_End_line"; } strcpy(key_get, "contacts"); - if((contact = (char *)sym_get(keys, key_get)) == NULL) { + if ((contact = (char *)sym_get(keys, key_get)) == NULL) { contact = "No_Contacts"; } strcpy(key_get, "stime"); - if((mystime = (char *)sym_get(keys, key_get)) == NULL) { + if ((mystime = (char *)sym_get(keys, key_get)) == NULL) { mystime = "No_stime"; } @@ -388,7 +388,7 @@ print_header(tags) extern int extended; - if(extended) + if (extended) out = stderr; else out = stdout; @@ -397,12 +397,12 @@ print_header(tags) /* build header out of RTS keywords */ sprintf(key_get, "_RTS"); Key.data = (void *) key_get; - if(sym_seq(tags, &Key, &Data, R_CURSOR) == 0) { + if (sym_seq(tags, &Key, &Data, R_CURSOR) == 0) { do { - if(strcmp((char *)Key.data, "PATH")==0) + if (strcmp((char *)Key.data, "PATH")==0) continue; fprintf(out, "%-20.20s %s\n", (char *)Key.data, (char *)Data.data); - } while(sym_seq(tags, &Key, &Data, R_NEXT)==0); + } while (sym_seq(tags, &Key, &Data, R_NEXT)==0); } fprintf(out, "\n"); @@ -429,7 +429,7 @@ cuts_testcase(tag, keys) extern char yytext[]; cuts_info[tok_num] = strtok(yytext, "\t "); - while(tok_num < 5 && + while (tok_num < 5 && (cuts_info[++tok_num] = strtok(NULL, "\t ")) != NULL ) ; @@ -445,7 +445,7 @@ cuts_testcase(tag, keys) } #endif - if((oldresult=(char *)sym_get(tag, key)) != NULL) { + if ((oldresult=(char *)sym_get(tag, key)) != NULL) { /* Duplicate -- assume mulitple runs */ /* keep "worst case" */ newresult = worst_case(oldresult, cuts_info[2]); @@ -474,13 +474,13 @@ worst_case(t1, t2) /* Search the table for each status, then use the index to determine which has a lower precedence */ - for(w1=worst; *w1 != NULL && strcmp(t1,*w1); w1++) + for (w1=worst; *w1 != NULL && strcmp(t1,*w1); w1++) ; - for(w2=worst; *w2 != NULL && strcmp(t2,*w2); w2++) + for (w2=worst; *w2 != NULL && strcmp(t2,*w2); w2++) ; - if(w1 < w2) + if (w1 < w2) return(t1); else return(t2); diff --git a/pan/zoolib.c b/pan/zoolib.c index 8f7bf6f07..1685b947a 100644 --- a/pan/zoolib.c +++ b/pan/zoolib.c @@ -260,7 +260,7 @@ zoo_clear(zoo_t z, pid_t p) if (zoo_unlock(z)) return -1; - if(!found) { + if (!found) { snprintf(zoo_error, ZELEN, "zoo_clear() did not find pid(%d)", p); @@ -387,12 +387,12 @@ cat_args(int argc, char **argv) int a, size; char *cmd; - for( size = a = 0; a < argc; a++) { + for (size = a = 0; a < argc; a++) { size += strlen(argv[a]); size++; } - if( (cmd = (char *)malloc(size)) == NULL ) { + if ((cmd = (char *)malloc(size)) == NULL) { snprintf(zoo_error, ZELEN, "Malloc Error, %s/%d", __FILE__, __LINE__); @@ -400,8 +400,8 @@ cat_args(int argc, char **argv) } *cmd='\0'; - for(a = 0; a < argc ; a++) { - if(a != 0) + for (a = 0; a < argc ; a++) { + if (a != 0) strcat(cmd, " "); strcat(cmd, argv[a]); } @@ -450,12 +450,12 @@ main(int argc, char *argv[]) zoo_mark_args(test_zoo, getpid(), test_tag, argc, argv); - for(j = 0; j < 5; j++) { - for(i = 0; i < 20; i++) { + for (j = 0; j < 5; j++) { + for (i = 0; i < 20; i++) { zt_add(test_zoo, i); } - for(; i >=0; i--) { + for (; i >=0; i--) { zoo_clear(test_zoo, i); } } |