shithub: lwext4

Download patch

ref: 1fd8182cfc6ba92966e01dfb0e389072776ce7be
parent: faa32647222d3dd0565b0b52d92454539b627a4d
author: gkostka <kostka.grzegorz@gmail.com>
date: Tue Jun 16 07:45:19 EDT 2015

clang-format: fs_test

--- a/fs_test/lwext4_client.c
+++ b/fs_test/lwext4_client.c
@@ -26,7 +26,6 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -69,14 +68,12 @@
     --addr (-a) - server ip address                             \n\
 \n";
 
-
-
 static int client_connect(void)
 {
     int fd = 0;
     struct sockaddr_in serv_addr;
 
-    if(winsock_init() < 0) {
+    if (winsock_init() < 0) {
         printf("winsock_init error\n");
         exit(-1);
     }
@@ -83,7 +80,7 @@
 
     memset(&serv_addr, '0', sizeof(serv_addr));
     fd = socket(AF_INET, SOCK_STREAM, 0);
-    if(fd < 0) {
+    if (fd < 0) {
         printf("socket() error: %s\n", strerror(errno));
         exit(-1);
     }
@@ -91,12 +88,12 @@
     serv_addr.sin_family = AF_INET;
     serv_addr.sin_port = htons(connection_port);
 
-    if(!inet_pton(AF_INET, server_addr, &serv_addr.sin_addr)){
+    if (!inet_pton(AF_INET, server_addr, &serv_addr.sin_addr)) {
         printf("inet_pton() error\n");
         exit(-1);
     }
 
-    if(connect(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr))){
+    if (connect(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr))) {
         printf("connect() error: %s\n", strerror(errno));
         exit(-1);
     }
@@ -104,24 +101,20 @@
     return fd;
 }
 
-
-
 static bool parse_opt(int argc, char **argv)
 {
     int option_index = 0;
     int c;
 
-    static struct option long_options[] =
-    {
-            {"call",    required_argument, 0, 'c'},
-            {"port",    required_argument, 0, 'p'},
-            {"addr",    required_argument, 0, 'a'},
-            {0, 0, 0, 0}
-    };
+    static struct option long_options[] = {{"call", required_argument, 0, 'c'},
+                                           {"port", required_argument, 0, 'p'},
+                                           {"addr", required_argument, 0, 'a'},
+                                           {0, 0, 0, 0}};
 
-    while(-1 != (c = getopt_long (argc, argv, "c:p:a:", long_options, &option_index))) {
+    while (-1 != (c = getopt_long(argc, argv, "c:p:a:", long_options,
+                                  &option_index))) {
 
-        switch(c){
+        switch (c) {
         case 'a':
             server_addr = optarg;
             break;
@@ -134,13 +127,11 @@
         default:
             printf("%s", usage);
             return false;
-
         }
     }
     return true;
 }
 
-
 int main(int argc, char *argv[])
 {
     int sockfd;
@@ -148,27 +139,26 @@
     int rc;
     char recvBuff[1024];
 
-    if(!parse_opt(argc, argv))
+    if (!parse_opt(argc, argv))
         return -1;
 
     sockfd = client_connect();
 
-
     n = send(sockfd, op_code, strlen(op_code), 0);
-    if(n < 0) {
+    if (n < 0) {
         printf("\tWrite error: %s fd = %d\n", strerror(errno), sockfd);
         return -1;
     }
 
     n = recv(sockfd, (void *)&rc, sizeof(rc), 0);
-    if(n < 0) {
+    if (n < 0) {
         printf("\tWrite error: %s fd = %d\n", strerror(errno), sockfd);
         return -1;
     }
 
     printf("rc: %d %s\n", rc, strerror(rc));
-    if(rc)
-        printf("\t%s\n",op_code);
+    if (rc)
+        printf("\t%s\n", op_code);
 
     winsock_fini();
     return rc;
@@ -179,7 +169,7 @@
 #if WIN32
     int rc;
     static WSADATA wsaData;
-    rc = WSAStartup(MAKEWORD(2,2), &wsaData);
+    rc = WSAStartup(MAKEWORD(2, 2), &wsaData);
     if (rc != 0) {
         return -1;
     }
@@ -194,21 +184,21 @@
 #endif
 }
 
-
 #if WIN32
 static int inet_pton(int af, const char *src, void *dst)
 {
     struct sockaddr_storage ss;
     int size = sizeof(ss);
-    char src_copy[INET6_ADDRSTRLEN+1];
+    char src_copy[INET6_ADDRSTRLEN + 1];
 
     ZeroMemory(&ss, sizeof(ss));
     /* stupid non-const API */
-    strncpy (src_copy, src, INET6_ADDRSTRLEN+1);
+    strncpy(src_copy, src, INET6_ADDRSTRLEN + 1);
     src_copy[INET6_ADDRSTRLEN] = 0;
 
-    if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) == 0) {
-        switch(af) {
+    if (WSAStringToAddress(src_copy, af, NULL, (struct sockaddr *)&ss, &size) ==
+        0) {
+        switch (af) {
         case AF_INET:
             *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr;
             return 1;
--- a/fs_test/lwext4_server.c
+++ b/fs_test/lwext4_server.c
@@ -26,7 +26,6 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -48,7 +47,6 @@
 #include <sys/types.h>
 #endif
 
-
 #include <ext4_filedev.h>
 #include <io_raw.h>
 
@@ -57,15 +55,14 @@
 
 static int winsock_init(void);
 static void winsock_fini(void);
-static char* entry_to_str(uint8_t type);
+static char *entry_to_str(uint8_t type);
 
-#define MAX_FILES   64
-#define MAX_DIRS    64
+#define MAX_FILES 64
+#define MAX_DIRS 64
 
-#define MAX_RW_BUFFER   (1024 * 1024)
-#define RW_BUFFER_PATERN    ('x')
+#define MAX_RW_BUFFER (1024 * 1024)
+#define RW_BUFFER_PATERN ('x')
 
-
 /**@brief   Default connection port*/
 static int connection_port = 1234;
 
@@ -86,7 +83,6 @@
 static char read_buffer[MAX_RW_BUFFER];
 static char write_buffer[MAX_RW_BUFFER];
 
-
 static const char *usage = "                                    \n\
 Welcome in lwext4_server.                                       \n\
 Copyright (c) 2013 Grzegorz Kostka (kostka.grzegorz@gmail.com)  \n\
@@ -98,27 +94,29 @@
     --cache_wb  (-c) - cache writeback_mode                     \n\
 \n";
 
-
-
 /**@brief   Open file instance descriptor.*/
-struct lwext4_files {
-    char        name[255];
-    ext4_file   fd;
+struct lwext4_files
+{
+    char name[255];
+    ext4_file fd;
 };
 
 /**@brief   Open directory instance descriptor.*/
-struct lwext4_dirs {
-    char        name[255];
-    ext4_dir    fd;
+struct lwext4_dirs
+{
+    char name[255];
+    ext4_dir fd;
 };
 
 /**@brief   Library call opcode.*/
-struct lwext4_op_codes {
+struct lwext4_op_codes
+{
     char *func;
 };
 
 /**@brief   Library call wraper.*/
-struct lwext4_call {
+struct lwext4_call
+{
     int (*lwext4_call)(char *p);
 };
 
@@ -126,37 +124,18 @@
 static struct lwext4_files file_tab[MAX_FILES];
 
 /**@brief  */
-static struct lwext4_dirs  dir_tab[MAX_DIRS];
+static struct lwext4_dirs dir_tab[MAX_DIRS];
 
 /**@brief  */
 static struct lwext4_op_codes op_codes[] = {
-        "device_register",
-        "mount",
-        "umount",
-        "mount_point_stats",
-        "cache_write_back",
-        "fremove",
-        "fopen",
-        "fclose",
-        "fread",
-        "fwrite",
-        "fseek",
-        "ftell",
-        "fsize",
-        "dir_rm",
-        "dir_mk",
-        "dir_open",
-        "dir_close",
-        "dir_entry_get",
+    "device_register",  "mount",         "umount",      "mount_point_stats",
+    "cache_write_back", "fremove",       "fopen",       "fclose",
+    "fread",            "fwrite",        "fseek",       "ftell",
+    "fsize",            "dir_rm",        "dir_mk",      "dir_open",
+    "dir_close",        "dir_entry_get",
 
-        "multi_fcreate",
-        "multi_fwrite",
-        "multi_fread",
-        "multi_fremove",
-        "multi_dcreate",
-        "multi_dremove",
-        "stats_save",
-        "stats_check",
+    "multi_fcreate",    "multi_fwrite",  "multi_fread", "multi_fremove",
+    "multi_dcreate",    "multi_dremove", "stats_save",  "stats_check",
 };
 
 int _device_register(char *p);
@@ -190,33 +169,33 @@
 
 /**@brief  */
 static struct lwext4_call op_call[] = {
-        _device_register,  /*PARAMS(3):   0 cache_mode dev_name   */
-        _mount,            /*PARAMS(2):   dev_name mount_point    */
-        _umount,           /*PARAMS(1):   mount_point             */
-        _mount_point_stats,/*PARAMS(2):   mount_point, 0          */
-        _cache_write_back, /*PARAMS(2):   mount_point, en         */
-        _fremove,          /*PARAMS(1):   path                    */
-        _fopen,            /*PARAMS(2):   fid path flags          */
-        _fclose,           /*PARAMS(1):   fid                     */
-        _fread,            /*PARAMS(4):   fid 0 len 0             */
-        _fwrite,           /*PARAMS(4):   fid 0 len 0             */
-        _fseek,            /*PARAMS(2):   fid off origin          */
-        _ftell,            /*PARAMS(2):   fid exp                 */
-        _fsize,            /*PARAMS(2):   fid exp                 */
-        _dir_rm,           /*PARAMS(1):   path                    */
-        _dir_mk,           /*PARAMS(1):   path                    */
-        _dir_open,         /*PARAMS(2):   did, path               */
-        _dir_close,        /*PARAMS(1):   did                     */
-        _dir_entry_get,    /*PARAMS(2):   did, exp                */
+    _device_register,   /*PARAMS(3):   0 cache_mode dev_name   */
+    _mount,             /*PARAMS(2):   dev_name mount_point    */
+    _umount,            /*PARAMS(1):   mount_point             */
+    _mount_point_stats, /*PARAMS(2):   mount_point, 0          */
+    _cache_write_back,  /*PARAMS(2):   mount_point, en         */
+    _fremove,           /*PARAMS(1):   path                    */
+    _fopen,             /*PARAMS(2):   fid path flags          */
+    _fclose,            /*PARAMS(1):   fid                     */
+    _fread,             /*PARAMS(4):   fid 0 len 0             */
+    _fwrite,            /*PARAMS(4):   fid 0 len 0             */
+    _fseek,             /*PARAMS(2):   fid off origin          */
+    _ftell,             /*PARAMS(2):   fid exp                 */
+    _fsize,             /*PARAMS(2):   fid exp                 */
+    _dir_rm,            /*PARAMS(1):   path                    */
+    _dir_mk,            /*PARAMS(1):   path                    */
+    _dir_open,          /*PARAMS(2):   did, path               */
+    _dir_close,         /*PARAMS(1):   did                     */
+    _dir_entry_get,     /*PARAMS(2):   did, exp                */
 
-        _multi_fcreate,    /*PARAMS(3):   path prefix cnt         */
-        _multi_fwrite,     /*PARAMS(4):   path prefix cnt size    */
-        _multi_fread,      /*PARAMS(4):   path prefix cnt size    */
-        _multi_fremove,    /*PARAMS(2):   path prefix cnt         */
-        _multi_dcreate,    /*PARAMS(3):   path prefix cnt         */
-        _multi_dremove,    /*PARAMS(2):   path prefix             */
-        _stats_save,       /*PARAMS(1):   path                    */
-        _stats_check,      /*PARAMS(1):   path                    */
+    _multi_fcreate, /*PARAMS(3):   path prefix cnt         */
+    _multi_fwrite,  /*PARAMS(4):   path prefix cnt size    */
+    _multi_fread,   /*PARAMS(4):   path prefix cnt size    */
+    _multi_fremove, /*PARAMS(2):   path prefix cnt         */
+    _multi_dcreate, /*PARAMS(3):   path prefix cnt         */
+    _multi_dremove, /*PARAMS(2):   path prefix             */
+    _stats_save,    /*PARAMS(1):   path                    */
+    _stats_check,   /*PARAMS(1):   path                    */
 };
 
 static clock_t get_ms(void)
@@ -234,10 +213,10 @@
 
     for (i = 0; i < sizeof(op_codes) / sizeof(op_codes[0]); ++i) {
 
-        if(strncmp(op_codes[i].func, opcode, strlen(op_codes[i].func)))
+        if (strncmp(op_codes[i].func, opcode, strlen(op_codes[i].func)))
             continue;
 
-        if(opcode[strlen(op_codes[i].func)] != ' ')
+        if (opcode[strlen(op_codes[i].func)] != ' ')
             continue;
 
         printf("%s\n", opcode);
@@ -255,7 +234,6 @@
     return r;
 }
 
-
 static int server_open(void)
 {
     int fd = 0;
@@ -263,13 +241,13 @@
 
     memset(&serv_addr, 0, sizeof(serv_addr));
 
-    if(winsock_init() < 0) {
+    if (winsock_init() < 0) {
         printf("winsock_init() error\n");
         exit(-1);
     }
 
     fd = socket(AF_INET, SOCK_STREAM, 0);
-    if(fd < 0) {
+    if (fd < 0) {
         printf("socket() error: %s\n", strerror(errno));
         exit(-1);
     }
@@ -284,12 +262,12 @@
     serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
     serv_addr.sin_port = htons(connection_port);
 
-    if(bind(fd, (struct sockaddr*)&serv_addr, sizeof(serv_addr))){
+    if (bind(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr))) {
         printf("bind() error: %s\n", strerror(errno));
         exit(-1);
     }
 
-    if(listen(fd, 1)){
+    if (listen(fd, 1)) {
         printf("listen() error: %s\n", strerror(errno));
         exit(-1);
     }
@@ -303,17 +281,17 @@
     int c;
 
     static struct option long_options[] = {
-            {"image",   required_argument, 0, 'i'},
-            {"port",    required_argument, 0, 'p'},
-            {"verbose", required_argument, 0, 'v'},
-            {"winpart", required_argument, 0, 'w'},
-            {"cache_wb",required_argument, 0, 'c'},
-            {0, 0, 0, 0}
-    };
+        {"image", required_argument, 0, 'i'},
+        {"port", required_argument, 0, 'p'},
+        {"verbose", required_argument, 0, 'v'},
+        {"winpart", required_argument, 0, 'w'},
+        {"cache_wb", required_argument, 0, 'c'},
+        {0, 0, 0, 0}};
 
-    while(-1 != (c = getopt_long (argc, argv, "c:i:p:v:w:", long_options, &option_index))) {
+    while (-1 != (c = getopt_long(argc, argv, "c:i:p:v:w:", long_options,
+                                  &option_index))) {
 
-        switch(c){
+        switch (c) {
         case 'i':
             ext4_fname = optarg;
             break;
@@ -332,7 +310,6 @@
         default:
             printf("%s", usage);
             return false;
-
         }
     }
     return true;
@@ -345,7 +322,7 @@
     int connfd;
     char op_code[128];
 
-    if(!parse_opt(argc, argv))
+    if (!parse_opt(argc, argv))
         return -1;
 
     listenfd = server_open();
@@ -353,13 +330,12 @@
     printf("lwext4_server: listening on port: %d\n", connection_port);
 
     memset(write_buffer, RW_BUFFER_PATERN, MAX_RW_BUFFER);
-    while(1)
-    {
-        connfd = accept(listenfd, (struct sockaddr*)NULL, NULL);
+    while (1) {
+        connfd = accept(listenfd, (struct sockaddr *)NULL, NULL);
 
         n = recv(connfd, op_code, sizeof(op_code), 0);
 
-        if(n < 0) {
+        if (n < 0) {
             printf("recv() error: %s fd = %d\n", strerror(errno), connfd);
             break;
         }
@@ -369,7 +345,7 @@
         int r = exec_op_code(op_code);
 
         n = send(connfd, (void *)&r, sizeof(r), 0);
-        if(n < 0) {
+        if (n < 0) {
             printf("send() error: %s fd = %d\n", strerror(errno), connfd);
             break;
         }
@@ -381,7 +357,6 @@
     return 0;
 }
 
-
 int _device_register(char *p)
 {
     int dev;
@@ -388,18 +363,17 @@
     int cache_mode;
     char dev_name[32];
 
-    if(sscanf(p, "%d %d %s", &dev, &cache_mode, dev_name) != 3){
+    if (sscanf(p, "%d %d %s", &dev, &cache_mode, dev_name) != 3) {
         printf("Param list error\n");
         return -1;
     }
 
 #ifdef WIN32
-    if(winpart){
+    if (winpart) {
         ext4_io_raw_filename(ext4_fname);
         bd = ext4_io_raw_dev_get();
 
-    }
-    else
+    } else
 #endif
     {
         ext4_filedev_filename(ext4_fname);
@@ -414,13 +388,13 @@
     char mount_point[32];
     int rc;
 
-    if(sscanf(p, "%s %s", dev_name, mount_point) != 2){
+    if (sscanf(p, "%s %s", dev_name, mount_point) != 2) {
         printf("Param list error\n");
         return -1;
     }
 
     rc = ext4_mount(dev_name, mount_point);
-    if(cache_wb)
+    if (cache_wb)
         ext4_cache_write_back(mount_point, 1);
     return rc;
 }
@@ -429,12 +403,12 @@
 {
     char mount_point[32];
 
-    if(sscanf(p, "%s", mount_point) != 1){
+    if (sscanf(p, "%s", mount_point) != 1) {
         printf("Param list error\n");
         return -1;
     }
 
-    if(cache_wb)
+    if (cache_wb)
         ext4_cache_write_back(mount_point, 0);
 
     return ext4_umount(mount_point);
@@ -447,7 +421,7 @@
     int rc;
     struct ext4_mount_stats stats;
 
-    if(sscanf(p, "%s %d", mount_point, &d) != 2){
+    if (sscanf(p, "%s %d", mount_point, &d) != 2) {
         printf("Param list error\n");
         return -1;
     }
@@ -454,10 +428,10 @@
 
     rc = ext4_mount_point_stats(mount_point, &stats);
 
-    if(rc != EOK)
+    if (rc != EOK)
         return rc;
 
-    if(verbose){
+    if (verbose) {
         printf("\tinodes_count = %d\n", stats.inodes_count);
         printf("\tfree_inodes_count = %d\n", stats.free_inodes_count);
         printf("\tblocks_count = %llu\n", stats.blocks_count);
@@ -479,7 +453,7 @@
     char mount_point[32];
     int en;
 
-    if(sscanf(p, "%s %d", mount_point, &en) != 2){
+    if (sscanf(p, "%s %d", mount_point, &en) != 2) {
         printf("Param list error\n");
         return -1;
     }
@@ -487,12 +461,11 @@
     return ext4_cache_write_back(mount_point, en);
 }
 
-
 int _fremove(char *p)
 {
     char path[255];
 
-    if(sscanf(p, "%s", path) != 1){
+    if (sscanf(p, "%s", path) != 1) {
         printf("Param list error\n");
         return -1;
     }
@@ -507,12 +480,12 @@
     char flags[8];
     int rc;
 
-    if(sscanf(p, "%d %s %s", &fid, path, flags) != 3){
+    if (sscanf(p, "%d %s %s", &fid, path, flags) != 3) {
         printf("Param list error\n");
         return -1;
     }
 
-    if(!(fid < MAX_FILES)){
+    if (!(fid < MAX_FILES)) {
         printf("File id too big\n");
         return -1;
     }
@@ -519,7 +492,7 @@
 
     rc = ext4_fopen(&file_tab[fid].fd, path, flags);
 
-    if(rc == EOK)
+    if (rc == EOK)
         strcpy(file_tab[fid].name, path);
 
     return rc;
@@ -530,17 +503,17 @@
     int fid = MAX_FILES;
     int rc;
 
-    if(sscanf(p, "%d", &fid) != 1){
+    if (sscanf(p, "%d", &fid) != 1) {
         printf("Param list error\n");
         return -1;
     }
 
-    if(!(fid < MAX_FILES)){
+    if (!(fid < MAX_FILES)) {
         printf("File id too big\n");
         return -1;
     }
 
-    if(file_tab[fid].name[0] == 0){
+    if (file_tab[fid].name[0] == 0) {
         printf("File id empty\n");
         return -1;
     }
@@ -547,7 +520,7 @@
 
     rc = ext4_fclose(&file_tab[fid].fd);
 
-    if(rc == EOK)
+    if (rc == EOK)
         file_tab[fid].name[0] = 0;
 
     return rc;
@@ -561,36 +534,36 @@
     int rc;
     int rb;
 
-    if(sscanf(p, "%d %d %d %d", &fid, &d, &len, &d) != 4){
+    if (sscanf(p, "%d %d %d %d", &fid, &d, &len, &d) != 4) {
         printf("Param list error\n");
         return -1;
     }
 
-    if(!(fid < MAX_FILES)){
+    if (!(fid < MAX_FILES)) {
         printf("File id too big\n");
         return -1;
     }
 
-    if(file_tab[fid].name[0] == 0){
+    if (file_tab[fid].name[0] == 0) {
         printf("File id empty\n");
         return -1;
     }
 
-    while(len){
+    while (len) {
         d = len > MAX_RW_BUFFER ? MAX_RW_BUFFER : len;
 
         memset(read_buffer, 0, MAX_RW_BUFFER);
         rc = ext4_fread(&file_tab[fid].fd, read_buffer, d, &rb);
 
-        if(rc != EOK)
+        if (rc != EOK)
             break;
 
-        if(rb != d){
+        if (rb != d) {
             printf("Read count error\n");
             return -1;
         }
 
-        if(memcmp(read_buffer, write_buffer, d)){
+        if (memcmp(read_buffer, write_buffer, d)) {
             printf("Read compare error\n");
             return -1;
         }
@@ -609,29 +582,29 @@
     int rc;
     int wb;
 
-    if(sscanf(p, "%d %d %d %d", &fid, &d, &len, &d) != 4){
+    if (sscanf(p, "%d %d %d %d", &fid, &d, &len, &d) != 4) {
         printf("Param list error\n");
         return -1;
     }
 
-    if(!(fid < MAX_FILES)){
+    if (!(fid < MAX_FILES)) {
         printf("File id too big\n");
         return -1;
     }
 
-    if(file_tab[fid].name[0] == 0){
+    if (file_tab[fid].name[0] == 0) {
         printf("File id empty\n");
         return -1;
     }
 
-    while(len){
+    while (len) {
         d = len > MAX_RW_BUFFER ? MAX_RW_BUFFER : len;
         rc = ext4_fwrite(&file_tab[fid].fd, write_buffer, d, &wb);
 
-        if(rc != EOK)
+        if (rc != EOK)
             break;
 
-        if(wb != d){
+        if (wb != d) {
             printf("Write count error\n");
             return -1;
         }
@@ -648,17 +621,17 @@
     int off;
     int origin;
 
-    if(sscanf(p, "%d %d %d", &fid, &off, &origin) != 3){
+    if (sscanf(p, "%d %d %d", &fid, &off, &origin) != 3) {
         printf("Param list error\n");
         return -1;
     }
 
-    if(!(fid < MAX_FILES)){
+    if (!(fid < MAX_FILES)) {
         printf("File id too big\n");
         return -1;
     }
 
-    if(file_tab[fid].name[0] == 0){
+    if (file_tab[fid].name[0] == 0) {
         printf("File id empty\n");
         return -1;
     }
@@ -671,23 +644,22 @@
     int fid = MAX_FILES;
     uint32_t exp_pos;
 
-    if(sscanf(p, "%d %u", &fid, &exp_pos) != 2){
+    if (sscanf(p, "%d %u", &fid, &exp_pos) != 2) {
         printf("Param list error\n");
         return -1;
     }
 
-    if(!(fid < MAX_FILES)){
+    if (!(fid < MAX_FILES)) {
         printf("File id too big\n");
         return -1;
     }
 
-    if(file_tab[fid].name[0] == 0){
+    if (file_tab[fid].name[0] == 0) {
         printf("File id empty\n");
         return -1;
     }
 
-
-    if(exp_pos != ext4_ftell(&file_tab[fid].fd)){
+    if (exp_pos != ext4_ftell(&file_tab[fid].fd)) {
         printf("Expected filepos error\n");
         return -1;
     }
@@ -700,22 +672,22 @@
     int fid = MAX_FILES;
     uint32_t exp_size;
 
-    if(sscanf(p, "%d %u", &fid, &exp_size) != 2){
+    if (sscanf(p, "%d %u", &fid, &exp_size) != 2) {
         printf("Param list error\n");
         return -1;
     }
 
-    if(!(fid < MAX_FILES)){
+    if (!(fid < MAX_FILES)) {
         printf("File id too big\n");
         return -1;
     }
 
-    if(file_tab[fid].name[0] == 0){
+    if (file_tab[fid].name[0] == 0) {
         printf("File id empty\n");
         return -1;
     }
 
-    if(exp_size != ext4_fsize(&file_tab[fid].fd)){
+    if (exp_size != ext4_fsize(&file_tab[fid].fd)) {
         printf("Expected filesize error\n");
         return -1;
     }
@@ -727,7 +699,7 @@
 {
     char path[255];
 
-    if(sscanf(p, "%s", path) != 1){
+    if (sscanf(p, "%s", path) != 1) {
         printf("Param list error\n");
         return -1;
     }
@@ -739,7 +711,7 @@
 {
     char path[255];
 
-    if(sscanf(p, "%s", path) != 1){
+    if (sscanf(p, "%s", path) != 1) {
         printf("Param list error\n");
         return -1;
     }
@@ -753,12 +725,12 @@
     char path[255];
     int rc;
 
-    if(sscanf(p, "%d %s", &did, path) != 2){
+    if (sscanf(p, "%d %s", &did, path) != 2) {
         printf("Param list error\n");
         return -1;
     }
 
-    if(!(did < MAX_DIRS)){
+    if (!(did < MAX_DIRS)) {
         printf("Dir id too big\n");
         return -1;
     }
@@ -765,7 +737,7 @@
 
     rc = ext4_dir_open(&dir_tab[did].fd, path);
 
-    if(rc == EOK)
+    if (rc == EOK)
         strcpy(dir_tab[did].name, path);
 
     return rc;
@@ -776,17 +748,17 @@
     int did = MAX_DIRS;
     int rc;
 
-    if(sscanf(p, "%d", &did) != 1){
+    if (sscanf(p, "%d", &did) != 1) {
         printf("Param list error\n");
         return -1;
     }
 
-    if(!(did < MAX_DIRS)){
+    if (!(did < MAX_DIRS)) {
         printf("Dir id too big\n");
         return -1;
     }
 
-    if(dir_tab[did].name[0] == 0){
+    if (dir_tab[did].name[0] == 0) {
         printf("Dir id empty\n");
         return -1;
     }
@@ -793,7 +765,7 @@
 
     rc = ext4_dir_close(&dir_tab[did].fd);
 
-    if(rc == EOK)
+    if (rc == EOK)
         dir_tab[did].name[0] = 0;
 
     return rc;
@@ -805,42 +777,40 @@
     int exp;
     char name[256];
 
-    if(sscanf(p, "%d %d", &did, &exp) != 2){
+    if (sscanf(p, "%d %d", &did, &exp) != 2) {
         printf("Param list error\n");
         return -1;
     }
 
-    if(!(did < MAX_DIRS)){
+    if (!(did < MAX_DIRS)) {
         printf("Dir id too big\n");
         return -1;
     }
 
-    if(dir_tab[did].name[0] == 0){
+    if (dir_tab[did].name[0] == 0) {
         printf("Dir id empty\n");
         return -1;
     }
 
-
     int idx = 0;
     ext4_direntry *d;
 
-    while(d = ext4_dir_entry_next(&dir_tab[did].fd)){
+    while (d = ext4_dir_entry_next(&dir_tab[did].fd)) {
 
         idx++;
         memcpy(name, d->name, d->name_length);
         name[d->name_length] = 0;
-        if(verbose){
+        if (verbose) {
             printf("\t%s %s\n", entry_to_str(d->inode_type), name);
         }
     }
 
-
-    if(idx < 2){
+    if (idx < 2) {
         printf("Minumum dir entry error\n");
         return -1;
     }
 
-    if((idx - 2) != exp){
+    if ((idx - 2) != exp) {
         printf("Expected dir entry error\n");
         return -1;
     }
@@ -856,9 +826,9 @@
     int cnt;
     int rc;
     int i;
-    ext4_file   fd;
+    ext4_file fd;
 
-    if(sscanf(p, "%s %s %d", path, prefix, &cnt) != 3){
+    if (sscanf(p, "%s %s %d", path, prefix, &cnt) != 3) {
         printf("Param list error\n");
         return -1;
     }
@@ -867,7 +837,7 @@
         sprintf(path1, "%s%s%d", path, prefix, i);
         rc = ext4_fopen(&fd, path1, "wb+");
 
-        if(rc != EOK)
+        if (rc != EOK)
             break;
     }
 
@@ -883,9 +853,9 @@
     int len, ll;
     int rc;
     int i, d, wb;
-    ext4_file   fd;
+    ext4_file fd;
 
-    if(sscanf(p, "%s %s %d %d", path, prefix, &cnt, &ll) != 4){
+    if (sscanf(p, "%s %s %d %d", path, prefix, &cnt, &ll) != 4) {
         printf("Param list error\n");
         return -1;
     }
@@ -894,18 +864,18 @@
         sprintf(path1, "%s%s%d", path, prefix, i);
         rc = ext4_fopen(&fd, path1, "rb+");
 
-        if(rc != EOK)
+        if (rc != EOK)
             break;
 
         len = ll;
-        while(len){
+        while (len) {
             d = len > MAX_RW_BUFFER ? MAX_RW_BUFFER : len;
             rc = ext4_fwrite(&fd, write_buffer, d, &wb);
 
-            if(rc != EOK)
+            if (rc != EOK)
                 break;
 
-            if(wb != d){
+            if (wb != d) {
                 printf("Write count error\n");
                 return -1;
             }
@@ -926,9 +896,9 @@
     int len, ll;
     int rc;
     int i, d, rb;
-    ext4_file   fd;
+    ext4_file fd;
 
-    if(sscanf(p, "%s %s %d %d", path, prefix, &cnt, &ll) != 4){
+    if (sscanf(p, "%s %s %d %d", path, prefix, &cnt, &ll) != 4) {
         printf("Param list error\n");
         return -1;
     }
@@ -937,25 +907,25 @@
         sprintf(path1, "%s%s%d", path, prefix, i);
         rc = ext4_fopen(&fd, path1, "rb+");
 
-        if(rc != EOK)
+        if (rc != EOK)
             break;
 
         len = ll;
-        while(len){
+        while (len) {
             d = len > MAX_RW_BUFFER ? MAX_RW_BUFFER : len;
 
             memset(read_buffer, 0, MAX_RW_BUFFER);
             rc = ext4_fread(&fd, read_buffer, d, &rb);
 
-            if(rc != EOK)
+            if (rc != EOK)
                 break;
 
-            if(rb != d){
+            if (rb != d) {
                 printf("Read count error\n");
                 return -1;
             }
 
-            if(memcmp(read_buffer, write_buffer, d)){
+            if (memcmp(read_buffer, write_buffer, d)) {
                 printf("Read compare error\n");
                 return -1;
             }
@@ -972,9 +942,9 @@
     char path[256];
     char path1[256];
     char prefix[32];
-    int  cnt, i, rc;
+    int cnt, i, rc;
 
-    if(sscanf(p, "%s %s %d", path, prefix, &cnt) != 3){
+    if (sscanf(p, "%s %s %d", path, prefix, &cnt) != 3) {
         printf("Param list error\n");
         return -1;
     }
@@ -982,7 +952,7 @@
     for (i = 0; i < cnt; ++i) {
         sprintf(path1, "%s%s%d", path, prefix, i);
         rc = ext4_fremove(path1);
-        if(rc != EOK)
+        if (rc != EOK)
             break;
     }
 
@@ -994,9 +964,9 @@
     char path[256];
     char path1[256];
     char prefix[32];
-    int  cnt, i, rc;
+    int cnt, i, rc;
 
-    if(sscanf(p, "%s %s %d", path, prefix, &cnt) != 3){
+    if (sscanf(p, "%s %s %d", path, prefix, &cnt) != 3) {
         printf("Param list error\n");
         return -1;
     }
@@ -1004,7 +974,7 @@
     for (i = 0; i < cnt; ++i) {
         sprintf(path1, "%s%s%d", path, prefix, i);
         rc = ext4_dir_mk(path1);
-        if(rc != EOK)
+        if (rc != EOK)
             break;
     }
 
@@ -1016,9 +986,9 @@
     char path[256];
     char path1[256];
     char prefix[32];
-    int  cnt, i, rc;
+    int cnt, i, rc;
 
-    if(sscanf(p, "%s %s %d", path, prefix, &cnt) != 3){
+    if (sscanf(p, "%s %s %d", path, prefix, &cnt) != 3) {
         printf("Param list error\n");
         return -1;
     }
@@ -1026,7 +996,7 @@
     for (i = 0; i < cnt; ++i) {
         sprintf(path1, "%s%s%d", path, prefix, i);
         rc = ext4_dir_rm(path1);
-        if(rc != EOK)
+        if (rc != EOK)
             break;
     }
 
@@ -1033,13 +1003,13 @@
     return rc;
 }
 
-struct ext4_mount_stats  saved_stats;
+struct ext4_mount_stats saved_stats;
 
 int _stats_save(char *p)
 {
     char path[256];
 
-    if(sscanf(p, "%s", path) != 1){
+    if (sscanf(p, "%s", path) != 1) {
         printf("Param list error\n");
         return -1;
     }
@@ -1052,9 +1022,9 @@
     char path[256];
     int rc;
 
-    struct ext4_mount_stats  actual_stats;
+    struct ext4_mount_stats actual_stats;
 
-    if(sscanf(p, "%s", path) != 1){
+    if (sscanf(p, "%s", path) != 1) {
         printf("Param list error\n");
         return -1;
     }
@@ -1061,17 +1031,18 @@
 
     rc = ext4_mount_point_stats(path, &actual_stats);
 
-    if(rc != EOK)
+    if (rc != EOK)
         return rc;
 
-    if(memcmp(&saved_stats, &actual_stats, sizeof(struct ext4_mount_stats))){
-        if(verbose){
+    if (memcmp(&saved_stats, &actual_stats, sizeof(struct ext4_mount_stats))) {
+        if (verbose) {
             printf("\tMount point stats error:\n");
             printf("\tsaved_stats:\n");
             printf("\tinodes_count = %d\n", saved_stats.inodes_count);
             printf("\tfree_inodes_count = %d\n", saved_stats.free_inodes_count);
             printf("\tblocks_count = %llu\n", saved_stats.blocks_count);
-            printf("\tfree_blocks_count = %llu\n", saved_stats.free_blocks_count);
+            printf("\tfree_blocks_count = %llu\n",
+                   saved_stats.free_blocks_count);
             printf("\tblock_size = %d\n", saved_stats.block_size);
             printf("\tblock_group_count = %d\n", saved_stats.block_group_count);
             printf("\tblocks_per_group = %d\n", saved_stats.blocks_per_group);
@@ -1079,11 +1050,14 @@
             printf("\tvolume_name = %s\n", saved_stats.volume_name);
             printf("\tactual_stats:\n");
             printf("\tinodes_count = %d\n", actual_stats.inodes_count);
-            printf("\tfree_inodes_count = %d\n", actual_stats.free_inodes_count);
+            printf("\tfree_inodes_count = %d\n",
+                   actual_stats.free_inodes_count);
             printf("\tblocks_count = %llu\n", actual_stats.blocks_count);
-            printf("\tfree_blocks_count = %llu\n", actual_stats.free_blocks_count);
+            printf("\tfree_blocks_count = %llu\n",
+                   actual_stats.free_blocks_count);
             printf("\tblock_size = %d\n", actual_stats.block_size);
-            printf("\tblock_group_count = %d\n", actual_stats.block_group_count);
+            printf("\tblock_group_count = %d\n",
+                   actual_stats.block_group_count);
             printf("\tblocks_per_group = %d\n", actual_stats.blocks_per_group);
             printf("\tinodes_per_group = %d\n", actual_stats.inodes_per_group);
             printf("\tvolume_name = %s\n", actual_stats.volume_name);
@@ -1091,14 +1065,12 @@
         return -1;
     }
 
-
-   return rc;
+    return rc;
 }
 
-
-static char* entry_to_str(uint8_t type)
+static char *entry_to_str(uint8_t type)
 {
-    switch(type){
+    switch (type) {
     case EXT4_DIRENTRY_UNKNOWN:
         return "[UNK] ";
     case EXT4_DIRENTRY_REG_FILE:
@@ -1126,7 +1098,7 @@
 #if WIN32
     int rc;
     static WSADATA wsaData;
-    rc = WSAStartup(MAKEWORD(2,2), &wsaData);
+    rc = WSAStartup(MAKEWORD(2, 2), &wsaData);
     if (rc != 0) {
         return -1;
     }
@@ -1140,4 +1112,3 @@
     WSACleanup();
 #endif
 }
-