From 342a070444127de4639b48defe0cda84c7dc9712 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Mon, 1 Dec 2014 22:46:14 +0100
Subject: [PATCH] userspace/snmpd: some checkpatch on my own code

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
---
 userspace/snmpd/wrsDate.c   |  6 +++---
 userspace/snmpd/wrsPpsi.c   | 12 +++++-------
 userspace/snmpd/wrsPstats.c | 13 ++++++-------
 userspace/snmpd/wrsSnmp.h   |  2 +-
 4 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/userspace/snmpd/wrsDate.c b/userspace/snmpd/wrsDate.c
index a2be3c95b..a839b6563 100644
--- a/userspace/snmpd/wrsDate.c
+++ b/userspace/snmpd/wrsDate.c
@@ -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;
diff --git a/userspace/snmpd/wrsPpsi.c b/userspace/snmpd/wrsPpsi.c
index f8f9c5246..7e8248565 100644
--- a/userspace/snmpd/wrsPpsi.c
+++ b/userspace/snmpd/wrsPpsi.c
@@ -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)));
-	
-
 }
diff --git a/userspace/snmpd/wrsPstats.c b/userspace/snmpd/wrsPstats.c
index 027b7152d..ae39335d0 100644
--- a/userspace/snmpd/wrsPstats.c
+++ b/userspace/snmpd/wrsPstats.c
@@ -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;
 }
 
diff --git a/userspace/snmpd/wrsSnmp.h b/userspace/snmpd/wrsSnmp.h
index ba163b32c..ec8227975 100644
--- a/userspace/snmpd/wrsSnmp.h
+++ b/userspace/snmpd/wrsSnmp.h
@@ -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]))
-- 
GitLab