cyclictest: Align option fixes
These changes make the align option truly optional as claimed.
1. Rename disaligned to offset for readability.
2. Fix the aligned option so that if no optional argument is given,
the offset defaults to 0
3. Fix some white space problems as reported by checkpatch.pl in the kernel
Signed-off-by: John Kacur <jkacur@redhat.com>
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index bbdcf93..7ca621b 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -185,7 +185,7 @@
static int use_fifo = 0;
static pthread_t fifo_threadid;
static int aligned = 0;
-static int disaligned = 0;
+static int offset = 0;
static pthread_cond_t refresh_on_max_cond = PTHREAD_COND_INITIALIZER;
static pthread_mutex_t refresh_on_max_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -777,13 +777,12 @@
/* Get current time */
if(aligned){
pthread_barrier_wait(&globalt_barr);
- if(par->tnum==0){
+ if(par->tnum==0)
clock_gettime(par->clock, &globalt);
- }
pthread_barrier_wait(&align_barr);
now = globalt;
- if(disaligned){
- now.tv_nsec += disaligned * par->tnum;
+ if(offset) {
+ now.tv_nsec += offset * par->tnum;
tsnorm(&now);
}
}
@@ -1177,7 +1176,7 @@
{"help", no_argument, NULL, OPT_HELP },
{NULL, 0, NULL, 0}
};
- int c = getopt_long(argc, argv, "a::A:b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:",
+ int c = getopt_long(argc, argv, "a::A::b:Bc:Cd:D:Efh:H:i:Il:MnNo:O:p:PmqrRsSt::uUvD:wWT:",
long_options, &option_index);
if (c == -1)
break;
@@ -1201,7 +1200,11 @@
case OPT_ALIGNED:
aligned=1;
if (optarg != NULL)
- disaligned = atoi(optarg);
+ offset = atoi(optarg);
+ else if (optind<argc && atoi(argv[optind]))
+ offset = atoi(argv[optind]);
+ else
+ offset = 0;
break;
case 'b':
case OPT_BREAKTRACE:
@@ -1443,8 +1446,8 @@
error = 1;
if (aligned) {
- pthread_barrier_init (&globalt_barr, NULL, num_threads);
- pthread_barrier_init (&align_barr, NULL, num_threads);
+ pthread_barrier_init(&globalt_barr, NULL, num_threads);
+ pthread_barrier_init(&align_barr, NULL, num_threads);
}
if (error)