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-06-11 12:45:32 +0200
commit50039ae496a57e745d61b6b0556ede1fd3bdc6a1 (patch)
tree05d37c42bd66b53e2f4540f9cca998c34cbc56ca
parentd7ec9fedb91e6c2041fb7a7b507bb4a6532e96fe (diff)
downloadhardware_replicant_libsamsung-ipc-50039ae496a57e745d61b6b0556ede1fd3bdc6a1.tar.gz
hardware_replicant_libsamsung-ipc-50039ae496a57e745d61b6b0556ede1fd3bdc6a1.tar.bz2
hardware_replicant_libsamsung-ipc-50039ae496a57e745d61b6b0556ede1fd3bdc6a1.zip
tools: nv_data-md5: 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/nv_data-md5.c115
1 files changed, 57 insertions, 58 deletions
diff --git a/tools/nv_data-md5.c b/tools/nv_data-md5.c
index efacc2d..224d657 100644
--- a/tools/nv_data-md5.c
+++ b/tools/nv_data-md5.c
@@ -26,78 +26,77 @@
void usage_print(void)
{
- printf("Usage: nv_data-md5 [nv_data.bin]\n");
+ printf("Usage: nv_data-md5 [nv_data.bin]\n");
}
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(int argc, char *argv[])
{
- struct ipc_client *client = NULL;
- char *secret = NV_DATA_SECRET;
- size_t size = NV_DATA_SIZE;
- size_t chunk_size = NV_DATA_CHUNK_SIZE;
- char *md5_string = NULL;
- char *path;
- int rc = 0;
-
- if (argc < 2) {
- usage_print();
- return 1;
- }
-
- path = argv[1];
-
- client = ipc_client_create(IPC_CLIENT_TYPE_DUMMY);
- 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;
- }
-
- md5_string = ipc_nv_data_md5_calculate(client, path, secret, size, chunk_size);
- if (md5_string == NULL) {
- fprintf(stderr, "Calculating nv_data backup md5 failed\n");
- return 1;
- }
-
- printf("%s\n", md5_string);
-
- free(md5_string);
-
- return 0;
+ struct ipc_client *client = NULL;
+ char *secret = NV_DATA_SECRET;
+ size_t size = NV_DATA_SIZE;
+ size_t chunk_size = NV_DATA_CHUNK_SIZE;
+ char *md5_string = NULL;
+ char *path;
+ int rc = 0;
+
+ if (argc < 2) {
+ usage_print();
+ return 1;
+ }
+
+ path = argv[1];
+
+ client = ipc_client_create(IPC_CLIENT_TYPE_DUMMY);
+ 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;
+ }
+
+ md5_string = ipc_nv_data_md5_calculate(client, path, secret, size,
+ chunk_size);
+ if (md5_string == NULL) {
+ fprintf(stderr, "Calculating nv_data backup md5 failed\n");
+ return 1;
+ }
+
+ printf("%s\n", md5_string);
+
+ free(md5_string);
+
+ return 0;
error:
- if (client != NULL)
- ipc_client_destroy(client);
+ if (client != NULL)
+ ipc_client_destroy(client);
}
-
-// vim:ts=4:sw=4:expandtab