Skip to content

Commit

Permalink
Fix all declarations to be C prototypes
Browse files Browse the repository at this point in the history
In particular a lot of foo() -> foo(void) and some related. This
fixes a lot of warnings with -Wstrict-prototypes, some also in user
programs using numa.h

Fixes numactl#69
  • Loading branch information
Andi Kleen committed Jul 4, 2019
1 parent 9dd617c commit 25dcde0
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 30 deletions.
5 changes: 2 additions & 3 deletions libnuma.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ numa_init(void)
memset(&numa_no_nodes, 0, sizeof(numa_no_nodes));
}

static void cleanup_node_cpu_mask_v2();
static void cleanup_node_cpu_mask_v2(void);

#define FREE_AND_ZERO(x) if (x) { \
numa_bitmask_free(x); \
Expand Down Expand Up @@ -1244,8 +1244,7 @@ numa_parse_bitmap_v2(char *line, struct bitmask *mask)
}
__asm__(".symver numa_parse_bitmap_v2,numa_parse_bitmap@@libnuma_1.2");

void
static init_node_cpu_mask_v2(void)
static void init_node_cpu_mask_v2(void)
{
int nnodes = numa_max_possible_node_v2_int() + 1;
node_cpu_mask_v2 = calloc (nnodes, sizeof(struct bitmask *));
Expand Down
2 changes: 1 addition & 1 deletion mt.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define MT_LEN 624

extern void mt_init(void);
extern void mt_refill();
extern void mt_refill(void);

extern int mt_index;
extern unsigned int mt_buffer[MT_LEN];
Expand Down
24 changes: 12 additions & 12 deletions numa.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,27 +252,27 @@ void numa_set_bind_policy(int strict);
void numa_set_strict(int flag);

/* maximum nodes (size of kernel nodemask_t) */
int numa_num_possible_nodes();
int numa_num_possible_nodes(void);

/* maximum cpus (size of kernel cpumask_t) */
int numa_num_possible_cpus();
int numa_num_possible_cpus(void);

/* nodes in the system */
int numa_num_configured_nodes();
int numa_num_configured_nodes(void);

/* maximum cpus */
int numa_num_configured_cpus();
int numa_num_configured_cpus(void);

/* maximum cpus allowed to current task */
int numa_num_task_cpus();
int numa_num_thread_cpus(); /* backward compatibility */
int numa_num_task_cpus(void);
int numa_num_thread_cpus(void); /* backward compatibility */

/* maximum nodes allowed to current task */
int numa_num_task_nodes();
int numa_num_thread_nodes(); /* backward compatibility */
int numa_num_task_nodes(void);
int numa_num_thread_nodes(void); /* backward compatibility */

/* allocate a bitmask the size of the kernel cpumask_t */
struct bitmask *numa_allocate_cpumask();
struct bitmask *numa_allocate_cpumask(void);

static inline void numa_free_cpumask(struct bitmask *b)
{
Expand Down Expand Up @@ -341,7 +341,7 @@ static inline void numa_set_interleave_mask_compat(nodemask_t *nodemask)
numa_set_interleave_mask(&tmp);
}

static inline nodemask_t numa_get_interleave_mask_compat()
static inline nodemask_t numa_get_interleave_mask_compat(void)
{
struct bitmask *tp;
nodemask_t mask;
Expand Down Expand Up @@ -371,7 +371,7 @@ static inline void numa_set_membind_compat(nodemask_t *mask)
numa_set_membind(&tmp);
}

static inline nodemask_t numa_get_membind_compat()
static inline nodemask_t numa_get_membind_compat(void)
{
struct bitmask *tp;
nodemask_t mask;
Expand Down Expand Up @@ -401,7 +401,7 @@ static inline int numa_run_on_node_mask_compat(const nodemask_t *mask)
return numa_run_on_node_mask(&tmp);
}

static inline nodemask_t numa_get_run_node_mask_compat()
static inline nodemask_t numa_get_run_node_mask_compat(void)
{
struct bitmask *tp;
nodemask_t mask;
Expand Down
2 changes: 1 addition & 1 deletion numademo.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ int popcnt(unsigned long val)

int max_node, numnodes;

int get_node_list()
int get_node_list(void)
{
int a, got_nodes = 0;
long free_node_sizes;
Expand Down
20 changes: 10 additions & 10 deletions numastat.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ struct hash_entry {
int index;
} hash_table[HASH_TABLE_SIZE];

void init_hash_table() {
void init_hash_table(void) {
memset(hash_table, 0, sizeof(hash_table));
}

Expand Down Expand Up @@ -676,13 +676,13 @@ char *prog_name = NULL;
double page_size_in_bytes = 0;
double huge_page_size_in_bytes = 0;

void display_version_and_exit() {
void display_version_and_exit(void) {
char *version_string = "20130723";
printf("%s version: %s: %s\n", prog_name, version_string, __DATE__);
exit(EXIT_SUCCESS);
}

void display_usage_and_exit() {
void display_usage_and_exit(void) {
fprintf(stderr, "Usage: %s [-c] [-m] [-n] [-p <PID>|<pattern>] [-s[<node>]] [-v] [-V] [-z] [ <PID>|<pattern>... ]\n", prog_name);
fprintf(stderr, "-c to minimize column widths\n");
fprintf(stderr, "-m to show meminfo-like system-wide memory usage\n");
Expand All @@ -695,7 +695,7 @@ void display_usage_and_exit() {
exit(EXIT_FAILURE);
}

int get_screen_width() {
int get_screen_width(void) {
int width = 80;
char *p = getenv("NUMASTAT_WIDTH");
if (p != NULL) {
Expand Down Expand Up @@ -867,19 +867,19 @@ void show_info_from_system_file(char *file, meminfo_p meminfo, int meminfo_rows,
free_table(&table);
}

void show_numastat_info() {
void show_numastat_info(void) {
if (!compatibility_mode) {
printf("\nPer-node numastat info (in MBs):\n");
}
show_info_from_system_file("numastat", numastat_meminfo, NUMASTAT_MEMINFO_ROWS, 0);
}

void show_system_info() {
void show_system_info(void) {
printf("\nPer-node system memory usage (in MBs):\n");
show_info_from_system_file("meminfo", system_meminfo, SYSTEM_MEMINFO_ROWS, 2);
}

void show_process_info() {
void show_process_info(void) {
vtab_t table;
int header_rows = 2;
int header_cols = 1;
Expand Down Expand Up @@ -1138,7 +1138,7 @@ void init_node_ix_map_and_header(int compatibility_mode) {
}
}

void free_node_ix_map_and_header() {
void free_node_ix_map_and_header(void) {
if (node_ix_map != NULL) {
free(node_ix_map);
node_ix_map = NULL;
Expand All @@ -1152,7 +1152,7 @@ void free_node_ix_map_and_header() {
}
}

double get_huge_page_size_in_bytes() {
double get_huge_page_size_in_bytes(void) {
double huge_page_size = 0;;
FILE *fs = fopen("/proc/meminfo", "r");
if (!fs) {
Expand Down Expand Up @@ -1212,7 +1212,7 @@ int ascending(const void *p1, const void *p2) {
return *(int *)p1 - *(int *) p2;
}

void sort_pids_and_remove_duplicates() {
void sort_pids_and_remove_duplicates(void) {
if (num_pids > 1) {
qsort(pid_array, num_pids, sizeof(int), ascending);
int ix1 = 0;
Expand Down
6 changes: 3 additions & 3 deletions stream_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <stdlib.h>
#include "stream_lib.h"

static inline double mysecond()
static inline double mysecond(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
Expand Down Expand Up @@ -59,7 +59,7 @@ long N = 8000000;
*
*/

int checktick();
int checktick(void);

# define HLINE "-------------------------------------------------------------\n"

Expand Down Expand Up @@ -204,7 +204,7 @@ void stream_test(double *res)

# define M 20

int checktick()
int checktick(void)
{
int i, minDelta, Delta;
double t1, t2, timesfound[M];
Expand Down

0 comments on commit 25dcde0

Please sign in to comment.