Skip to content
Snippets Groups Projects
Commit 342a0704 authored by Alessandro Rubini's avatar Alessandro Rubini Committed by Adam Wujek
Browse files

userspace/snmpd: some checkpatch on my own code


Signed-off-by: default avatarAlessandro Rubini <rubini@gnudd.com>
parent 21c04d92
Branches
No related merge requests found
......@@ -37,8 +37,8 @@ void *create_map(unsigned long address, unsigned long size)
if (fd < 0)
return NULL;
offset = address & ~(ps -1);
fragment = address & (ps -1);
offset = address & ~(ps - 1);
fragment = address & (ps - 1);
len = address + size - offset;
mapaddr = mmap(0, len, PROT_READ | PROT_WRITE,
......@@ -68,7 +68,7 @@ static void wrs_d_get(void)
utcl = pps->CNTR_UTCLO;
tmp1 = pps->CNTR_UTCHI;
tmp2 = pps->CNTR_UTCLO;
} while((tmp1 != utch) || (tmp2 != utcl));
} while ((tmp1 != utch) || (tmp2 != utcl));
wrs_d_current_64 = (uint64_t)(utch) << 32 | utcl;
t = wrs_d_current_64;
......
......@@ -116,7 +116,7 @@ static void wrs_ppsi_parse_line(char *line, void *baseaddr,
addr = baseaddr + pi->offset;
/* Here I'm lazy in error checking, let's hope it's ok */
switch(pi->type) {
switch (pi->type) {
case ASN_UNSIGNED:
/*
* our unsigned is line length, definitely less than 2G,
......@@ -276,7 +276,7 @@ static int ppsi_g_group(netsnmp_mib_handler *handler,
/* For the per-port table we use an iterator like in wrsPstats.c */
static netsnmp_variable_list *
ppsi_p_next_entry( void **loop_context,
ppsi_p_next_entry(void **loop_context,
void **data_context,
netsnmp_variable_list *index,
netsnmp_iterator_info *data)
......@@ -290,7 +290,7 @@ ppsi_p_next_entry( void **loop_context,
return NULL; /* no more */
i++;
/* Create the row OID: only the counter index */
snmp_set_var_value(index, (u_char*)&i, sizeof(i));
snmp_set_var_value(index, (u_char *)&i, sizeof(i));
/* Set the data context (1..4 -> 0..3) */
*data_context = (void *)(intptr_t)(i - 1);
......@@ -306,7 +306,7 @@ ppsi_p_first_entry(void **loop_context,
netsnmp_iterator_info *data)
{
/* reset internal position, so "next" is "first" */
*loop_context = (void*)0; /* first counter */
*loop_context = (void *)0; /* first counter */
return ppsi_p_next_entry(loop_context, data_context, index, data);
}
......@@ -353,7 +353,7 @@ ppsi_p_handler(netsnmp_mib_handler *handler,
}
for (request=requests; request; request=request->next) {
for (request = requests; request; request = request->next) {
requestvb = request->requestvb;
//logmsg("%s: %i\n", __func__, __LINE__);
......@@ -424,6 +424,4 @@ init_wrsPpsi(void)
ppsi_p_load, NULL,
wrsPpsiP_oid,
OID_LENGTH(wrsPpsiP_oid)));
}
......@@ -51,7 +51,7 @@ wrsPstats_handler(netsnmp_mib_handler *handler,
logmsg("%s: %i\n", __func__, __LINE__);
switch (reqinfo->mode) {
case MODE_GET:
for (request=requests; request; request=request->next) {
for (request = requests; request; request = request->next) {
requestvb = request->requestvb;
logmsg("%s: %i\n", __func__, __LINE__);
......@@ -94,7 +94,7 @@ wrsPstats_handler(netsnmp_mib_handler *handler,
static netsnmp_variable_list *
wrsPstats_next_entry( void **loop_context,
wrsPstats_next_entry(void **loop_context,
void **data_context,
netsnmp_variable_list *index,
netsnmp_iterator_info *data)
......@@ -108,7 +108,7 @@ wrsPstats_next_entry( void **loop_context,
return NULL; /* no more */
i++;
/* Create the row OID: only the counter index */
snmp_set_var_value(index, (u_char*)&i, sizeof(i));
snmp_set_var_value(index, (u_char *)&i, sizeof(i));
/* Set the data context (1..39 -> 0..38) */
*data_context = (void *)(intptr_t)(i - 1);
......@@ -126,7 +126,7 @@ wrsPstats_first_entry(void **loop_context,
logmsg("%s: %i\n", __func__, __LINE__);
/* reset internal position, so "next" is "first" */
*loop_context = (void*)0; /* first counter */
*loop_context = (void *)0; /* first counter */
return wrsPstats_next_entry(loop_context, data_context, index, data);
}
......@@ -146,13 +146,13 @@ wrsPstats_load(netsnmp_cache *cache, void *vmagic)
/* parse new line delimited file */
p = fgets(pstats_global_data.counter_name[counter],
PSTATS_MAX_COUNTERS_NAME_LEN, f);
if(p == NULL)
if (p == NULL)
break;
/* fgets usualy returns strings with newline, return
string shall contain maximum one newline character */
p = strchr(pstats_global_data.counter_name[counter],
'\n');
if(p != NULL)
if (p != NULL)
*p = '\0';
}
......@@ -185,7 +185,6 @@ wrsPstats_load(netsnmp_cache *cache, void *vmagic)
}
fclose(f);
}
//dumpstruct(logf, "global data", &pstats_global_data, sizeof(pstats_global_data));
return 0;
}
......
......@@ -66,7 +66,7 @@ static inline int dumpstruct(FILE *dest, char *name, void *ptr, int size)
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
(type *)( (char *)__mptr - offsetof(type, member) );})
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment