diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2014-08-02 20:59:34 +0200 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2014-08-02 20:59:34 +0200 |
commit | 7d2ebf43876c1550f7671092589b625324f860bb (patch) | |
tree | cb422a9f36369e33b9a53bcee75ad7dc634a3c84 | |
parent | 056cf387d88ab0a0eab0c097474d62d8c3d09c13 (diff) | |
download | external_libsamsung-ipc-7d2ebf43876c1550f7671092589b625324f860bb.zip external_libsamsung-ipc-7d2ebf43876c1550f7671092589b625324f860bb.tar.gz external_libsamsung-ipc-7d2ebf43876c1550f7671092589b625324f860bb.tar.bz2 |
rfs: Size function for helpers that return data with non-explicit size
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r-- | include/rfs.h | 1 | ||||
-rw-r--r-- | samsung-ipc/rfs.c | 24 |
2 files changed, 20 insertions, 5 deletions
diff --git a/include/rfs.h b/include/rfs.h index daa3f61..024fad9 100644 --- a/include/rfs.h +++ b/include/rfs.h @@ -74,6 +74,7 @@ void *ipc_nv_data_read(struct ipc_client *client, size_t size, unsigned int offset); int ipc_nv_data_write(struct ipc_client *client, const void *data, size_t size, unsigned int offset); +size_t ipc_rfs_nv_data_item_response_size_setup(const void *data, size_t size); void *ipc_rfs_nv_read_item_response_setup(const void *data, size_t size, unsigned int offset); diff --git a/samsung-ipc/rfs.c b/samsung-ipc/rfs.c index 086646c..915dd1d 100644 --- a/samsung-ipc/rfs.c +++ b/samsung-ipc/rfs.c @@ -656,6 +656,18 @@ complete: return rc; } +size_t ipc_rfs_nv_data_item_response_size_setup(const void *data, size_t size) +{ + size_t length; + + if (data == NULL) + size = 0; + + length = sizeof(struct ipc_rfs_nv_read_item_response_header) + size; + + return length; +} + void *ipc_rfs_nv_read_item_response_setup(const void *data, size_t size, unsigned int offset) { @@ -665,14 +677,16 @@ void *ipc_rfs_nv_read_item_response_setup(const void *data, size_t size, unsigned char confirm; unsigned char *p; - if (data != NULL && size > 0) { - length = sizeof(struct ipc_rfs_nv_read_item_response_header) + size; - confirm = 1; - } else { - length = sizeof(struct ipc_rfs_nv_read_item_response_header); + length = ipc_rfs_nv_data_item_response_size_setup(data, size); + if (length == 0) + return NULL; + + if (data == NULL || size == 0) { size = 0; offset = 0; confirm = 0; + } else { + confirm = 1; } buffer = calloc(1, length); |