aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2020-04-04 19:11:17 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2020-04-05 10:51:27 +0200
commitda47544ef1a59a576afaaa64127da4a1e25fdbdc (patch)
tree98f60dbf69325d971f3126dff7fba3d1614d8aca
parent0f352d332171f7e777bd4cf382eba6ce41ac62ca (diff)
downloadhardware_replicant_libsamsung-ipc-da47544ef1a59a576afaaa64127da4a1e25fdbdc.tar.gz
hardware_replicant_libsamsung-ipc-da47544ef1a59a576afaaa64127da4a1e25fdbdc.tar.bz2
hardware_replicant_libsamsung-ipc-da47544ef1a59a576afaaa64127da4a1e25fdbdc.zip
tools: ipc-test: switch to Linux code style
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@cyberdimension.org>
-rw-r--r--tools/ipc-test.c188
1 files 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