Skip to content

Commit

Permalink
Merge pull request #309 from neheb/f
Browse files Browse the repository at this point in the history
ui: change void to char
  • Loading branch information
nhorman authored Apr 1, 2024
2 parents 1686a95 + e78ea26 commit 35ede08
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 64 deletions.
15 changes: 5 additions & 10 deletions bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,42 +282,37 @@ static inline int bitmap_equal(const unsigned long *src1,
{
if (nbits <= BITS_PER_LONG)
return ! ((*src1 ^ *src2) & BITMAP_LAST_WORD_MASK(nbits));
else
return __bitmap_equal(src1, src2, nbits);
return __bitmap_equal(src1, src2, nbits);
}

static inline int bitmap_intersects(const unsigned long *src1,
const unsigned long *src2, int nbits)
{
if (nbits <= BITS_PER_LONG)
return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0;
else
return __bitmap_intersects(src1, src2, nbits);
return __bitmap_intersects(src1, src2, nbits);
}

static inline int bitmap_subset(const unsigned long *src1,
const unsigned long *src2, int nbits)
{
if (nbits <= BITS_PER_LONG)
return ! ((*src1 & ~(*src2)) & BITMAP_LAST_WORD_MASK(nbits));
else
return __bitmap_subset(src1, src2, nbits);
return __bitmap_subset(src1, src2, nbits);
}

static inline int bitmap_empty(const unsigned long *src, int nbits)
{
if (nbits <= BITS_PER_LONG)
return ! (*src & BITMAP_LAST_WORD_MASK(nbits));
else
return __bitmap_empty(src, nbits);
return __bitmap_empty(src, nbits);
}

static inline int bitmap_full(const unsigned long *src, int nbits)
{
if (nbits <= BITS_PER_LONG)
return ! (~(*src) & BITMAP_LAST_WORD_MASK(nbits));
else
return __bitmap_full(src, nbits);
return __bitmap_full(src, nbits);
}

static inline int bitmap_weight(const unsigned long *src, int nbits)
Expand Down
26 changes: 13 additions & 13 deletions classify.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ static void apply_pci_quirks(const struct pci_info *pci, int *irq_class)
break;
}
}

return;
}

/* Determin IRQ class based on PCI class code */
Expand Down Expand Up @@ -200,25 +198,30 @@ static unsigned int read_pci_data(const char *devpath, const char* file)
/* Get pci information for IRQ classification */
static int get_pci_info(const char *devpath, struct pci_info *pci)
{
unsigned int data = PCI_INVAL_DATA;
unsigned int data;

if ((data = read_pci_data(devpath, "vendor")) == PCI_INVAL_DATA)
data = read_pci_data(devpath, "vendor");
if (data == PCI_INVAL_DATA)
return -ENODEV;
pci->vendor = (unsigned short)data;

if ((data = read_pci_data(devpath, "device")) == PCI_INVAL_DATA)
data = read_pci_data(devpath, "device");
if (data == PCI_INVAL_DATA)
return -ENODEV;
pci->device = (unsigned short)data;

if ((data = read_pci_data(devpath, "subsystem_vendor")) == PCI_INVAL_DATA)
data = read_pci_data(devpath, "subsystem_vendor");
if (data == PCI_INVAL_DATA)
return -ENODEV;
pci->sub_vendor = (unsigned short)data;

if ((data = read_pci_data(devpath, "subsystem_device")) == PCI_INVAL_DATA)
data = read_pci_data(devpath, "subsystem_device");
if (data == PCI_INVAL_DATA)
return -ENODEV;
pci->sub_device = (unsigned short)data;

if ((data = read_pci_data(devpath, "class")) == PCI_INVAL_DATA)
data = read_pci_data(devpath, "class");
if (data == PCI_INVAL_DATA)
return -ENODEV;
pci->class = data;

Expand Down Expand Up @@ -278,7 +281,6 @@ static void add_banned_irq(int irq, GList **list)

*list = g_list_append(*list, new);
log(TO_CONSOLE, LOG_INFO, "IRQ %d was BANNED.\n", irq);
return;
}

void add_cl_banned_irq(int irq)
Expand All @@ -290,8 +292,7 @@ gint substr_find(gconstpointer a, gconstpointer b)
{
if (strstr(b, a))
return 0;
else
return 1;
return 1;
}

static void add_banned_module(char *modname, GList **modlist)
Expand Down Expand Up @@ -553,8 +554,7 @@ static int check_for_module_ban(char *name)

if (entry)
return 1;
else
return 0;
return 0;
}

static int check_for_irq_ban(struct irq_info *irq, char *mod)
Expand Down
10 changes: 5 additions & 5 deletions irqbalance.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <malloc.h>
#include <sys/time.h>
#include <syslog.h>
#include <unistd.h>
#include <signal.h>
#include <time.h>
#include <sys/types.h>
Expand Down Expand Up @@ -330,10 +329,10 @@ gboolean scan(gpointer data __attribute__((unused)))

if (keep_going) {
return TRUE;
} else {
g_main_loop_quit(main_loop);
return FALSE;
}

g_main_loop_quit(main_loop);
return FALSE;
}

void get_irq_data(struct irq_info *irq, void *data)
Expand Down Expand Up @@ -422,7 +421,8 @@ gboolean sock_handle(gint fd, GIOCondition condition, gpointer user_data __attri
log(TO_ALL, LOG_WARNING, "Connection couldn't be accepted.\n");
goto out;
}
if ((recv_size = recvmsg(sock, &msg, 0)) < 0) {
recv_size = recvmsg(sock, &msg, 0);
if (recv_size < 0) {
log(TO_ALL, LOG_WARNING, "Error while receiving data.\n");
goto out_close;
}
Expand Down
2 changes: 1 addition & 1 deletion numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void connect_cpu_mem_topo(struct topo_obj *p, void *data __attribute__((unused))

if (len == 0) {
return;
} else if (len > 1) {
} if (len > 1) {
for_each_object(p->children, connect_cpu_mem_topo, NULL);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion ui/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void for_each_cpu(GList *list, void (*fp)(cpu_ban_t *cpu, void *data), void *dat
}
}

void for_each_int(GList *list, void (*fp)(int *number, void *data), void *data)
void for_each_int(GList *list, void (*fp)(int *number, char *data), void *data)
{
GList *entry;
entry = g_list_first(list);
Expand Down
2 changes: 1 addition & 1 deletion ui/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ char * hex_to_bitmap(char hex_digit);
gpointer copy_cpu_ban(gconstpointer src, gpointer data);
gpointer copy_irq(gconstpointer src, gpointer data);
void for_each_cpu(GList *list, void (*fp)(cpu_ban_t *cpu, void *data), void *data);
void for_each_int(GList *list, void (*fp)(int *number, void *data), void *data);
void for_each_int(GList *list, void (*fp)(int *number, char *data), void *data);
void for_each_irq(GList *list, void (*fp)(irq_t *irq, void *data), void *data);
void for_each_node(GList *list, void (*fp)(cpu_node_t *node, void *data), void *data);

Expand Down
32 changes: 14 additions & 18 deletions ui/irqbalance-ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,21 @@ void parse_setup(char *setup_data)
setup.banned_irqs = NULL;
setup.banned_cpus = NULL;
token = strtok_r(copy, " ", &ptr);
if(strncmp(token, "SLEEP", strlen("SLEEP"))) goto out;
if(strncmp(token, "SLEEP", strlen("SLEEP")) != 0) goto out;
setup.sleep = strtol(strtok_r(NULL, " ", &ptr), NULL, 10);
token = strtok_r(NULL, " ", &ptr);
/* Parse banned IRQ data */
while(!strncmp(token, "IRQ", strlen("IRQ"))) {
new_irq = malloc(sizeof(irq_t));
new_irq->vector = strtol(strtok_r(NULL, " ", &ptr), NULL, 10);
token = strtok_r(NULL, " ", &ptr);
if(strncmp(token, "LOAD", strlen("LOAD"))) goto out;
if(strncmp(token, "LOAD", strlen("LOAD")) != 0) goto out;
new_irq->load = strtol(strtok_r(NULL, " ", &ptr), NULL, 10);
token = strtok_r(NULL, " ", &ptr);
if(strncmp(token, "DIFF", strlen("DIFF"))) goto out;
if(strncmp(token, "DIFF", strlen("DIFF")) != 0) goto out;
new_irq->diff = strtol(strtok_r(NULL, " ", &ptr), NULL, 10);
token = strtok_r(ptr, " ", &ptr);
if(strncmp(token, "CLASS", strlen("CLASS"))) goto out;
if(strncmp(token, "CLASS", strlen("CLASS")) != 0) goto out;
new_irq->class = strtol(strtok_r(NULL, " ", &ptr), NULL, 10);
new_irq->is_banned = 1;
new_irq->assigned_to = NULL;
Expand All @@ -180,7 +180,7 @@ void parse_setup(char *setup_data)
new_irq = NULL;
}

if(strncmp(token, "BANNED", strlen("BANNED"))) goto out;
if(strncmp(token, "BANNED", strlen("BANNED")) != 0) goto out;
token = strtok_r(NULL, " ", &ptr);
for(i = strlen(token) - 1; i >= 0; i--) {
if (token[i] == ',')
Expand Down Expand Up @@ -287,29 +287,25 @@ void parse_into_tree(char *data)
token = strtok_r(copy, " ", &ptr);
while(token != NULL) {
/* Parse node data */
if(strncmp(token, "TYPE", strlen("TYPE"))) {
if(strncmp(token, "TYPE", strlen("TYPE")) != 0) {
free(copy);
goto out;
}
new = malloc(sizeof(cpu_node_t));
new->irqs = NULL;
new->children = NULL;
new->cpu_list = NULL;
new->cpu_mask = NULL;
new = g_malloc0(sizeof(cpu_node_t));
new->type = strtol(strtok_r(NULL, " ", &ptr), NULL, 10);
if(new->type == OBJ_TYPE_NODE) {
parent = NULL;
} else if(new->type >= parent->type) {
parent = parent->parent;
}
token = strtok_r(NULL, " ", &ptr);
if(strncmp(token, "NUMBER", strlen("NUMBER"))) goto out;
if(strncmp(token, "NUMBER", strlen("NUMBER")) != 0) goto out;
new->number = strtol(strtok_r(NULL, " ", &ptr), NULL, 10);
token = strtok_r(NULL, " ", &ptr);
if(strncmp(token, "LOAD", strlen("LOAD"))) goto out;
if(strncmp(token, "LOAD", strlen("LOAD")) != 0) goto out;
new->load = strtol(strtok_r(NULL, " ", &ptr), NULL, 10);
token = strtok_r(NULL, " ", &ptr);
if(strncmp(token, "SAVE_MODE", strlen("SAVE_MODE"))) goto out;
if(strncmp(token, "SAVE_MODE", strlen("SAVE_MODE")) != 0) goto out;
new->is_powersave = strtol(strtok_r(NULL, " ", &ptr), NULL, 10);
token = strtok_r(NULL, " ", &ptr);

Expand All @@ -318,21 +314,21 @@ void parse_into_tree(char *data)
new_irq = malloc(sizeof(irq_t));
new_irq->vector = strtol(strtok_r(NULL, " ", &ptr), NULL, 10);
token = strtok_r(NULL, " ", &ptr);
if(strncmp(token, "LOAD", strlen("LOAD"))) goto out;
if(strncmp(token, "LOAD", strlen("LOAD")) != 0) goto out;
new_irq->load = strtol(strtok_r(NULL, " ", &ptr), NULL, 10);
token = strtok_r(NULL, " ", &ptr);
if(strncmp(token, "DIFF", strlen("DIFF"))) goto out;
if(strncmp(token, "DIFF", strlen("DIFF")) != 0) goto out;
new_irq->diff = strtol(strtok_r(NULL, " ", &ptr), NULL, 10);
token = strtok_r(NULL, " ", &ptr);
if(strncmp(token, "CLASS", strlen("CLASS"))) goto out;
if(strncmp(token, "CLASS", strlen("CLASS")) != 0) goto out;
new_irq->class = strtol(strtok_r(NULL, " ", &ptr), NULL, 10);
new_irq->is_banned = 0;
new->irqs = g_list_append(new->irqs, new_irq);
token = strtok_r(NULL, " ", &ptr);
new_irq = NULL;
}

if((token == NULL) || (strncmp(token, "IRQ", strlen("IRQ")))) {
if((token == NULL) || (strncmp(token, "IRQ", strlen("IRQ")) != 0)) {
new->parent = parent;
if(parent == NULL) {
tree = g_list_append(tree, new);
Expand Down
21 changes: 10 additions & 11 deletions ui/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,13 @@ int get_valid_sleep_input(int column_offest)
new_sleep = strtol(input, &error, 10);
if((*error == '\0') && (new_sleep >= 1)) {
break;
} else {
new_sleep = setup.sleep;
attrset(COLOR_PAIR(4) | A_BOLD);
mvprintw(LINES - 2, 1,
"Invalid input: %s ",
input);
refresh();
}
new_sleep = setup.sleep;
attrset(COLOR_PAIR(4) | A_BOLD);
mvprintw(LINES - 2, 1,
"Invalid input: %s ",
input);
refresh();
free(input);
}

Expand All @@ -130,7 +129,7 @@ int get_valid_sleep_input(int column_offest)
return new_sleep;
}

void get_banned_cpu(int *cpu, void *data __attribute__((unused)))
void get_banned_cpu(int *cpu, char *data __attribute__((unused)))
{
cpu_ban_t *new = malloc(sizeof(cpu_ban_t));
new->number = *cpu;
Expand Down Expand Up @@ -188,9 +187,9 @@ void print_all_cpus(void)
max_offset = 0;
}

void add_banned_cpu(int *banned_cpu, void *data)
void add_banned_cpu(int *banned_cpu, char *data)
{
snprintf((char *)data + strlen(data), 1024 - strlen(data), "%d, ", *banned_cpu);
snprintf(data + strlen(data), 1024 - strlen(data), "%d, ", *banned_cpu);
}

void display_banned_cpus(void)
Expand Down Expand Up @@ -369,7 +368,7 @@ static inline void bsnl_emit(char *buf, int buflen)
snprintf(buf + len, buflen - len, "%d-%d", rbot, rtop);
}

void copy_assigned_obj(int *number, void *data)
void copy_assigned_obj(int *number, char *data)
{
if (rtop == -1) {
rbot = rtop = *number;
Expand Down
7 changes: 3 additions & 4 deletions ui/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "irqbalance-ui.h"
#include "helpers.h"

extern GList *tree;
extern setup_t setup;

extern int offset;
Expand All @@ -23,18 +22,18 @@ void show_footer(void);
char * check_control_in_sleep_input(int max_len, int column_offest, int line_offset);
int get_valid_sleep_input(int column_offest);

void get_banned_cpu(int *cpu, void *data);
void get_banned_cpu(int *cpu, char *data);
void print_cpu_line(cpu_ban_t *cpu, void *data);
void print_all_cpus(void);
void add_banned_cpu(int *banned_cpu, void *data);
void add_banned_cpu(int *banned_cpu, char *data);
void display_banned_cpus(void);
int toggle_cpu(GList *cpu_list, int cpu_number);
void get_new_cpu_ban_values(cpu_ban_t *cpu, void *data);
void get_cpu(cpu_node_t *node, void *data);
void handle_sleep_setting(void);
void handle_cpu_banning(void);

void copy_assigned_obj(int *number, void *data);
void copy_assigned_obj(int *number, char *data);
void print_assigned_objects_string(irq_t *irq, int *line_offset);
void print_irq_line(irq_t *irq, void *data);
void print_all_irqs(void);
Expand Down

0 comments on commit 35ede08

Please sign in to comment.