Modification of coding rule violation 51/153651/3
authorsanghyeok.oh <sanghyeok.oh@samsung.com>
Fri, 29 Sep 2017 05:10:05 +0000 (14:10 +0900)
committersanghyeok.oh <sanghyeok.oh@samsung.com>
Fri, 29 Sep 2017 07:26:44 +0000 (16:26 +0900)
Change-Id: I3e0c88f7c85200267d8cca500826da0112ebe323
Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
src/dbus_daemon.c
src/libdbuspolicy1.c
src/stest_common.c [changed mode: 0644->0755]
src/stest_cynara.c [changed mode: 0644->0755]
src/stest_method_call.c [changed mode: 0644->0755]
src/stest_ownership.c [changed mode: 0644->0755]
src/stest_signal.c [changed mode: 0644->0755]
src/test_runner.c

index 79e749e..eb6f5e3 100755 (executable)
@@ -27,7 +27,7 @@
 
 #define POOL_SIZE (16 * 1024 * 1024)
 
-#define err_r(_r, _msg) fprintf(stderr, "log: %d, %s, %s, %d, %s\n",(_r), (_msg), __func__, __LINE__, __FILE__)
+#define err_r(_r, _msg) fprintf(stderr, "log: %d, %s, %s, %d, %s\n", (_r), (_msg), __func__, __LINE__, __FILE__)
 #define err(_msg) err_r(errno, (_msg))
 
 static uint8_t* pool;
@@ -157,8 +157,7 @@ int parse_args(int argc, char** argv)
        int fdl = -1;
        int count = 0;
 
-       while (i < argc)
-       {
+       while (i < argc) {
                if (argv[i][0] == '-')
                        state = argv[i][1];
                else {
@@ -169,18 +168,18 @@ int parse_args(int argc, char** argv)
                                break;
 
                        case 'u':
-                               uid = strtoul(argv[i],NULL,10);
+                               uid = strtoul(argv[i], NULL, 10);
                                r = setuid((uid_t)uid);
-                               if (r< 0) {
+                               if (r < 0) {
                                        fprintf(stderr, "Cannot set uid");
                                        exit(-3245);
                                }
                        break;
 
                        case 'g':
-                               gid = strtoul(argv[i],NULL,10);
+                               gid = strtoul(argv[i], NULL, 10);
                                r = setgid((gid_t)gid);
-                               if (r< 0) {
+                               if (r < 0) {
                                        fprintf(stderr, "Cannot set gid");
                                        exit(-3245);
                                }
@@ -188,15 +187,13 @@ int parse_args(int argc, char** argv)
 
                        case 'l':
                                fdl = open("/proc/self/attr/current", 0, S_IWUSR);
-                               if (fdl < 0)
-                               {
-                                       fprintf(stderr,"Cannot open /proc/self/attr/current\n");
+                               if (fdl < 0) {
+                                       fprintf(stderr, "Cannot open /proc/self/attr/current\n");
                                        exit(-345);
                                }
 
                                r = write(fdl, argv[i], strlen(argv[i]));
-                               if (r < 0)
-                               {
+                               if (r < 0) {
                                        fprintf(stderr, "Cannot write to /proc/self/attr/current\n");
                                        close(fdl);
                                        exit(-345);
@@ -213,17 +210,16 @@ int parse_args(int argc, char** argv)
        return 0;
 }
 
-int main(int argc, char* argv[]) {
+int main(int argc, char* argv[])
+{
        int j = 0;
        int fd;
        parse_args(argc, argv);
        fd = bus_open_connection(KDBUS_SYSTEM_BUS_PATH, KDBUS_ATTACH_PIDS);
-       if (fd < 0) {
+       if (fd < 0)
                return -1;
-       }
 
-       while(server_names[j] != '\0')
-       {
+       while (server_names[j] != '\0') {
                if (bus_acquire_name(fd, server_names[j]))
                        return -1;
                j++;
@@ -231,6 +227,6 @@ int main(int argc, char* argv[]) {
 
        close(ready_fd);
 
-       for(;;);
+       for (;;);
        return 0;
 }
index 9c8c840..4d7e0e2 100755 (executable)
@@ -105,7 +105,7 @@ static int kdbus_hello(bool bus_type, uint64_t hello_flags, uint64_t attach_flag
        item = cmd->items;
        item->size = offsetof(struct kdbus_item, data) + sizeof(CONNECTION_LABEL);
        item->type = KDBUS_ITEM_CONN_DESCRIPTION;
-       memcpy (item->str, CONNECTION_LABEL, sizeof(CONNECTION_LABEL));
+       memcpy(item->str, CONNECTION_LABEL, sizeof(CONNECTION_LABEL));
        if (ioctl(fd, KDBUS_CMD_HELLO, cmd) < 0)
                goto err;
 
@@ -169,33 +169,37 @@ static bool dbuspolicy_init_once(void)
 
 static int bus_path_resolve(const char *bus_path, char *resolved_path, unsigned resolved_path_size, unsigned int *bus_type)
 {
-       char rp[PATH_MAX];
        char *p;
        const char user_suffix[] = "-user/bus";
        int suffix_pos;
+       int ret = -1;
 
-       p = realpath(bus_path, rp);
+       p = realpath(bus_path, NULL);
        if (!p)
                return -1;
 
        if (0 != strncmp(p, KDBUS_PATH_PREFIX, strlen(KDBUS_PATH_PREFIX)))
-               return -1;
+               goto err;
 
        if (0 == strcmp(p, KDBUS_SYSTEM_BUS_PATH)) {
                *bus_type = SYSTEM_BUS;
        } else {
                suffix_pos = strlen(p) - strlen(user_suffix);
                if (suffix_pos < 0)
-                       return -1;
+                       goto err;
 
                if (0 != strcmp(p + suffix_pos, user_suffix))
-                       return -1;
+                       goto err;
 
                *bus_type = SESSION_BUS;
        }
 
        snprintf(resolved_path, resolved_path_size, "%s", p);
-       return 0;
+       ret = 0;
+err:
+       if (p)
+               free(p);
+       return ret;
 }
 
 static bool init_once_done = false;
@@ -260,12 +264,13 @@ DBUSPOLICY1_EXPORT void dbuspolicy1_free(void* configuration)
 }
 
 #ifdef LIBDBUSPOLICY_TESTS_API
-DBUSPOLICY1_EXPORT void __dbuspolicy1_change_creds(void* configuration, uid_t uid, gid_t gid,const char* label) {
+DBUSPOLICY1_EXPORT void __dbuspolicy1_change_creds(void* configuration, uid_t uid, gid_t gid, const char* label)
+{
        (void)configuration;
        g_udesc.uid = uid;
        g_udesc.gid = gid;
        if (label)
-               strncpy (g_udesc.label, label, strlen(label) + 1);
+               strncpy(g_udesc.label, label, strlen(label) + 1);
 }
 #endif
 
@@ -342,9 +347,8 @@ int kdbus_get_conn_info(bool bus_type, const char *destination, int message_type
        _Static_assert((unsigned)KDBUS_ITEM_SECLABEL == KDBUS_ITEM_SECLABEL, "KDBUS_ITEM_SECLABEL not preserved when cast to unsigned");
        _Static_assert((unsigned)KDBUS_ITEM_OWNED_NAME == KDBUS_ITEM_OWNED_NAME, "KDBUS_ITEM_OWNED_NAME not preserved when cast to unsigned");
 
-       for (item = conn_info->items; (uintptr_t)item < items_end; item = (typeof(item))ALIGN8((uintptr_t)item + (unsigned)item->size))
-               switch ((unsigned)item->type)
-       {
+       for (item = conn_info->items; (uintptr_t)item < items_end; item = (typeof(item))ALIGN8((uintptr_t)item + (unsigned)item->size)) {
+               switch ((unsigned)item->type) {
                case KDBUS_ITEM_CREDS:
                        uid_n = item->creds.euid;
                        gid_n = item->creds.egid;
@@ -356,6 +360,7 @@ int kdbus_get_conn_info(bool bus_type, const char *destination, int message_type
                        empty_names = false;
                        k_names[k_i++] = item->name.name;
                        break;
+               }
        }
        if (!empty_names)
                k_names[k_i++] = NULL;
@@ -413,7 +418,7 @@ DBUSPOLICY1_EXPORT int dbuspolicy1_check_out(void* configuration,
        if (info.empty_names)
                r = __internal_can_send(bus_type, g_udesc.uid, g_udesc.gid, g_udesc.label, destination, path, interface, member, message_type);
        else
-        r = __internal_can_send_multi_dest(bus_type, g_udesc.uid, g_udesc.gid, g_udesc.label, info.k_names, path, interface, member, message_type);
+               r = __internal_can_send_multi_dest(bus_type, g_udesc.uid, g_udesc.gid, g_udesc.label, info.k_names, path, interface, member, message_type);
 
        if (r <= 0)
                goto end;
old mode 100644 (file)
new mode 100755 (executable)
index 6938047..e13ee03
@@ -18,11 +18,10 @@ void assert_printf(int res, int tc,  const char* value, int line, const char* fi
 
 void prepare_mask(int argc, char* argv[])
 {
-       if (argc > 1)
-       {
+       if (argc > 1) {
                int i = 1;
                test_cases_mask = 0;
-               for (;i < argc; i++) {
+               for (; i < argc; i++) {
                        int val = strtol(argv[i], NULL, 10);
                        if (val >= 0)
                                test_cases_mask |= (1<<val);
old mode 100644 (file)
new mode 100755 (executable)
index 7e1df99..daa8b24
@@ -10,7 +10,7 @@
 #define NEGATIVE_MATCH "negative"
 #define COUNT 1000
 
-void __dbuspolicy1_change_creds(void* configuration, uid_t uid, gid_t gid,const char* label);
+void __dbuspolicy1_change_creds(void* configuration, uid_t uid, gid_t gid, const char* label);
 
 int main(int argc, char* argv[])
 {
@@ -18,7 +18,7 @@ int main(int argc, char* argv[])
        int desired_result = 1;
        int i;
 
-       assert(argc>0);
+       assert(argc > 0);
 
        if (!strncmp(argv[0], NEGATIVE_MATCH, sizeof(NEGATIVE_MATCH)-1))
                desired_result = 0;
@@ -27,7 +27,7 @@ int main(int argc, char* argv[])
        c = dbuspolicy1_init("/sys/fs/kdbus/0-system/bus");
        assert(c != NULL);
 
-       __dbuspolicy1_change_creds(c,200,0,"L");
+       __dbuspolicy1_change_creds(c, 200, 0, "L");
 
        for (i = 0; i < COUNT; i++) {
                int result = dbuspolicy1_check_in(c, "cynara.destination", "cynara.sender",
old mode 100644 (file)
new mode 100755 (executable)
index d1bf8e1..dfda6e0
@@ -5,75 +5,75 @@
 #include <assert.h>
 #include "stest_common.h"
 
-void __dbuspolicy1_change_creds(void* configuration, uid_t uid, gid_t gid,const char* label);
+void __dbuspolicy1_change_creds(void* configuration, uid_t uid, gid_t gid, const char* label);
 
 int main(int argc, char* argv[])
 {
        void* c = NULL;
 
-       prepare_mask(argc,argv);
+       prepare_mask(argc, argv);
 
        c = dbuspolicy1_init("/sys/fs/kdbus/0-system/bus");
        assert(c != NULL);
 
-       __dbuspolicy1_change_creds(c,0,0,NULL);
+       __dbuspolicy1_change_creds(c, 0, 0, NULL);
        tassert(dbuspolicy1_check_out(c, "org.test.test2", "org.test.test3", NULL, "org.test.Itest1", "DoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) == true);
 
-       __dbuspolicy1_change_creds(c,5001,100,NULL);
+       __dbuspolicy1_change_creds(c, 5001, 100, NULL);
        tassert(dbuspolicy1_check_in(c, "org.test.test2", "org.test.test3", NULL, 0, 0, "", "org.test.Itest1", "DoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) == true);
 
-       __dbuspolicy1_change_creds(c,0,0,NULL);
+       __dbuspolicy1_change_creds(c, 0, 0, NULL);
        tassert(dbuspolicy1_check_out(c, "org.test.test2", "org.test.test3", "", "org.test.Itest1", "DontDoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) == false);
 
-       __dbuspolicy1_change_creds(c,5001,100,NULL);
+       __dbuspolicy1_change_creds(c, 5001, 100, NULL);
        tassert(dbuspolicy1_check_in(c, "org.test.test2", "org.test.test3", "", 0, 0,  "", "org.test.Itest1", "DontDoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) ==  false);
 
-       __dbuspolicy1_change_creds(c,0,0,NULL);
+       __dbuspolicy1_change_creds(c, 0, 0, NULL);
        tassert(dbuspolicy1_check_out(c, "org.test.test2", "org.test.test3", "", "org.test.Itest1", "NotKnown", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) == false);
 
-       __dbuspolicy1_change_creds(c,5001,100,NULL);
+       __dbuspolicy1_change_creds(c, 5001, 100, NULL);
        tassert(dbuspolicy1_check_in(c, "org.test.test2", "org.test.test3", "", 0, 0,  "", "org.test.Itest1", "NotKnown", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) ==  false);
 
-       __dbuspolicy1_change_creds(c,0,0,NULL);
+       __dbuspolicy1_change_creds(c, 0, 0, NULL);
        tassert(dbuspolicy1_check_out(c, "org.test.test2", "org.test.test3", "", "org.test.Itest2", "NotKnown", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) == false);
 
-       __dbuspolicy1_change_creds(c,5001,100,NULL);
+       __dbuspolicy1_change_creds(c, 5001, 100, NULL);
        tassert(dbuspolicy1_check_in(c, "org.test.test2", "org.test.test3", "", 0, 0,  "", "org.test.Itest2", "NotKnown", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) ==  false);
 
-       __dbuspolicy1_change_creds(c,5001,100,NULL);
+       __dbuspolicy1_change_creds(c, 5001, 100, NULL);
        tassert(dbuspolicy1_check_out(c, "org.test.test3", "org.test.test2", "", "org.test.Itest3", "NotKnown", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) == false);
 
-       __dbuspolicy1_change_creds(c,0,0,NULL);
+       __dbuspolicy1_change_creds(c, 0, 0, NULL);
        tassert(dbuspolicy1_check_in(c, "org.test.test3", "org.test.test2", "", 5001, 100,  "", "org.test.Itest3", "NotKnown", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) ==  false);
 
-       __dbuspolicy1_change_creds(c,5001,100,NULL);
+       __dbuspolicy1_change_creds(c, 5001, 100, NULL);
        tassert(dbuspolicy1_check_out(c, "org.test.test3", "org.test.test2", "", "org.test.Itest3", "DontDoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) == false);
 
-       __dbuspolicy1_change_creds(c,0,0,NULL);
+       __dbuspolicy1_change_creds(c, 0, 0, NULL);
        tassert(dbuspolicy1_check_in(c, "org.test.test3", "org.test.test2", "", 5001, 100,  "", "org.test.Itest3", "DontDoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) ==  false);
 
-       __dbuspolicy1_change_creds(c,5001,100,NULL);
+       __dbuspolicy1_change_creds(c, 5001, 100, NULL);
        tassert(dbuspolicy1_check_out(c, "org.test.test3", "org.test.test2", "", "org.test.Itest3", "DoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) == true);
 
-       __dbuspolicy1_change_creds(c,0,0,NULL);
-       tassert(dbuspolicy1_check_in(c, "org.test.test3", "org.test.test2", "", 5001, 100,  "" ,"org.test.Itest3", "DoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) ==  true);
+       __dbuspolicy1_change_creds(c, 0, 0, NULL);
+       tassert(dbuspolicy1_check_in(c, "org.test.test3", "org.test.test2", "", 5001, 100,  "" , "org.test.Itest3", "DoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) ==  true);
 
-       __dbuspolicy1_change_creds(c,5001,100,NULL);
+       __dbuspolicy1_change_creds(c, 5001, 100, NULL);
        tassert(dbuspolicy1_check_out(c, "org.test.test3", "org.test.test2", "", "org.test.Itest4", "DoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) == true);
 
-       __dbuspolicy1_change_creds(c,0,0,NULL);
+       __dbuspolicy1_change_creds(c, 0, 0, NULL);
        tassert(dbuspolicy1_check_in(c, "org.test.test3", "org.test.test2", "", 5001, 100,  NULL, "org.test.Itest4", "DoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) ==  true);
 
-       __dbuspolicy1_change_creds(c,5001,100,NULL);
+       __dbuspolicy1_change_creds(c, 5001, 100, NULL);
        tassert(dbuspolicy1_check_out(c, "org.test.test9", "org.test.test10", "", "org.test.Itest4", "DoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) == true);
 
-       __dbuspolicy1_change_creds(c,0,0,NULL);
+       __dbuspolicy1_change_creds(c, 0, 0, NULL);
        tassert(dbuspolicy1_check_in(c, "org.test.test9", "org.test.test10", "", 5001, 100,  NULL, "org.test.Itest4", "DoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) ==  true);
 
-       __dbuspolicy1_change_creds(c,0,0,NULL);
+       __dbuspolicy1_change_creds(c, 0, 0, NULL);
        tassert(dbuspolicy1_check_out(c, "org.test.test10", "org.test.test9", "", "org.test.Itest4", "DoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) == true);
 
-       __dbuspolicy1_change_creds(c,5001,100,NULL);
+       __dbuspolicy1_change_creds(c, 5001, 100, NULL);
        tassert(dbuspolicy1_check_in(c, "org.test.test10", "org.test.test9", "", 0, 0,  NULL, "org.test.Itest4", "DoIt", DBUSPOLICY_MESSAGE_TYPE_METHOD_CALL, "", 0, 0) ==  true);
 
        return 0;
old mode 100644 (file)
new mode 100755 (executable)
index 9172500..85fe6b3
@@ -5,13 +5,13 @@
 #include <assert.h>
 #include "stest_common.h"
 
-void __dbuspolicy1_change_creds(void* configuration, uid_t uid, gid_t gid,const char* label);
+void __dbuspolicy1_change_creds(void* configuration, uid_t uid, gid_t gid, const char* label);
 
 int main(int argc, char* argv[])
 {
        void* c = NULL;
 
-       prepare_mask(argc,argv);
+       prepare_mask(argc, argv);
 
        c = dbuspolicy1_init("/sys/fs/kdbus/0-system/bus");
        assert(c != NULL);
old mode 100644 (file)
new mode 100755 (executable)
index 5fbef7c..66c4472
@@ -5,21 +5,21 @@
 #include <assert.h>
 #include "stest_common.h"
 
-void __dbuspolicy1_change_creds(void* configuration, uid_t uid, gid_t gid,const char* label);
+void __dbuspolicy1_change_creds(void* configuration, uid_t uid, gid_t gid, const char* label);
 
 int main(int argc, char* argv[])
 {
        void* c = NULL;
 
-       prepare_mask(argc,argv);
+       prepare_mask(argc, argv);
 
        c = dbuspolicy1_init("/sys/fs/kdbus/0-system/bus");
        assert(c != NULL);
 
-       __dbuspolicy1_change_creds(c,0,0,NULL);
+       __dbuspolicy1_change_creds(c, 0, 0, NULL);
        tassert(dbuspolicy1_check_out(c, "",  "bli.bla.blubb test.test1 test.tes3", "", "/an/object/path", "", DBUSPOLICY_MESSAGE_TYPE_SIGNAL, "", 0, 0) == true);
 
-       __dbuspolicy1_change_creds(c,5010,0,NULL);
+       __dbuspolicy1_change_creds(c, 5010, 0, NULL);
        tassert(dbuspolicy1_check_out(c, "",  "bli.bla.blubb", "", "/an/object/path", "", DBUSPOLICY_MESSAGE_TYPE_SIGNAL, "", 0, 0) == false);
 
        return 0;
index cfcfac7..5c9cc42 100755 (executable)
@@ -135,7 +135,7 @@ static struct state {
 
 static void sm_reset(void)
 {
-       memset(&g_state, 0, sizeof (g_state));
+       memset(&g_state, 0, sizeof(g_state));
 }
 
 static int sm_update(char* buffer, int i)
@@ -183,11 +183,11 @@ static const char* sm_get_result(int i)
        return g_state.results[i];
 }
 
-static pid_t daemon_pids[4] ={0};
+static pid_t daemon_pids[4] = {0};
 static int daemons_pipe[4][2];
-static char* daemon_argv1[] = {TEST_PATH "dbus_daemon", "-q", NULL, "-n","org.test.test3", NULL};
-static char* daemon_argv2[] = {TEST_PATH "dbus_daemon", "-q", NULL,"-n", "org.test.test2", "-g", "100", "-u", "5001", NULL};
-static char* daemon_argv3[] = {TEST_PATH "dbus_daemon", "-q", NULL,"-n", "org.test.test12", "org.test.test9", NULL};
+static char* daemon_argv1[] = {TEST_PATH "dbus_daemon", "-q", NULL, "-n", "org.test.test3", NULL};
+static char* daemon_argv2[] = {TEST_PATH "dbus_daemon", "-q", NULL, "-n", "org.test.test2", "-g", "100", "-u", "5001", NULL};
+static char* daemon_argv3[] = {TEST_PATH "dbus_daemon", "-q", NULL, "-n", "org.test.test12", "org.test.test9", NULL};
 static char* daemon_argv4[] = {TEST_PATH "dbus_daemon", "-q", NULL, "-n", "org.test.test13", "org.test.test10", "org.test.test11", "-g", "100", "-u", "5001", NULL};
 static char** daemons[] = { daemon_argv1, daemon_argv2, daemon_argv3, daemon_argv4};
 
@@ -200,7 +200,7 @@ int daemon_init(void)
        int nfds = -1;
        int proc_num = sizeof(daemons)/sizeof(daemons[0]);
 
-       for (;i < proc_num;i++) {
+       for (; i < proc_num; i++) {
                if (pipe(daemons_pipe[i]) < 0) {
                        perror("cannot create pipe");
                        goto error1;
@@ -209,22 +209,22 @@ int daemon_init(void)
                daemon_pids[i] = fork();
                if (!daemon_pids[i]) {
                        char fdd[15];
-                       snprintf(fdd,sizeof(fdd)-1, "%d",daemons_pipe[i][PIPE_WRITE]);
+                       snprintf(fdd, sizeof(fdd)-1, "%d", daemons_pipe[i][PIPE_WRITE]);
                        daemons[i][2] = fdd;
-                       close (daemons_pipe[i][PIPE_READ]);
-                       (void)execv(daemons[i][0],daemons[i]);
+                       close(daemons_pipe[i][PIPE_READ]);
+                       (void)execv(daemons[i][0], daemons[i]);
                        exit(0);
-               } else if (daemon_pids[i] > 0){
-                       close (daemons_pipe[i][PIPE_WRITE]);
+               } else if (daemon_pids[i] > 0) {
+                       close(daemons_pipe[i][PIPE_WRITE]);
                } else
                        goto error1;
        }
 
        tv.tv_sec = 1;
        tv.tv_usec = 0;
-       while(1) {
+       while (1) {
                FD_ZERO(&rfds);
-               for (i = 0; i < proc_num;i++) {
+               for (i = 0; i < proc_num; i++) {
                        if (daemons_pipe[i][PIPE_READ] > -1)
                                FD_SET(daemons_pipe[i][PIPE_READ], &rfds);
                }
@@ -234,10 +234,10 @@ int daemon_init(void)
 
                nfds = select(FD_SETSIZE, &rfds, NULL, NULL, &tv);
                if (nfds > 0) {
-                       for (i = 0; i < proc_num;i++) {
+                       for (i = 0; i < proc_num; i++) {
                                if (daemons_pipe[i][PIPE_READ] > -1 && FD_ISSET(daemons_pipe[i][PIPE_READ], &rfds)) {
                                        ++ready_proc;
-                                       close (daemons_pipe[i][PIPE_READ]);
+                                       close(daemons_pipe[i][PIPE_READ]);
                                        daemons_pipe[i][PIPE_READ] = -1;
                                }
                        }
@@ -254,7 +254,7 @@ error1:
 int daemon_clear(void)
 {
        unsigned int i = 0;
-       for (;i < sizeof(daemons)/sizeof(daemons[0]);i++) {
+       for (; i < sizeof(daemons)/sizeof(daemons[0]); i++) {
                if (daemon_pids[i])
                        kill(daemon_pids[i], SIGKILL);
        }
@@ -289,7 +289,7 @@ static int call_script(char* path, char* argv[])
 int cynara_n_init(void)
 {
        char* argv[] = {CYNARA_PATH, "DENY", NULL};
-       return call_script(argv[0],argv);
+       return call_script(argv[0], argv);
 }
 
 int cynara_n_clear(void)
@@ -300,13 +300,13 @@ int cynara_n_clear(void)
 int cynara_init(void)
 {
        char* argv[] = {CYNARA_PATH, "ALLOW", NULL};
-       return call_script(argv[0],argv);
+       return call_script(argv[0], argv);
 }
 
 int cynara_clear(void)
 {
        char* argv[] = {CYNARA_PATH, NULL};
-       return call_script(argv[0],argv);
+       return call_script(argv[0], argv);
 }
 
 static char* args[3];
@@ -330,7 +330,7 @@ void parse_test_state(const struct binary* b, const char* test_name, char* buffe
 {
        char test_id[MAX_COMMENT];
 
-       switch(state_change) {
+       switch (state_change) {
        case INIT_TEST:
                sm_reset();
                break;
@@ -339,8 +339,8 @@ void parse_test_state(const struct binary* b, const char* test_name, char* buffe
                        int k = 0;
                        buffer[state_option] = 0;
                        get_test_id(test_id, b, test_name);
-                       fprintf(stderr, "[stdout][%s]%s\n",test_id, buffer);
-                       while ( (k = sm_update(buffer, k))) {
+                       fprintf(stderr, "[stdout][%s]%s\n", test_id, buffer);
+                       while ((k = sm_update(buffer, k))) {
                                const char* t_name = sm_get_result(0);
                                const char* result_code = sm_get_result(1);
                                bool is_successful = result_code[0] == '1' && result_code[1] == 0;
@@ -355,7 +355,7 @@ void parse_test_state(const struct binary* b, const char* test_name, char* buffe
        case NEW_STDERR:
                buffer[state_option] = 0;
                get_test_id(test_id, b, test_name);
-               fprintf(stderr, "[stderr][%s]%s\n",test_id, buffer);
+               fprintf(stderr, "[stderr][%s]%s\n", test_id, buffer);
                break;
        case RESULT_CODE:
                if (state_option != 0)
@@ -398,14 +398,14 @@ char* get_test_id(char* dest, const struct binary* b, const char* test_name)
 
 static void print_description(const char* name, const char* description)
 {
-       printf("%s;%s\n",name, description);
+       printf("%s;%s\n", name, description);
 }
 
 static void print_list(const char* test_name)
 {
        unsigned int i;
        char full_name[MAX_COMMENT];
-       for (i = 0;i < sizeof(tests)/sizeof(struct binary); i++) {
+       for (i = 0; i < sizeof(tests)/sizeof(struct binary); i++) {
                int j = 0;
                int l = strlen(tests[i].name);
                memcpy(full_name, tests[i].name, l+1);
@@ -415,7 +415,7 @@ static void print_list(const char* test_name)
                while (tests[i].test_cases[j].name) {
                        memcpy(full_name + l, tests[i].test_cases[j].name, strlen(tests[i].test_cases[j].name) + 1);
                        if (!test_name || strcmp(full_name, test_name) == 0)
-                               print_description(full_name,tests[i].test_cases[j].description);
+                               print_description(full_name, tests[i].test_cases[j].description);
                        j++;
                }
        }
@@ -444,7 +444,7 @@ static void stop_binary(const struct binary* b, pid_t pid, const char* test_name
                        b->parse(b, test_name, buffer, RESULT_SIGNAL, WTERMSIG(status));
                } else if (WIFSTOPPED(status)) {
                        b->parse(b, test_name, buffer, RESULT_SIGNAL, WSTOPSIG(status));
-        } else if (WIFCONTINUED(status)) {
+               } else if (WIFCONTINUED(status)) {
                        kill(pid, SIGKILL);
                        b->parse(b, test_name, buffer, RESULT_SIGNAL, -1);
                }
@@ -457,8 +457,8 @@ static void parse_output_with_timeout(const struct binary* b, pid_t pid, const c
        fd_set rfds;
        int nfds;
        int res;
-       tv.tv_sec = b->timeout/(1000*1000);
-       tv.tv_usec = (b->timeout-tv.tv_sec*1000*1000);
+       tv.tv_sec = b->timeout / (1000*1000);
+       tv.tv_usec = (b->timeout-tv.tv_sec * 1000*1000);
        while (1) {
                FD_ZERO(&rfds);
                FD_SET(stdout_pipe[PIPE_READ], &rfds);
@@ -472,7 +472,7 @@ static void parse_output_with_timeout(const struct binary* b, pid_t pid, const c
                                res = read(stdout_pipe[PIPE_READ], buffer, MAX_BUFFER-1);
                                if (res == 0 || (res < 0 && errno != EINTR))
                                        break;
-                               else if (res >=0)
+                               else if (res >= 0)
                                        b->parse(b, test_name, buffer, NEW_STDOUT, res);
                        }
 
@@ -519,19 +519,19 @@ static int create_child(const char* path, char* const arguments[])
                        return -1;
                }
 
-        // redirect stdout
+               // redirect stdout
                if (dup2(stdout_pipe[PIPE_WRITE], STDOUT_FILENO) == -1) {
                        perror("redirecting stdout failed");
                        return -1;
                }
 
-        // redirect stderr
+               // redirect stderr
                if (dup2(stderr_pipe[PIPE_WRITE], STDERR_FILENO) == -1) {
                        perror("redirecting stderr failed");
                        return -1;
                }
 
-        // all these are for use by parent only
+               // all these are for use by parent only
                close(stdin_pipe[PIPE_READ]);
                close(stdin_pipe[PIPE_WRITE]);
                close(stdout_pipe[PIPE_READ]);
@@ -606,14 +606,15 @@ static void run_test(const struct binary* b, const char* test_name)
                b->clean();
 }
 
-static void parse_run_test(const char* tc) {
+static void parse_run_test(const char* tc)
+{
        unsigned int i = 0;
-       for (i = 0;i < sizeof(tests)/sizeof(struct binary); i++) {
+       for (i = 0; i < sizeof(tests)/sizeof(struct binary); i++) {
                int len = strlen(tests[i].name);
                if (strncmp(tc, tests[i].name, len) == 0) {
                        if (tc[len] == '*' || tc[len] == '\0')
                                run_test(&tests[i], "");
-            else
+                       else
                                run_test(&tests[i], tc + len);
                }
        }
@@ -663,9 +664,7 @@ static void print_results()
 {
        int i = 0;
        for (i = 0; i < test_results_i; i++)
-       {
                printf("%s;%s;%s\n", test_results[i].name, test_results[i].result, test_results[i].comment);
-       }
 }
 
 int main(int argc, char* argv[])
@@ -678,11 +677,11 @@ int main(int argc, char* argv[])
        prepare_results();
 
        if (!requested_tc[0]) {
-               for (i = 0;i < sizeof(tests)/sizeof(struct binary); i++)
+               for (i = 0; i < sizeof(tests) / sizeof(struct binary); i++)
                    run_test(&tests[i], "");
        } else {
                i = 0;
-               while(requested_tc[i]) {
+               while (requested_tc[i]) {
                    parse_run_test(requested_tc[i]);
                        i++;
                }