Skip to content

Commit

Permalink
Do not reuse variable names in subscopes and delete useless blank lines
Browse files Browse the repository at this point in the history
  • Loading branch information
luochunsheng authored and andikleen committed Aug 25, 2022
1 parent 7dcc223 commit fb744b2
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 19 deletions.
4 changes: 1 addition & 3 deletions libnuma.c
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,7 @@ __numa_parse_cpustring(const char *s, struct bitmask *allowed_cpus_ptr)
int conf_cpus = numa_num_configured_cpus();
char *end;
struct bitmask *mask;
int i;

mask = numa_allocate_cpumask();

Expand All @@ -2076,7 +2077,6 @@ __numa_parse_cpustring(const char *s, struct bitmask *allowed_cpus_ptr)
}
do {
unsigned long arg;
int i;

if (!strcmp(s,"all")) {
copy_bitmask_to_bitmask(allowed_cpus_ptr, mask);
Expand All @@ -2098,7 +2098,6 @@ __numa_parse_cpustring(const char *s, struct bitmask *allowed_cpus_ptr)
if (*s == '-') {
char *end2;
unsigned long arg2;
int i;
arg2 = get_nr(++s, &end2, allowed_cpus_ptr, relative);
if (end2 == s) {
numa_warn(W_cpuparse, "missing cpu argument %s\n", s);
Expand All @@ -2120,7 +2119,6 @@ __numa_parse_cpustring(const char *s, struct bitmask *allowed_cpus_ptr)
if (s[-1] != '\0')
goto err;
if (invert) {
int i;
for (i = 0; i < conf_cpus; i++) {
if (numa_bitmask_isbitset(mask, i))
numa_bitmask_clearbit(mask, i);
Expand Down
1 change: 0 additions & 1 deletion migratepages.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ int main(int argc, char *argv[])
}

rc = numa_migrate_pages(pid, fromnodes, tonodes);

if (rc < 0) {
perror("migrate_pages");
return 1;
Expand Down
2 changes: 0 additions & 2 deletions migspeed.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ static void displaymap(void)
if (!strstr(buffer, "bind"))
continue ;
printf("%s", buffer);

}
fclose(f);
}
Expand Down Expand Up @@ -131,7 +130,6 @@ int main(int argc, char *argv[])
pages, pagesize);

memory = memalign(pagesize, bytes);

if (!memory) {
printf("Out of Memory\n");
exit(2);
Expand Down
6 changes: 3 additions & 3 deletions numastat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ int node_and_digits(const struct dirent *dptr)
return 1;
}

static void init_node_ix_map_and_header(int compatibility_mode)
static void init_node_ix_map_and_header(void)
{
// Count directory names of the form: /sys/devices/system/node/node<N>
struct dirent **namelist;
Expand Down Expand Up @@ -1196,7 +1196,7 @@ static void free_node_ix_map_and_header(void)

static double get_huge_page_size_in_bytes(void)
{
double huge_page_size = 0;;
double huge_page_size = 0;
FILE *fs = fopen("/proc/meminfo", "r");
if (!fs) {
perror("Can't open /proc/meminfo");
Expand Down Expand Up @@ -1406,7 +1406,7 @@ int main(int argc, char **argv)
// with the old numastat perl script (which is included at the end of this
// file for reference)
compatibility_mode = (argc == 1);
init_node_ix_map_and_header(compatibility_mode); // enumarate the NUMA nodes
init_node_ix_map_and_header(); // enumarate the NUMA nodes
if (compatibility_mode) {
show_numastat_info();
free_node_ix_map_and_header();
Expand Down
2 changes: 0 additions & 2 deletions shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ void attach_shared(char *name, char *opt)
shmptr = mmap64(NULL, shmlen, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, shmoffset);
if (shmptr == (char*)-1)
err("shm mmap");

}

static void
Expand Down Expand Up @@ -326,7 +325,6 @@ void verify_shm(int policy, struct bitmask *nodes)

case MPOL_DEFAULT:
break;

}
}

Expand Down
1 change: 0 additions & 1 deletion stream_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ void stream_test(double *res)

if (res)
res[j] = speed;

}
}

Expand Down
4 changes: 1 addition & 3 deletions stream_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ static void usage(void)
exit(1);
}

char *policy = "default";

/* Run STREAM with a numa policy */
int main(int ac, char **av)
{
Expand All @@ -24,7 +22,7 @@ int main(int ac, char **av)
policy = parse_policy(av[1], av[2]);
if (policy == MPOL_MAX)
usage();

nodes = numa_allocate_nodemask();

if (av[1] && av[2])
Expand Down
2 changes: 0 additions & 2 deletions syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ SYMVER("numa_sched_getaffinity_v1", "numa_sched_getaffinity@libnuma_1.1")
int numa_sched_getaffinity_v1(pid_t pid, unsigned len, const unsigned long *mask)
{
return syscall(__NR_sched_getaffinity,pid,len,mask);

}

SYMVER("numa_sched_getaffinity_v2", "numa_sched_getaffinity@@libnuma_1.2")
Expand All @@ -277,7 +276,6 @@ int numa_sched_getaffinity_v2(pid_t pid, struct bitmask *mask)
return syscall(__NR_sched_getaffinity, pid, numa_bitmask_nbytes(mask),
mask->maskp);
/* sched_getaffinity returns sizeof(cpumask_t) */

}

make_internal_alias(numa_sched_getaffinity_v1);
Expand Down
2 changes: 1 addition & 1 deletion test/migrate_pages.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ int main(int argc, char **argv)
numa_move_pages(0, page_count, addr, nodes, status, 0);

printf("\nMigrating the current processes pages ...\n");

rc = numa_migrate_pages(0, old_nodes, new_nodes);

if (rc < 0) {
perror("numa_migrate_pages failed");
errors++;
Expand Down
1 change: 0 additions & 1 deletion test/move_pages.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ int main(int argc, char **argv)
pagesize = getpagesize();

nr_nodes = get_node_list();

if (nr_nodes < 2) {
printf("A minimum of 2 nodes is required for this test.\n");
exit(77);
Expand Down

0 comments on commit fb744b2

Please sign in to comment.