[Replicant] [libsamsung-ipc][PATCH 02/48] tools: ipc-test: switch to Linux code style

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Sun Apr 5 18:20:36 UTC 2020


This contains no functional changes.

The commented out code if any has also been preserved as it
could be relevant to the understanding of the code.

It will be kept until we understand why the code has been
commented. In that case we either need to remove it completely
or to replace it by a comment explaining why not having that
code was necessary.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 tools/ipc-test.c | 188 +++++++++++++++++++++++------------------------
 1 file changed, 93 insertions(+), 95 deletions(-)

diff --git a/tools/ipc-test.c b/tools/ipc-test.c
index 59f9074..17e8f9b 100644
--- a/tools/ipc-test.c
+++ b/tools/ipc-test.c
@@ -26,114 +26,112 @@
 void log_callback(__attribute__((unused)) void *data,
 		  const char *message)
 {
-    char *buffer;
-    size_t length;
-    int i;
+	char *buffer;
+	size_t length;
+	int i;
 
-    if (message == NULL)
-        return;
+	if (message == NULL)
+		return;
 
-    buffer = strdup(message);
-    length = strlen(message);
+	buffer = strdup(message);
+	length = strlen(message);
 
-    for (i = length; i > 0; i--) {
-        if (buffer[i] == '\n')
-            buffer[i] = '\0';
-        else if (buffer[i] != '\0')
-            break;
-    }
+	for (i = length; i > 0; i--) {
+		if (buffer[i] == '\n')
+			buffer[i] = '\0';
+		else if (buffer[i] != '\0')
+			break;
+	}
 
-    printf("[ipc] %s\n", buffer);
+	printf("[ipc] %s\n", buffer);
 
-    free(buffer);
+	free(buffer);
 }
 
 int main(__attribute__((unused)) int args,
 	 __attribute__((unused)) char *argv[])
 {
-    struct ipc_client *client = NULL;
-    struct ipc_message message;
-    int rc;
-    int i;
-
-    client = ipc_client_create(IPC_CLIENT_TYPE_FMT);
-    if (client == NULL) {
-        printf("Creating client failed\n");
-        goto error;
-    }
-
-    rc = ipc_client_log_callback_register(client, log_callback, NULL);
-    if (rc < 0) {
-        printf("Registering log callback failed: error %d\n", rc);
-        goto error;
-    }
-
-    rc = ipc_client_data_create(client);
-    if (rc < 0) {
-        printf("Creating data failed: error %d\n", rc);
-        goto error;
-    }
-
-    rc = ipc_client_boot(client);
-    if (rc < 0) {
-        printf("Booting failed: error %d\n", rc);
-        goto error;
-    }
-
-    rc = ipc_client_power_on(client);
-    if (rc < 0) {
-        printf("Powering on failed: error %d\n", rc);
-        goto error;
-    }
-
-    rc = ipc_client_open(client);
-    if (rc < 0) {
-        printf("ipc_client_open failed: error %d\n", rc);
-        goto error;
-    }
-
-    for (i = 0; i < 5; i++) {
-        rc = ipc_client_poll(client, NULL, NULL);
-        if (rc < 0) {
-            printf("Polling failed: error %d\n", rc);
-            break;
-        }
-
-        rc = ipc_client_recv(client, &message);
-        if (rc < 0) {
-            printf("Receiving failed: error %d\n", rc);
-            break;
-        }
-
-        if (message.data != NULL && message.size > 0) {
-            free(message.data);
-            message.data = NULL;
-        }
-    }
-
-    rc = ipc_client_close(client);
-    if (rc < 0) {
-        printf("Closing failed: error %d\n", rc);
-        goto error;
-    }
-
-    rc = ipc_client_power_off(client);
-    if (rc < 0) {
-        printf("Powering on failed: error %d\n", rc);
-        goto error;
-    }
-
-    rc = 0;
-    goto complete;
+	struct ipc_client *client = NULL;
+	struct ipc_message message;
+	int rc;
+	int i;
+
+	client = ipc_client_create(IPC_CLIENT_TYPE_FMT);
+	if (client == NULL) {
+		printf("Creating client failed\n");
+		goto error;
+	}
+
+	rc = ipc_client_log_callback_register(client, log_callback, NULL);
+	if (rc < 0) {
+		printf("Registering log callback failed: error %d\n", rc);
+		goto error;
+	}
+
+	rc = ipc_client_data_create(client);
+	if (rc < 0) {
+		printf("Creating data failed: error %d\n", rc);
+		goto error;
+	}
+
+	rc = ipc_client_boot(client);
+	if (rc < 0) {
+		printf("Booting failed: error %d\n", rc);
+		goto error;
+	}
+
+	rc = ipc_client_power_on(client);
+	if (rc < 0) {
+		printf("Powering on failed: error %d\n", rc);
+		goto error;
+	}
+
+	rc = ipc_client_open(client);
+	if (rc < 0) {
+		printf("ipc_client_open failed: error %d\n", rc);
+		goto error;
+	}
+
+	for (i = 0; i < 5; i++) {
+		rc = ipc_client_poll(client, NULL, NULL);
+		if (rc < 0) {
+			printf("Polling failed: error %d\n", rc);
+			break;
+		}
+
+		rc = ipc_client_recv(client, &message);
+		if (rc < 0) {
+			printf("Receiving failed: error %d\n", rc);
+			break;
+		}
+
+		if (message.data != NULL && message.size > 0) {
+			free(message.data);
+			message.data = NULL;
+		}
+	}
+
+	rc = ipc_client_close(client);
+	if (rc < 0) {
+		printf("Closing failed: error %d\n", rc);
+		goto error;
+	}
+
+	rc = ipc_client_power_off(client);
+	if (rc < 0) {
+		printf("Powering on failed: error %d\n", rc);
+		goto error;
+	}
+
+	rc = 0;
+	goto complete;
 
 error:
-    rc = 1;
+	rc = 1;
 
 complete:
-    if (client != NULL)
-        ipc_client_destroy(client);
+	if (client != NULL)
+		ipc_client_destroy(client);
 
-    return rc;
+	return rc;
 }
-
-// vim:ts=4:sw=4:expandtab
-- 
2.26.0



More information about the Replicant mailing list