[Accel-config] [PATCH v1 1/8] accel-config: Fix some indentation and coding convention errors

ramesh.thomas at intel.com
Newsgroups dev.linux.lists.accel-config
Message-ID <[email protected]>
From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Fixing checkpatch and indentation errors in these files to make review
easier

Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/config_attr.c | 27 +++++++++++++-------------
 accfg/enable.c      |  4 ++--
 accfg/list.c        | 14 +++++++-------
 util/filter.c       | 46 ++++++++++++++++++++-------------------------
 util/filter.h       |  8 ++++----
 util/json.c         | 16 +++++++++-------
 util/json.h         |  1 -
 7 files changed, 56 insertions(+), 60 deletions(-)

diff --git a/accfg/config_attr.c b/accfg/config_attr.c
index a9a405a..a893f08 100644
--- a/accfg/config_attr.c
+++ b/accfg/config_attr.c
@@ -1,5 +1,5 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright(c) 2019 Intel Corporation. All rights reserved. */
+// SPDX-License-Identifier: GPL-2.0
+// Copyright(c) 2019 Intel Corporation. All rights reserved.
 
 #include <stdio.h>
 #include <errno.h>
@@ -45,6 +45,7 @@ static int accel_config_parse_device_attribs(struct accfg_device *dev,
 		struct dev_parameters *device_param)
 {
 	int rc = 0;
+
 	rc = accfg_device_set_token_limit(dev, device_param->token_limit);
 	if (rc < 0)
 		return rc;
@@ -93,10 +94,10 @@ static int accel_config_parse_group_attribs(struct accfg_group *group,
 	}
 
 	if (group_params->use_token_limit != UINT_MAX) {
-                rc = accfg_group_set_use_token_limit(group,
+		rc = accfg_group_set_use_token_limit(group,
 			group_params->use_token_limit);
 		if (rc < 0)
-		        return rc;
+			return rc;
 	}
 
 	if (group_params->tokens_reserved != UINT_MAX) {
@@ -309,7 +310,7 @@ int cmd_config_device(int argc, const char **argv, void *ctx)
 	}
 
 	for (i = 0; i < argc; i++) {
-			if (accfg_device_type_validate(argv[i])) {
+		if (accfg_device_type_validate(argv[i])) {
 			/* walkthrough device */
 			accfg_device_foreach(ctx, device) {
 				if (!util_device_filter(device, argv[i]))
@@ -318,7 +319,7 @@ int cmd_config_device(int argc, const char **argv, void *ctx)
 						&dev_param);
 				if (rc != 0) {
 					fprintf(stderr,
-						"accel_config_parse_device_attribs failed\n");
+							"accel_config_parse_device_attribs failed\n");
 					return rc;
 				}
 			}
@@ -401,7 +402,7 @@ int cmd_config_group(int argc, const char **argv, void *ctx)
 
 			accfg_group_foreach(device, group) {
 				if (!util_group_filter(group, group_name))
-				      continue;
+					continue;
 
 				rc = accel_config_parse_group_attribs(group,
 						&group_param);
@@ -481,9 +482,9 @@ int cmd_config_wq(int argc, const char **argv, void *ctx)
 		if (!accfg_device_type_validate(dev_name))
 			return -EINVAL;
 
-                rc = sprintf(wq_name, "wq%u.%u", dev_id, wq_id);
-                if (rc < 0)
-                        return rc;
+		rc = sprintf(wq_name, "wq%u.%u", dev_id, wq_id);
+		if (rc < 0)
+			return rc;
 
 		accfg_device_foreach(ctx, device) {
 			if (!util_device_filter(device, dev_name))
@@ -553,9 +554,9 @@ int cmd_config_engine(int argc, const char **argv, void *ctx)
 		if (!accfg_device_type_validate(dev_name))
 			return -EINVAL;
 
-                rc = sprintf(engine_name, "engine%u.%u", dev_id, engine_id);
-                if (rc < 0)
-                        return rc;
+		rc = sprintf(engine_name, "engine%u.%u", dev_id, engine_id);
+		if (rc < 0)
+			return rc;
 
 		accfg_device_foreach(ctx, device) {
 			if (!util_device_filter(device, dev_name))
diff --git a/accfg/enable.c b/accfg/enable.c
index 6954214..f65f8e2 100644
--- a/accfg/enable.c
+++ b/accfg/enable.c
@@ -1,5 +1,5 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright(c) 2019 Intel Corporation. All rights reserved. */
+// SPDX-License-Identifier: GPL-2.0
+// Copyright(c) 2019 Intel Corporation. All rights reserved.
 
 #include <stdio.h>
 #include <errno.h>
diff --git a/accfg/list.c b/accfg/list.c
index 998ebdd..a252585 100644
--- a/accfg/list.c
+++ b/accfg/list.c
@@ -1,5 +1,5 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright(c) 2019 Intel Corporation. All rights reserved. */
+// SPDX-License-Identifier: GPL-2.0
+// Copyright(c) 2019 Intel Corporation. All rights reserved.
 
 #include <stdio.h>
 #include <errno.h>
@@ -128,7 +128,7 @@ static bool filter_wq(struct accfg_wq *wq, struct util_filter_ctx *ctx)
 	if (!jwq)
 		return false;
 
-	for (i = 0; i < max_groups; i ++) {
+	for (i = 0; i < max_groups; i++) {
 		/*
 		 * Group array will be created only if group contains
 		 * the wq.
@@ -308,9 +308,9 @@ static bool filter_device(struct accfg_device *device,
 	if (!jc)
 		return false;
 
-       jc->jgroup_assigned = calloc(max_groups, sizeof(struct json_object *));
-       if (!jc->jgroup_assigned)
-               goto err_jc;
+	jc->jgroup_assigned = calloc(max_groups, sizeof(struct json_object *));
+	if (!jc->jgroup_assigned)
+		goto err_jc;
 
 	jc->jwq_group = calloc(max_groups, sizeof(struct json_object *));
 	if (!jc->jwq_group)
@@ -361,7 +361,7 @@ static void free_containers(struct list_filter_arg *lfa)
 	}
 }
 
-static int save_config(struct list_filter_arg *lfa, const char* saved_file)
+static int save_config(struct list_filter_arg *lfa, const char *saved_file)
 {
 	struct json_object *jdevices = lfa->jdevices;
 	FILE *fd = fopen(saved_file, "w");
diff --git a/util/filter.c b/util/filter.c
index d761e29..5e5840d 100644
--- a/util/filter.c
+++ b/util/filter.c
@@ -1,5 +1,5 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright(c) 2015-2019 Intel Corporation. All rights reserved. */
+// SPDX-License-Identifier: GPL-2.0
+// Copyright(c) 2015-2019 Intel Corporation. All rights reserved.
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -47,9 +47,8 @@ struct accfg_device *util_device_filter(struct accfg_device *device,
 	}
 	free(ident);
 
-	if (name) {
+	if (name)
 		return device;
-	}
 
 	return NULL;
 }
@@ -61,9 +60,8 @@ struct accfg_group *util_group_filter(struct accfg_group *group,
 	const char *name;
 	int device_id, group_id;
 
-	if (!__ident) {
+	if (!__ident)
 		return group;
-	}
 
 	ident = strdup(__ident);
 	if (!ident)
@@ -74,9 +72,8 @@ struct accfg_group *util_group_filter(struct accfg_group *group,
 		if (strcmp(name, "all") == 0)
 			break;
 
-		if (strcmp(name, accfg_group_get_devname(group)) == 0) {
+		if (strcmp(name, accfg_group_get_devname(group)) == 0)
 			break;
-		}
 
 		if (sscanf(name, "%d.%d", &device_id, &group_id) == 2
 		    && accfg_group_get_id(group) == group_id
@@ -85,9 +82,9 @@ struct accfg_group *util_group_filter(struct accfg_group *group,
 		}
 	}
 	free(ident);
-	if (name) {
+	if (name)
 		return group;
-	}
+
 	return NULL;
 }
 
@@ -159,14 +156,12 @@ struct accfg_device *util_device_filter_by_group(struct accfg_device *device,
 {
 	struct accfg_group *group;
 
-	if (!ident || strcmp(ident, "all") == 0) {
+	if (!ident || strcmp(ident, "all") == 0)
 		return device;
-	}
 
 	accfg_group_foreach(device, group) {
-		if (util_group_filter(group, ident)) {
+		if (util_group_filter(group, ident))
 			return device;
-		}
 	}
 	return NULL;
 }
@@ -181,9 +176,9 @@ struct accfg_device *util_device_filter_by_wq(struct accfg_device *device,
 		return device;
 
 	accfg_group_foreach(device, group)
-	    accfg_wq_foreach(device, wq)
-	    if (util_wq_filter(wq, ident))
-		return device;
+		accfg_wq_foreach(device, wq)
+			if (util_wq_filter(wq, ident))
+				return device;
 	return NULL;
 }
 
@@ -197,9 +192,9 @@ struct accfg_device *util_device_filter_by_engine(struct accfg_device *device,
 		return device;
 
 	accfg_group_foreach(device, group)
-	    accfg_engine_foreach(device, engine)
-	    if (util_engine_filter(engine, ident))
-		return device;
+		accfg_engine_foreach(device, engine)
+			if (util_engine_filter(engine, ident))
+				return device;
 	return NULL;
 }
 
@@ -213,8 +208,8 @@ struct accfg_group *util_group_filter_by_wq(struct accfg_group *group,
 		return group;
 
 	accfg_wq_foreach(device, wq)
-	    if (util_wq_filter(wq, ident))
-		return group;
+		if (util_wq_filter(wq, ident))
+			return group;
 	return NULL;
 }
 
@@ -228,8 +223,8 @@ struct accfg_group *util_group_filter_by_engine(struct accfg_group *group,
 		return group;
 
 	accfg_engine_foreach(device, engine)
-	    if (util_engine_filter(engine, ident))
-		return group;
+		if (util_engine_filter(engine, ident))
+			return group;
 	return NULL;
 }
 
@@ -268,9 +263,8 @@ int util_filter_walk(struct accfg_ctx *ctx, struct util_filter_ctx *fctx,
 		}
 
 		accfg_wq_foreach(device, wq) {
-			if (!fctx->filter_wq) {
+			if (!fctx->filter_wq)
 				break;
-			}
 
 			if (!util_wq_filter(wq, param->wq))
 				continue;
diff --git a/util/filter.h b/util/filter.h
index 4ba0837..aa13efe 100644
--- a/util/filter.h
+++ b/util/filter.h
@@ -14,7 +14,7 @@ struct accfg_wq *util_wq_filter(struct accfg_wq *wq,
 struct accfg_engine *util_engine_filter(struct accfg_engine *engine, const char *ident);
 
 struct accfg_device *util_device_filter_by_group(struct accfg_device *device,
-                const char *ident);
+		const char *ident);
 struct accfg_group *util_group_filter_by_wq(struct accfg_group *group,
 		const char *ident);
 struct accfg_group *util_group_filter_by_engine(struct accfg_group *group,
@@ -40,7 +40,7 @@ struct accfg_json_container {
 	/* array for assigned engines in group */
 	struct json_object **jengine_group;
 	/* array for unassigned engines in group */
-        struct json_object *jengine_ungroup;
+	struct json_object *jengine_ungroup;
 	/* store group_id when a jgroup is created */
 	int *jgroup_id;
 	/* device_id bonded with this container */
@@ -54,9 +54,9 @@ struct accfg_json_container {
 /* json object device for the util_filter_walk() by cmd_list() and cmd_config() */
 struct list_filter_arg {
 	/* json object for device array */
-        struct json_object *jdevices;
+	struct json_object *jdevices;
 	/* json object for each device */
-        struct json_object *jdevice;
+	struct json_object *jdevice;
 	/* linked list to add accfg_json_container for each device */
 	struct list_head jdev_list;
 	/* linked list node for each list_filter_arg */
diff --git a/util/json.c b/util/json.c
index f2bb990..b02e336 100644
--- a/util/json.c
+++ b/util/json.c
@@ -1,5 +1,5 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/* Copyright(c) 2015-2019 Intel Corporation. All rights reserved. */
+// SPDX-License-Identifier: GPL-2.0
+// Copyright(c) 2015-2019 Intel Corporation. All rights reserved.
 #include <limits.h>
 #include <string.h>
 #include <util/json.h>
@@ -17,7 +17,7 @@
 #include <dirent.h>
 #include "sysfs.h"
 
-static const char *wq_type_str[] = {
+static const char * const wq_type_str[] = {
 	"none",
 	"kernel",
 	"user",
@@ -81,6 +81,7 @@ static int display_hex(struct json_object *jobj, struct printbuf *pbuf,
 {
 	uint64_t val = json_object_get_int64(jobj);
 	static char buf[32];
+
 	snprintf(buf, sizeof(buf), "\"%#" PRIx64 "\"", val);
 	return printbuf_memappend(pbuf, buf, strlen(buf));
 }
@@ -106,7 +107,7 @@ struct json_object *util_json_object_hex(uint64_t val,
 }
 
 /* API used to output json object display to console */
-void util_display_json_array(FILE * f_out, struct json_object *jarray,
+void util_display_json_array(FILE *f_out, struct json_object *jarray,
 			     uint64_t flags)
 {
 	int len = json_object_array_length(jarray);
@@ -117,6 +118,7 @@ void util_display_json_array(FILE * f_out, struct json_object *jarray,
 			json_object_to_json_string_ext(jarray, jflag));
 	else if (len) {
 		struct json_object *jobj;
+
 		jobj = json_object_array_get_idx(jarray, 0);
 		fprintf(f_out, "%s\n",
 			json_object_to_json_string_ext(jobj, jflag));
@@ -125,7 +127,7 @@ void util_display_json_array(FILE * f_out, struct json_object *jarray,
 }
 
 /* API used to output json object display to specified file */
-void __util_display_json_array(FILE * fd, struct json_object *jarray,
+void __util_display_json_array(FILE *fd, struct json_object *jarray,
 			     uint64_t flags)
 {
 	int len = json_object_array_length(jarray);
@@ -136,6 +138,7 @@ void __util_display_json_array(FILE * fd, struct json_object *jarray,
 			json_object_to_json_string_ext(jarray, jflag));
 	else if (len) {
 		struct json_object *jobj;
+
 		jobj = json_object_array_get_idx(jarray, 0);
 		fprintf(fd, "%s\n",
 			json_object_to_json_string_ext(jobj, jflag));
@@ -507,9 +510,8 @@ struct json_object *util_engine_to_json(struct accfg_engine *engine,
 	struct json_object *jaccfg = json_object_new_object();
 	struct json_object *jobj = NULL;
 
-	if (!jaccfg) {
+	if (!jaccfg)
 		return NULL;
-	}
 	jobj = json_object_new_string(accfg_engine_get_devname(engine));
 	if (!jobj)
 		goto err;
diff --git a/util/json.h b/util/json.h
index c185f80..79aad84 100644
--- a/util/json.h
+++ b/util/json.h
@@ -1,4 +1,3 @@
-
 /* SPDX-License-Identifier: GPL-2.0 */
 /* Copyright(c) 2015-2019 Intel Corporation. All rights reserved. */
 #ifndef __ACCFG_JSON_H__
-- 
2.26.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.