From 5028ba30a21072974a06cc51c90c3f071eb8ba1e Mon Sep 17 00:00:00 2001
From: Maarten de Waard <maarten@greenhost.nl>
Date: Wed, 19 Jul 2017 11:15:46 +0200
Subject: [PATCH] if ( and while ( instead of if( and while(

---
 src/api/ssh_keys_delete.c |  6 +++---
 src/api/ssh_keys_get.c    |  2 +-
 src/api/ssh_keys_put.c    |  6 +++---
 src/auxiliary.c           | 10 +++++-----
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/api/ssh_keys_delete.c b/src/api/ssh_keys_delete.c
index 27874e7..8cb97db 100644
--- a/src/api/ssh_keys_delete.c
+++ b/src/api/ssh_keys_delete.c
@@ -39,12 +39,12 @@ int callback_ssh_keys_delete(const struct _u_request * request,
 
     // Replace the key at ID with ""
     r = replace_ssh_key(id, "");
-    if(r < 0)
+    if (r < 0)
     {
-        if(r == -1)
+        if (r == -1)
             return send_simple_response(response, 500, "error",
                 "error opening authorized_keys");
-        if(r == -2)
+        if (r == -2)
             return send_simple_response(response, 500, "error",
                 "error opening authorized_keys tmp file");
         return send_simple_response(response, 500, "error",
diff --git a/src/api/ssh_keys_get.c b/src/api/ssh_keys_get.c
index 1bd5958..3818706 100644
--- a/src/api/ssh_keys_get.c
+++ b/src/api/ssh_keys_get.c
@@ -24,7 +24,7 @@ json_t * readAuthorizedKeysToJson()
     while ((read = getline(&line, &line_length, authorized_keys)) != -1)
     {
         // Ignore empty lines, they do have IDs though.
-        if(strlen(line) > 1)
+        if (strlen(line) > 1)
         {
             asprintf(&field, "%d", index);
             // Remove trailing newline.
diff --git a/src/api/ssh_keys_put.c b/src/api/ssh_keys_put.c
index 4503e5d..0af4782 100644
--- a/src/api/ssh_keys_put.c
+++ b/src/api/ssh_keys_put.c
@@ -51,12 +51,12 @@ int callback_ssh_keys_put(const struct _u_request * request,
     }
 
     r = replace_ssh_key(id, ssh_key);
-    if(r < 0)
+    if (r < 0)
     {
-        if(r == -1)
+        if (r == -1)
             return send_simple_response(response, 500, "error",
                 "error opening authorized_keys");
-        if(r == -2)
+        if (r == -2)
             return send_simple_response(response, 500, "error",
                 "error opening authorized_keys tmp file");
         return send_simple_response(response, 500, "error",
diff --git a/src/auxiliary.c b/src/auxiliary.c
index 90ab5ab..d586e45 100644
--- a/src/auxiliary.c
+++ b/src/auxiliary.c
@@ -263,7 +263,7 @@ int replace_ssh_key(int id, const char * ssh_key)
         {
             // Copy 1 line
             ch = getc(authorized_keys_in);
-            while(ch != EOF && ch != '\n')
+            while (ch != EOF && ch != '\n')
             {
                 // Copy all lines that don't have id as line number
                 putc(ch, authorized_keys_out);
@@ -274,11 +274,11 @@ int replace_ssh_key(int id, const char * ssh_key)
         {
             // Insert an ssh key instead of a line
             ch = *ssh_key++;
-            while(ch != '\0')
+            while (ch != '\0')
             {
                 // New line in ssh key is not allowed, because that will screw
                 // up the indices
-                if(ch != '\n')
+                if (ch != '\n')
                     putc(ch, authorized_keys_out);
                 ch = *ssh_key++;
             }
@@ -290,14 +290,14 @@ int replace_ssh_key(int id, const char * ssh_key)
             } while (ch != EOF && ch != '\n');
         }
 
-        if(ch != EOF)
+        if (ch != EOF)
         {
             // Insert newline
             putc('\n', authorized_keys_out);
             // Increment line number
             line_number++;
         }
-    } while(ch != EOF);
+    } while (ch != EOF);
 
     fclose(authorized_keys_in);
     fclose(authorized_keys_out);
-- 
GitLab