Skip to content

Commit

Permalink
tools: Avoid comma separated statements
Browse files Browse the repository at this point in the history
Use semicolons and braces.

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
  • Loading branch information
JoePerches authored and shuahkh committed Oct 2, 2020
1 parent c8bd596 commit aa80377
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 128 deletions.
10 changes: 6 additions & 4 deletions tools/lib/subcmd/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
ci = cj = ei = 0;
while (ci < cmds->cnt && ei < excludes->cnt) {
cmp = strcmp(cmds->names[ci]->name, excludes->names[ei]->name);
if (cmp < 0)
if (cmp < 0) {
cmds->names[cj++] = cmds->names[ci++];
else if (cmp == 0)
ci++, ei++;
else if (cmp > 0)
} else if (cmp == 0) {
ci++;
ei++;
} else if (cmp > 0) {
ei++;
}
}

while (ci < cmds->cnt)
Expand Down
14 changes: 9 additions & 5 deletions tools/power/cpupower/utils/cpufreq-set.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,17 @@ static unsigned long string_to_frequency(const char *str)
continue;

if (str[cp] == '.') {
while (power > -1 && isdigit(str[cp+1]))
cp++, power--;
while (power > -1 && isdigit(str[cp+1])) {
cp++;
power--;
}
}
if (power >= -1) /* not enough => pad */
if (power >= -1) { /* not enough => pad */
pad = power + 1;
else /* to much => strip */
pad = 0, cp += power + 1;
} else { /* too much => strip */
pad = 0;
cp += power + 1;
}
/* check bounds */
if (cp <= 0 || cp + pad > NORM_FREQ_LEN - 1)
return 0;
Expand Down
18 changes: 12 additions & 6 deletions tools/testing/selftests/vm/gup_benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,16 @@ int main(int argc, char **argv)
gup.flags |= FOLL_WRITE;

fd = open("/sys/kernel/debug/gup_benchmark", O_RDWR);
if (fd == -1)
perror("open"), exit(1);
if (fd == -1) {
perror("open");
exit(1);
}

p = mmap(NULL, size, PROT_READ | PROT_WRITE, flags, filed, 0);
if (p == MAP_FAILED)
perror("mmap"), exit(1);
if (p == MAP_FAILED) {
perror("mmap");
exit(1);
}
gup.addr = (unsigned long)p;

if (thp == 1)
Expand All @@ -123,8 +127,10 @@ int main(int argc, char **argv)

for (i = 0; i < repeats; i++) {
gup.size = size;
if (ioctl(fd, cmd, &gup))
perror("ioctl"), exit(1);
if (ioctl(fd, cmd, &gup)) {
perror("ioctl");
exit(1);
}

printf("Time: get:%lld put:%lld us", gup.get_delta_usec,
gup.put_delta_usec);
Expand Down
Loading

0 comments on commit aa80377

Please sign in to comment.