diff options
author | PaulK <contact@paulk.fr> | 2012-02-21 20:43:04 +0100 |
---|---|---|
committer | PaulK <contact@paulk.fr> | 2012-02-01 04:48:09 +0100 |
commit | 9b827bdb9c147c77c0d32cd3f4c41768818d8eaa (patch) | |
tree | 0414f1ca623689f0ea6a7025f08823d189367093 | |
parent | b7e7b7701358836bdfe3042f427236bb047fd28b (diff) | |
download | hardware_replicant_libsamsung-ipc-9b827bdb9c147c77c0d32cd3f4c41768818d8eaa.tar.gz hardware_replicant_libsamsung-ipc-9b827bdb9c147c77c0d32cd3f4c41768818d8eaa.tar.bz2 hardware_replicant_libsamsung-ipc-9b827bdb9c147c77c0d32cd3f4c41768818d8eaa.zip |
Fixed coding style: space after if, for, while, etc
-rw-r--r-- | samsung-ipc/gen.c | 2 | ||||
-rw-r--r-- | samsung-ipc/ipc.c | 40 | ||||
-rw-r--r-- | samsung-ipc/ipc_util.c | 24 | ||||
-rw-r--r-- | samsung-ipc/rfs.c | 74 |
4 files changed, 70 insertions, 70 deletions
diff --git a/samsung-ipc/gen.c b/samsung-ipc/gen.c index 79c4746..e038f9b 100644 --- a/samsung-ipc/gen.c +++ b/samsung-ipc/gen.c @@ -23,7 +23,7 @@ int ipc_gen_phone_res_check(struct ipc_gen_phone_res *res) { - if(res == NULL) + if (res == NULL) return -1; switch(res->code) diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c index 7ac9694..eb0eeff 100644 --- a/samsung-ipc/ipc.c +++ b/samsung-ipc/ipc.c @@ -65,9 +65,9 @@ int ipc_device_detect(void) int i; #ifdef IPC_DEVICE_EXPLICIT - for(i=0 ; i < ipc_devices_count ; i++) + for (i=0 ; i < ipc_devices_count ; i++) { - if(strcmp(IPC_DEVICE_EXPLICIT, ipc_devices[i].name) == 0) + if (strcmp(IPC_DEVICE_EXPLICIT, ipc_devices[i].name) == 0) { index = i; break; @@ -92,15 +92,15 @@ int ipc_device_detect(void) int len = strlen(str); char tmp; - for(i=0 ; i < len ; i++) + for (i=0 ; i < len ; i++) { tmp = (char) tolower(str[i]); str[i] = tmp; } - for(i=0 ; i < ipc_devices_count ; i++) + for (i=0 ; i < ipc_devices_count ; i++) { - if(strstr(pch, ipc_devices[i].board_name) != NULL) + if (strstr(pch, ipc_devices[i].board_name) != NULL) { index = i; break; @@ -121,7 +121,7 @@ struct ipc_client* ipc_client_new(int client_type) device_index = ipc_device_detect(); - if(device_index < 0 || device_index > ipc_devices_count) + if (device_index < 0 || device_index > ipc_devices_count) return NULL; if (client_type < 0 || client_type > IPC_CLIENT_TYPE_RFS) @@ -159,7 +159,7 @@ int ipc_client_free(struct ipc_client *client) int ipc_client_set_log_handler(struct ipc_client *client, ipc_client_log_handler_cb log_handler_cb, void *user_data) { - if(client == NULL) + if (client == NULL) return -1; client->log_handler = log_handler_cb; @@ -170,7 +170,7 @@ int ipc_client_set_log_handler(struct ipc_client *client, ipc_client_log_handler int ipc_client_set_handlers(struct ipc_client *client, struct ipc_handlers *handlers) { - if(client == NULL || + if (client == NULL || handlers == NULL) return -1; @@ -183,17 +183,17 @@ int ipc_client_set_io_handlers(struct ipc_client *client, ipc_io_handler_cb read, void *read_data, ipc_io_handler_cb write, void *write_data) { - if(client == NULL || + if (client == NULL || client->handlers == NULL) return -1; - if(read != NULL) + if (read != NULL) client->handlers->read = read; - if(read_data != NULL) + if (read_data != NULL) client->handlers->read_data = read_data; - if(write != NULL) + if (write != NULL) client->handlers->write = write; - if(write_data != NULL) + if (write_data != NULL) client->handlers->write_data = write_data; return 0; @@ -203,7 +203,7 @@ int ipc_client_set_handlers_common_data(struct ipc_client *client, void *data) { void *common_data; - if(client == NULL || + if (client == NULL || client->handlers == NULL || data == NULL) return -1; @@ -223,7 +223,7 @@ int ipc_client_set_handlers_common_data(struct ipc_client *client, void *data) void *ipc_client_get_handlers_common_data(struct ipc_client *client) { - if(client == NULL || + if (client == NULL || client->handlers == NULL) return NULL; @@ -234,7 +234,7 @@ int ipc_client_create_handlers_common_data(struct ipc_client *client) { void *common_data; - if(client == NULL || + if (client == NULL || client->handlers == NULL) return -1; @@ -256,14 +256,14 @@ int ipc_client_destroy_handlers_common_data(struct ipc_client *client) void *common_data; int rc; - if(client == NULL || + if (client == NULL || client->handlers == NULL || client->handlers->common_data_destroy == NULL) return -1; rc = client->handlers->common_data_destroy(client->handlers->common_data); - if(rc < 0) + if (rc < 0) return -1; common_data = NULL; @@ -281,7 +281,7 @@ int ipc_client_destroy_handlers_common_data(struct ipc_client *client) int ipc_client_set_handlers_common_data_fd(struct ipc_client *client, int fd) { - if(client == NULL || + if (client == NULL || client->handlers == NULL || client->handlers->common_data_set_fd == NULL) return -1; @@ -291,7 +291,7 @@ int ipc_client_set_handlers_common_data_fd(struct ipc_client *client, int fd) int ipc_client_get_handlers_common_data_fd(struct ipc_client *client) { - if(client == NULL || + if (client == NULL || client->handlers == NULL || client->handlers->common_data_get_fd == NULL) return -1; diff --git a/samsung-ipc/ipc_util.c b/samsung-ipc/ipc_util.c index 8001e5e..10e2ca9 100644 --- a/samsung-ipc/ipc_util.c +++ b/samsung-ipc/ipc_util.c @@ -202,7 +202,7 @@ void ipc_hex_dump(struct ipc_client *client, void *data, int size) char addrstr[10] = {0}; char hexstr[ 16*3 + 5] = {0}; char charstr[16*1 + 5] = {0}; - for(n=1;n<=size;n++) { + for (n=1;n<=size;n++) { if (n%16 == 1) { /* store address for this line */ snprintf(addrstr, sizeof(addrstr), "%.4x", @@ -222,12 +222,12 @@ void ipc_hex_dump(struct ipc_client *client, void *data, int size) snprintf(bytestr, sizeof(bytestr), "%c", c); strncat(charstr, bytestr, sizeof(charstr)-strlen(charstr)-1); - if(n%16 == 0) { + if (n%16 == 0) { /* line completed */ ipc_client_log(client, "[%4.4s] %-50.50s %s", addrstr, hexstr, charstr); hexstr[0] = 0; charstr[0] = 0; - } else if(n%8 == 0) { + } else if (n%8 == 0) { /* half line: add whitespaces */ strncat(hexstr, " ", sizeof(hexstr)-strlen(hexstr)-1); strncat(charstr, " ", sizeof(charstr)-strlen(charstr)-1); @@ -250,27 +250,27 @@ void *ipc_mtd_read(struct ipc_client *client, char *mtd_name, int size, int bloc int fd; int i; - if(mtd_name == NULL || size <= 0 || block_size <= 0) + if (mtd_name == NULL || size <= 0 || block_size <= 0) goto error; ipc_client_log(client, "ipc_mtd_read: reading 0x%x bytes from %s with 0x%x bytes block size\n", size, mtd_name, block_size); fd=open(mtd_name, O_RDONLY); - if(fd < 0) + if (fd < 0) goto error; mtd_p=malloc(size); - if(mtd_p == NULL) + if (mtd_p == NULL) goto error; memset(mtd_p, 0, size); data_p=(uint8_t *) mtd_p; - for(i=0 ; i < size / block_size ; i++) + for (i=0 ; i < size / block_size ; i++) { offs = i * block_size; - if(ioctl(fd, MEMGETBADBLOCK, &offs) == 1) + if (ioctl(fd, MEMGETBADBLOCK, &offs) == 1) { ipc_client_log(client, "ipc_mtd_read: warning: bad block at offset %lld\n", (long long int) offs); data_p+=block_size; @@ -298,24 +298,24 @@ void *ipc_file_read(struct ipc_client *client, char *file_name, int size, int bl int fd; int i; - if(file_name == NULL || size <= 0 || block_size <= 0) + if (file_name == NULL || size <= 0 || block_size <= 0) goto error; ipc_client_log(client, "ipc_file_read: reading 0x%x bytes from %s with 0x%x bytes block size\n", size, file_name, block_size); fd=open(file_name, O_RDONLY); - if(fd < 0) + if (fd < 0) goto error; file_p=malloc(size); - if(file_p == NULL) + if (file_p == NULL) goto error; memset(file_p, 0, size); data_p=(uint8_t *) file_p; - for(i=0 ; i < size / block_size ; i++) + for (i=0 ; i < size / block_size ; i++) { read(fd, data_p, block_size); data_p+=block_size; diff --git a/samsung-ipc/rfs.c b/samsung-ipc/rfs.c index 4d24e48..b4804a0 100644 --- a/samsung-ipc/rfs.c +++ b/samsung-ipc/rfs.c @@ -37,10 +37,10 @@ void md5hash2string(char *out, uint8_t *in) { int i; - for(i=0 ; i < MD5_DIGEST_LENGTH ; i++) + for (i=0 ; i < MD5_DIGEST_LENGTH ; i++) { /* After the first iteration, we override \0. */ - if(*in < 0x10) + if (*in < 0x10) sprintf(out, "0%x", *in); else sprintf(out, "%x", *in); @@ -94,7 +94,7 @@ void nv_data_md5_generate(struct ipc_client *client) /* Write the MD5 hash in nv_data.bin.md5. */ fd = open("/efs/nv_data.bin.md5", O_RDWR | O_CREAT | O_TRUNC, 0644); - if(fd < 0) + if (fd < 0) { ipc_client_log(client, "nv_data_md5_generate: fd open failed\n"); goto exit; @@ -127,20 +127,20 @@ void nv_data_backup_create(struct ipc_client *client) ipc_client_log(client, "nv_data_backup_create: enter\n"); - if(stat("/efs/nv_data.bin", &nv_stat) < 0) + if (stat("/efs/nv_data.bin", &nv_stat) < 0) { ipc_client_log(client, "nv_data_backup_create: nv_data.bin missing\n"); nv_data_generate(client); } - if(nv_stat.st_size != NV_DATA_SIZE) + if (nv_stat.st_size != NV_DATA_SIZE) { ipc_client_log(client, "nv_data_backup_create: wrong nv_data.bin size\n"); nv_data_generate(client); return; } - if(stat("/efs/nv_data.bin.md5", &nv_stat) < 0) + if (stat("/efs/nv_data.bin.md5", &nv_stat) < 0) { ipc_client_log(client, "nv_data_backup_create: nv_data.bin.md5 missing\n"); nv_data_generate(client); @@ -172,7 +172,7 @@ void nv_data_backup_create(struct ipc_client *client) ipc_client_log(client, "nv_data_backup_create: backup file computed MD5: %s read MD5: %s\n", nv_data_md5_hash_string, nv_data_md5_hash_read); - if(strcmp(nv_data_md5_hash_string, nv_data_md5_hash_read) != 0) + if (strcmp(nv_data_md5_hash_string, nv_data_md5_hash_read) != 0) { ipc_client_log(client, "nv_data_backup_create: MD5 hash mismatch on backup file\n"); ipc_client_log(client, "nv_data_backup_create: Consider the computed one as correct\n"); @@ -193,12 +193,12 @@ void nv_data_backup_create(struct ipc_client *client) memset(nv_data_md5_hash_string, 0, MD5_STRING_SIZE); nv_data_backup_create_write: - while(nv_data_write_tries < 5) + while (nv_data_write_tries < 5) { ipc_client_log(client, "nv_data_backup_create: .nv_data.bak write try #%d\n", nv_data_write_tries + 1); fd=open("/efs/.nv_data.bak", O_RDWR | O_CREAT | O_TRUNC, 0644); - if(fd < 0) + if (fd < 0) { ipc_client_log(client, "nv_data_backup_create: negative fd while opening /efs/.nv_data.bak, error: %s\n", strerror(errno)); nv_data_write_tries++; @@ -206,7 +206,7 @@ nv_data_backup_create_write: } rc = write(fd, nv_data_p, NV_DATA_SIZE); - if(rc < NV_DATA_SIZE) + if (rc < NV_DATA_SIZE) { ipc_client_log(client, "nv_data_backup_create: wrote less (%d) than what we expected (%d) on /efs/.nv_data.bak, error: %s\n", strerror(errno)); close(fd); @@ -218,7 +218,7 @@ nv_data_backup_create_write: break; } - if(nv_data_write_tries == 5) + if (nv_data_write_tries == 5) { ipc_client_log(client, "nv_data_backup_create: writing nv_data.bin to .nv_data.bak failed too many times\n"); unlink("/efs/.nv_data.bak"); @@ -238,7 +238,7 @@ nv_data_backup_create_write: nv_data_md5_hash_string, nv_data_md5_hash_read); /* Make sure both hashes are the same. */ - if(strcmp(nv_data_md5_hash_string, nv_data_md5_hash_read) != 0) + if (strcmp(nv_data_md5_hash_string, nv_data_md5_hash_read) != 0) { ipc_client_log(client, "nv_data_backup_create: MD5 hash mismatch on written file\n"); ipc_client_log(client, "nv_data_backup_create: Writing again\n"); @@ -283,7 +283,7 @@ void nv_data_backup_restore(struct ipc_client *client) ipc_client_log(client, "nv_data_backup_restore: enter\n"); - if(stat("/efs/.nv_data.bak", &nv_stat) < 0) + if (stat("/efs/.nv_data.bak", &nv_stat) < 0) { ipc_client_log(client, "nv_data_backup_restore: .nv_data.bak missing\n"); nv_data_generate(client); @@ -291,7 +291,7 @@ void nv_data_backup_restore(struct ipc_client *client) return; } - if(nv_stat.st_size != NV_DATA_SIZE) + if (nv_stat.st_size != NV_DATA_SIZE) { ipc_client_log(client, "nv_data_backup_restore: wrong .nv_data.bak size\n"); nv_data_generate(client); @@ -299,7 +299,7 @@ void nv_data_backup_restore(struct ipc_client *client) return; } - if(stat("/efs/.nv_data.bak.md5", &nv_stat) < 0) + if (stat("/efs/.nv_data.bak.md5", &nv_stat) < 0) { ipc_client_log(client, "nv_data_backup_restore: .nv_data.bak.md5 missing\n"); nv_data_generate(client); @@ -332,7 +332,7 @@ void nv_data_backup_restore(struct ipc_client *client) ipc_client_log(client, "nv_data_backup_restore: backup file computed MD5: %s read MD5: %s\n", nv_data_md5_hash_string, nv_data_md5_hash_read); - if(strcmp(nv_data_md5_hash_string, nv_data_md5_hash_read) != 0) + if (strcmp(nv_data_md5_hash_string, nv_data_md5_hash_read) != 0) { ipc_client_log(client, "nv_data_backup_restore: MD5 hash mismatch on backup file\n"); ipc_client_log(client, "nv_data_backup_restore: Consider the computed one as correct\n"); @@ -353,12 +353,12 @@ void nv_data_backup_restore(struct ipc_client *client) memset(nv_data_md5_hash_string, 0, MD5_STRING_SIZE); nv_data_backup_restore_write: - while(nv_data_write_tries < 5) + while (nv_data_write_tries < 5) { ipc_client_log(client, "nv_data_backup_restore: nv_data.bin write try #%d\n", nv_data_write_tries + 1); fd=open("/efs/nv_data.bin", O_RDWR | O_CREAT | O_TRUNC, 0644); - if(fd < 0) + if (fd < 0) { ipc_client_log(client, "nv_data_backup_restore: negative fd while opening /efs/nv_data.bin, error: %s\n", strerror(errno)); nv_data_write_tries++; @@ -366,7 +366,7 @@ nv_data_backup_restore_write: } rc = write(fd, nv_data_bak_p, NV_DATA_SIZE); - if(rc < NV_DATA_SIZE) + if (rc < NV_DATA_SIZE) { ipc_client_log(client, "nv_data_backup_restore: wrote less (%d) than what we expected (%d) on /efs/nv_data.bin, error: %s\n", strerror(errno)); close(fd); @@ -378,7 +378,7 @@ nv_data_backup_restore_write: break; } - if(nv_data_write_tries == 5) + if (nv_data_write_tries == 5) { ipc_client_log(client, "nv_data_backup_restore: writing the backup to nv_data.bin failed too many times\n"); unlink("/efs/nv_data.bin"); @@ -399,7 +399,7 @@ nv_data_backup_restore_write: nv_data_md5_hash_string, nv_data_md5_hash_read); /* Make sure both hashes are the same. */ - if(strcmp(nv_data_md5_hash_string, nv_data_md5_hash_read) != 0) + if (strcmp(nv_data_md5_hash_string, nv_data_md5_hash_read) != 0) { ipc_client_log(client, "nv_data_backup_restore: MD5 hash mismatch on written file\n"); ipc_client_log(client, "nv_data_backup_restore: Writing again\n"); @@ -434,26 +434,26 @@ void nv_data_check(struct ipc_client *client) ipc_client_log(client, "nv_data_check: enter\n"); - if(stat("/efs/nv_data.bin", &nv_stat) < 0) + if (stat("/efs/nv_data.bin", &nv_stat) < 0) { ipc_client_log(client, "nv_data_check: nv_data.bin missing\n"); nv_data_backup_restore(client); stat("/efs/nv_data.bin", &nv_stat); } - if(nv_stat.st_size != NV_DATA_SIZE) + if (nv_stat.st_size != NV_DATA_SIZE) { ipc_client_log(client, "nv_data_check: wrong nv_data.bin size\n"); nv_data_backup_restore(client); } - if(stat("/efs/nv_data.bin.md5", &nv_stat) < 0) + if (stat("/efs/nv_data.bin.md5", &nv_stat) < 0) { ipc_client_log(client, "nv_data_check: nv_data.bin.md5 missing\n"); nv_data_backup_restore(client); } - if(stat("/efs/.nv_data.bak", &nv_stat) < 0 || stat("/efs/.nv_data.bak.md5", &nv_stat) < 0) + if (stat("/efs/.nv_data.bak", &nv_stat) < 0 || stat("/efs/.nv_data.bak.md5", &nv_stat) < 0) { ipc_client_log(client, "nv_data_check: .nv_data.bak or .nv_data.bak.md5 missing\n"); nv_data_backup_create(client); @@ -461,7 +461,7 @@ void nv_data_check(struct ipc_client *client) nv_state_fd=open("/efs/.nv_state", O_RDONLY); - if(nv_state_fd < 0 || fstat(nv_state_fd, &nv_stat) < 0) + if (nv_state_fd < 0 || fstat(nv_state_fd, &nv_stat) < 0) { ipc_client_log(client, "nv_data_check: .nv_state missing\n"); nv_data_backup_restore(client); @@ -471,7 +471,7 @@ void nv_data_check(struct ipc_client *client) close(nv_state_fd); - if(nv_state != '1') + if (nv_state != '1') { ipc_client_log(client, "nv_data_check: bad nv_state\n"); nv_data_backup_restore(client); @@ -520,7 +520,7 @@ void nv_data_md5_check(struct ipc_client *client) ipc_client_log(client, "nv_data_md5_check: computed MD5: %s read MD5: %s\n", nv_data_md5_hash_string, nv_data_md5_hash_read); - if(strcmp(nv_data_md5_hash_string, nv_data_md5_hash_read) != 0) + if (strcmp(nv_data_md5_hash_string, nv_data_md5_hash_read) != 0) { ipc_client_log(client, "nv_data_md5_check: MD5 hash mismatch\n"); nv_data_backup_restore(client); @@ -539,12 +539,12 @@ int nv_data_read(struct ipc_client *client, int offset, int length, char *buf) ipc_client_log(client, "nv_data_read: enter\n"); - if(offset <= 0 || length <= 0) { + if (offset <= 0 || length <= 0) { ipc_client_log(client, "nv_data_read: offset or length <= 0\n"); return -1; } - if(buf == NULL) { + if (buf == NULL) { ipc_client_log(client, "nv_data_read: provided output buf is NULL\n"); return -1; } @@ -553,7 +553,7 @@ int nv_data_read(struct ipc_client *client, int offset, int length, char *buf) fd = open("/efs/nv_data.bin", O_RDONLY); - if(fd < 0) { + if (fd < 0) { ipc_client_log(client, "nv_data_read: nv_data file fd is negative\n"); return -1; } @@ -562,7 +562,7 @@ int nv_data_read(struct ipc_client *client, int offset, int length, char *buf) rc = read(fd, buf, length); - if(rc < length) { + if (rc < length) { ipc_client_log(client, "nv_data_read: read less than what we expected\n"); return -1; } @@ -579,12 +579,12 @@ int nv_data_write(struct ipc_client *client, int offset, int length, char *buf) ipc_client_log(client, "nv_data_write: enter\n"); - if(offset <= 0 || length <= 0) { + if (offset <= 0 || length <= 0) { ipc_client_log(client, "nv_data_write: offset or length <= 0\n"); return -1; } - if(buf == NULL) { + if (buf == NULL) { ipc_client_log(client, "nv_data_write: provided input buf is NULL\n"); return -1; } @@ -593,7 +593,7 @@ int nv_data_write(struct ipc_client *client, int offset, int length, char *buf) fd = open("/efs/nv_data.bin", O_WRONLY); - if(fd < 0) { + if (fd < 0) { ipc_client_log(client, "nv_data_write: nv_data file fd is negative\n"); return -1; } @@ -604,7 +604,7 @@ int nv_data_write(struct ipc_client *client, int offset, int length, char *buf) close(fd); - if(rc < length) { + if (rc < length) { ipc_client_log(client, "nv_data_write: wrote less (%d) than what we expected (%d), error: %s, restoring backup\n", rc, length, strerror(errno)); nv_data_backup_restore(client); return -1; @@ -625,7 +625,7 @@ void ipc_rfs_send_io_confirm_for_nv_read_item(struct ipc_client *client, struct void *rfs_data; int rc; - if(rfs_io == NULL) + if (rfs_io == NULL) { ipc_client_log(client, "ERROR: Request message is invalid: aseq = %i", info->aseq); return NULL; |