summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xinclude/mtp_cmd_handler.h2
-rwxr-xr-xinclude/mtp_datatype.h2
-rwxr-xr-xinclude/util/mtp_fs.h14
-rwxr-xr-xsrc/entity/mtp_store.c9
-rwxr-xr-xsrc/mtp_cmd_handler.c60
-rwxr-xr-xsrc/mtp_cmd_handler_util.c19
-rwxr-xr-xsrc/mtp_event_handler.c4
-rwxr-xr-xsrc/transport/mtp_transport.c6
-rwxr-xr-xsrc/util/mtp_fs.c42
9 files changed, 77 insertions, 81 deletions
diff --git a/include/mtp_cmd_handler.h b/include/mtp_cmd_handler.h
index 1fc6992..90559cf 100755
--- a/include/mtp_cmd_handler.h
+++ b/include/mtp_cmd_handler.h
@@ -77,7 +77,7 @@ typedef struct {
mtp_uint32 cmd_size;
mtp_uint32 data_size;
mtp_uint32 data_count;
- mtp_uint32 fhandle; /* for temporary mtp file */
+ FILE* fhandle; /* for temporary mtp file */
mtp_char *filepath;
mtp_uint32 file_size;
mtp_uint32 size_remaining;
diff --git a/include/mtp_datatype.h b/include/mtp_datatype.h
index 07f51f4..4fa9782 100755
--- a/include/mtp_datatype.h
+++ b/include/mtp_datatype.h
@@ -25,8 +25,6 @@
#endif
#ifdef _MTP_USE_OWNTYPES
-#define INVALID_FILE (0)
-
typedef unsigned char mtp_byte;
typedef unsigned char mtp_bool;
typedef unsigned char mtp_uchar;
diff --git a/include/util/mtp_fs.h b/include/util/mtp_fs.h
index 3a88e55..6ce634d 100755
--- a/include/util/mtp_fs.h
+++ b/include/util/mtp_fs.h
@@ -67,13 +67,13 @@ typedef struct {
mtp_uint64 reserved_size;
} fs_info_t;
-mtp_uint32 _util_file_open(const mtp_char *filename, file_mode_t mode,
+FILE* _util_file_open(const mtp_char *filename, file_mode_t mode,
mtp_int32 *error);
-void _util_file_read(mtp_uint32 fhandle, void *bufptr, mtp_uint32 size,
+void _util_file_read(FILE* fhandle, void *bufptr, mtp_uint32 size,
mtp_uint32 *read_count);
-mtp_uint32 _util_file_write(mtp_uint32 fhandle, void *bufptr, mtp_uint32 size);
-mtp_int32 _util_file_close(mtp_uint32 fhandle);
-mtp_bool _util_file_seek(mtp_uint32 fhandle, off_t offset, mtp_int32 whence);
+mtp_uint32 _util_file_write(FILE* fhandle, void *bufptr, mtp_uint32 size);
+mtp_int32 _util_file_close(FILE* fhandle);
+mtp_bool _util_file_seek(FILE* fhandle, off_t offset, mtp_int32 whence);
mtp_bool _util_file_copy(const mtp_char *origpath, const mtp_char *newpath,
mtp_int32 *error);
mtp_bool _util_copy_dir_children_recursive(const mtp_char *origpath,
@@ -89,8 +89,8 @@ mtp_bool _util_ifind_next(char *dir_name, DIR *dirp, dir_entry_t *dir_info);
mtp_bool _util_ifind_first(char *dir_name, DIR **dirp, dir_entry_t *dir_info);
mtp_bool _util_is_file_opened(const mtp_char *fullpath);
mtp_bool _util_get_filesystem_info(mtp_char *storepath, fs_info_t *fs_info);
-void _util_count_num_lines(mtp_uint32 fhandle, mtp_uint32 *num_lines);
-void _util_fill_guid_array(void *guidarray, mtp_uint32 start_index, mtp_uint32 fhandle,
+void _util_count_num_lines(FILE* fhandle, mtp_uint32 *num_lines);
+void _util_fill_guid_array(void *guidarray, mtp_uint32 start_index, FILE* fhandle,
mtp_uint32 size);
void FLOGD(const char *fmt, ...);
diff --git a/src/entity/mtp_store.c b/src/entity/mtp_store.c
index 7b9cba8..c47f9f3 100755
--- a/src/entity/mtp_store.c
+++ b/src/entity/mtp_store.c
@@ -444,7 +444,7 @@ mtp_uint32 _entity_get_objects_from_store(mtp_store_t *store,
if ((fmt == obj->obj_info->obj_fmt) ||
(fmt == PTP_FORMATCODE_ALL) ||
(fmt == PTP_FORMATCODE_NOTUSED)) {
- _prop_append_ele_ptparray(obj_arr, (mtp_uint32)obj);
+ _prop_append_ele_ptparray(obj_arr, obj->obj_handle);
}
}
_util_deinit_list_iterator(iter);
@@ -455,8 +455,6 @@ mtp_uint32 _entity_get_objects_from_store_till_depth(mtp_store_t *store,
mtp_uint32 obj_handle, mtp_uint32 fmt_code, mtp_uint32 depth,
ptp_array_t *obj_arr)
{
- mtp_obj_t *obj = NULL;
-
retv_if(store == NULL, 0);
retv_if(obj_arr == NULL, 0);
@@ -468,10 +466,7 @@ mtp_uint32 _entity_get_objects_from_store_till_depth(mtp_store_t *store,
}
if (PTP_OBJECTHANDLE_ROOT != obj_handle) {
- obj = _entity_get_object_from_store(store, obj_handle);
- if (obj) {
- _prop_append_ele_ptparray(obj_arr, (mtp_uint32)obj);
- }
+ _prop_append_ele_ptparray(obj_arr, obj_handle);
}
if (depth > 0) {
ptp_array_t *child_arr = NULL;
diff --git a/src/mtp_cmd_handler.c b/src/mtp_cmd_handler.c
index 282ac32..d662cd3 100755
--- a/src/mtp_cmd_handler.c
+++ b/src/mtp_cmd_handler.c
@@ -701,7 +701,7 @@ static void __get_object(mtp_handler_t *hdlr)
mtp_uint16 resp = PTP_RESPONSE_OK;
mtp_uint32 packet_len;
mtp_uint32 read_len = 0;
- mtp_uint32 h_file = INVALID_FILE;
+ FILE* h_file = NULL;
mtp_int32 error = 0;
if (_hdlr_get_param_cmd_container(&(hdlr->usb_cmd), 1) ||
@@ -745,7 +745,7 @@ static void __get_object(mtp_handler_t *hdlr)
_device_set_phase(DEVICE_PHASE_DATAIN);
h_file = _util_file_open(path, MTP_FILE_READ, &error);
- if (h_file == INVALID_FILE) {
+ if (h_file == NULL) {
ERR("_util_file_open() Fail");
_device_set_phase(DEVICE_PHASE_NOTREADY);
if (EACCES == error) {
@@ -1183,7 +1183,7 @@ static void __get_device_prop_desc(mtp_handler_t *hdlr)
}
case MTP_PROPERTYCODE_DEVICEICON:
{
- mtp_uint32 h_file;
+ FILE* h_file;
mtp_uint32 bytes_read = 0;
mtp_uint32 file_size = 0;
struct stat buf;
@@ -1197,7 +1197,7 @@ static void __get_device_prop_desc(mtp_handler_t *hdlr)
}
h_file = _util_file_open(MTP_DEVICE_ICON, MTP_FILE_READ, &err);
- if (h_file == INVALID_FILE) {
+ if (h_file == NULL) {
ERR("file handle is not valid");
_cmd_hdlr_send_response_code(hdlr,
PTP_RESPONSE_GEN_ERROR);
@@ -1380,7 +1380,7 @@ static void __get_device_prop_value(mtp_handler_t *hdlr)
case MTP_PROPERTYCODE_DEVICEICON:
{
- mtp_uint32 h_file;
+ FILE *h_file;
mtp_uint32 read_bytes = 0;
mtp_uint32 file_size = 0;
struct stat buf;
@@ -1390,13 +1390,13 @@ static void __get_device_prop_value(mtp_handler_t *hdlr)
mtp_uint32 ii;
h_file = _util_file_open(MTP_DEVICE_ICON, MTP_FILE_READ, &err);
- if (h_file == INVALID_FILE) {
+ if (h_file == NULL) {
ERR("file handle is not valid");
_cmd_hdlr_send_response_code(hdlr,
PTP_RESPONSE_GEN_ERROR);
return;
}
- if (fstat(fileno((FILE *)h_file), &buf) != 0) {
+ if (fstat(fileno(h_file), &buf) != 0) {
_util_file_close(h_file);
_cmd_hdlr_send_response_code(hdlr,
PTP_RESPONSE_GEN_ERROR);
@@ -2022,7 +2022,6 @@ static void __get_object_prop_list(mtp_handler_t *hdlr)
slist_node_t *next_node = NULL;
mtp_uint32 ii = 0;
mtp_uint32 jj = 0;
- mtp_obj_t **ptr_array = NULL;
mtp_obj_t *obj = NULL;
#endif /*MTP_USE_RUNTIME_GETOBJECTPROPVALUE*/
@@ -2085,10 +2084,17 @@ static void __get_object_prop_list(mtp_handler_t *hdlr)
#ifdef MTP_USE_RUNTIME_GETOBJECTPROPVALUE
if (resp == PTP_RESPONSE_OK && obj_arr.array_entry) {
- ptr_array = obj_arr.array_entry;
+ mtp_uint32 *obj_handles = obj_arr.array_entry;
for (ii = 0; ii < obj_arr.num_ele; ii++) {
- obj = ptr_array[ii];
+ mtp_store_t *store = NULL;
+
+ store = _device_get_store_containing_obj(obj_handles[ii]);
+ if (store == NULL) {
+ continue;
+ }
+
+ obj = _entity_get_object_from_store(store, obj_handles[ii]);
if (NULL == obj || obj->propval_list.nnodes == 0) {
continue;
}
@@ -2273,7 +2279,7 @@ static void __report_acquired_content(mtp_handler_t *hdlr)
mtp_uint32 num_bytes = 0;
mtp_uint32 num_lines = 0;
mtp_uint32 rem_modified = 0;
- mtp_uint32 h_file;
+ FILE* h_file;
time_t cur_time;
time_t l_time;
mtp_int32 diff_time;
@@ -2328,7 +2334,7 @@ static void __report_acquired_content(mtp_handler_t *hdlr)
}
h_file = _util_file_open(MTP_FILES_MODIFIED_FILES, MTP_FILE_READ, &err);
- if (h_file == INVALID_FILE) {
+ if (h_file == NULL) {
resp = PTP_RESPONSE_GEN_ERROR;
_prop_init_ptparray(&guid_arr, UINT32_TYPE);
_prop_append_ele_ptparray(&guid_arr, 0);
@@ -3190,10 +3196,10 @@ void _receive_mq_data_cb(mtp_char *buffer, mtp_int32 buf_len)
_transport_set_control_event(0);
_transport_set_mtp_operation_state(MTP_STATE_ONSERVICE);
- if (g_mgr->ftemp_st.fhandle != INVALID_FILE) {
+ if (g_mgr->ftemp_st.fhandle != NULL) {
DBG("In Cancel Transaction fclose ");
_util_file_close(g_mgr->ftemp_st.fhandle);
- g_mgr->ftemp_st.fhandle = INVALID_FILE;
+ g_mgr->ftemp_st.fhandle = NULL;
DBG("In Cancel Transaction, remove ");
if (remove(g_mgr->ftemp_st.filepath) < 0) {
ERR_SECURE("remove(%s) Fail", g_mgr->ftemp_st.filepath);
@@ -3259,16 +3265,15 @@ static mtp_bool __receive_temp_file_first_packet(mtp_char *data,
mtp_int32 data_len)
{
mtp_char *filepath = g_mgr->ftemp_st.filepath;
- mtp_uint32 *fhandle = &g_mgr->ftemp_st.fhandle;
mtp_int32 error = 0;
mtp_uint32 *data_sz = &g_mgr->ftemp_st.data_size;
mtp_char *buffer = g_mgr->ftemp_st.temp_buff;
_transport_set_mtp_operation_state(MTP_STATE_DATA_TRANSFER_DL);
if (access(filepath, F_OK) == 0) {
- if (*fhandle != INVALID_FILE) {
- _util_file_close(*fhandle);
- *fhandle = INVALID_FILE; /* initialize */
+ if (g_mgr->ftemp_st.fhandle != NULL) {
+ _util_file_close(g_mgr->ftemp_st.fhandle);
+ g_mgr->ftemp_st.fhandle = NULL; /* initialize */
}
if (remove(filepath) < 0) {
@@ -3278,8 +3283,8 @@ static mtp_bool __receive_temp_file_first_packet(mtp_char *data,
}
}
- *fhandle = _util_file_open(filepath, MTP_FILE_WRITE, &error);
- if (*fhandle == INVALID_FILE) {
+ g_mgr->ftemp_st.fhandle = _util_file_open(filepath, MTP_FILE_WRITE, &error);
+ if (g_mgr->ftemp_st.fhandle == NULL) {
ERR("First file handle is invalid!!");
__finish_receiving_file_packets(data, data_len);
return FALSE;
@@ -3293,14 +3298,14 @@ static mtp_bool __receive_temp_file_first_packet(mtp_char *data,
/* check whether last data packet */
if (*data_sz == g_mgr->ftemp_st.file_size) {
- if (_util_file_write(*fhandle, &data[sizeof(header_container_t)],
+ if (_util_file_write(g_mgr->ftemp_st.fhandle, &data[sizeof(header_container_t)],
data_len - sizeof(header_container_t)) !=
data_len - sizeof(header_container_t)) {
ERR("fwrite error!");
}
*data_sz = 0;
- _util_file_close(*fhandle);
- *fhandle = INVALID_FILE; /* initialize */
+ _util_file_close(g_mgr->ftemp_st.fhandle);
+ g_mgr->ftemp_st.fhandle = NULL; /* initialize */
__finish_receiving_file_packets(data, data_len);
} else {
g_mgr->ftemp_st.data_count++;
@@ -3317,14 +3322,13 @@ static mtp_bool __receive_temp_file_next_packets(mtp_char *data,
mtp_uint32 rx_size = _get_rx_pkt_size();
mtp_uint32 *data_sz = &g_mgr->ftemp_st.data_size;
mtp_char *buffer = g_mgr->ftemp_st.temp_buff;
- mtp_uint32 *fhandle = &g_mgr->ftemp_st.fhandle;
g_mgr->ftemp_st.data_count++;
g_mgr->ftemp_st.size_remaining += data_len;
if ((*data_sz + (mtp_uint32)data_len) > g_conf.write_file_size) {
/* copy oversized packet to temp file */
- if (_util_file_write(*fhandle, buffer, *data_sz) != *data_sz)
+ if (_util_file_write(g_mgr->ftemp_st.fhandle, buffer, *data_sz) != *data_sz)
ERR("fwrite error writeSize=[%u]\n", *data_sz);
*data_sz = 0;
@@ -3337,12 +3341,12 @@ static mtp_bool __receive_temp_file_next_packets(mtp_char *data,
if (data_len < rx_size ||
g_mgr->ftemp_st.size_remaining == g_mgr->ftemp_st.file_size) {
- if (_util_file_write(*fhandle, buffer, *data_sz) != *data_sz) {
+ if (_util_file_write(g_mgr->ftemp_st.fhandle, buffer, *data_sz) != *data_sz) {
ERR("fwrite error write size=[%u]\n", *data_sz);
}
*data_sz = 0;
- _util_file_close(*fhandle);
- *fhandle = INVALID_FILE; /* initialize */
+ _util_file_close(g_mgr->ftemp_st.fhandle);
+ g_mgr->ftemp_st.fhandle = NULL;
__finish_receiving_file_packets(data, data_len);
}
return TRUE;
diff --git a/src/mtp_cmd_handler_util.c b/src/mtp_cmd_handler_util.c
index c802fcf..5c84171 100755
--- a/src/mtp_cmd_handler_util.c
+++ b/src/mtp_cmd_handler_util.c
@@ -444,10 +444,10 @@ mtp_err_t _hutil_add_object_entry(obj_info_t *obj_info, mtp_char *file_name,
obj_info->association_type !=
PTP_ASSOCIATIONTYPE_FOLDER) ||
is_made_by_mtp) {
- mtp_uint32 h_abs_file = INVALID_FILE;
+ FILE* h_abs_file = NULL;
h_abs_file = _util_file_open(new_f_path,
MTP_FILE_WRITE, &error);
- if (h_abs_file == INVALID_FILE) {
+ if (h_abs_file == NULL) {
ERR("create file fail!!");
_entity_dealloc_mtp_obj(obj);
return MTP_ERROR_GENERAL;
@@ -1124,7 +1124,7 @@ mtp_err_t _hutil_read_file_data_from_offset(mtp_uint32 obj_handle, off_t offset,
void *data, mtp_uint32 *data_sz)
{
mtp_obj_t *obj = NULL;
- mtp_uint32 h_file = INVALID_FILE;
+ FILE* h_file = NULL;
mtp_int32 error = 0;
mtp_char fname[MTP_MAX_PATHNAME_SIZE + 1];
off_t result = 0;
@@ -1145,7 +1145,7 @@ mtp_err_t _hutil_read_file_data_from_offset(mtp_uint32 obj_handle, off_t offset,
g_strlcpy(fname, obj->file_path, MTP_MAX_PATHNAME_SIZE + 1);
h_file = _util_file_open(fname, MTP_FILE_READ, &error);
- if (h_file == INVALID_FILE) {
+ if (h_file == NULL) {
ERR("file open Fail[%s]\n", fname);
return MTP_ERROR_GENERAL;
}
@@ -1571,7 +1571,7 @@ mtp_err_t _hutil_construct_object_entry_prop_list(mtp_uint32 store_id,
mtp_char alb_extn[MTP_MAX_EXTENSION_LENGTH + 1] = { 0 };
mtp_char *alb_buf = NULL;
mtp_uint32 alb_sz = 0;
- mtp_uint32 h_temp = INVALID_FILE;
+ FILE* h_temp = NULL;
mtp_int32 error = 0;
#endif /*MTP_SUPPORT_ALBUM_ART*/
mtp_char file_name[MTP_MAX_FILENAME_SIZE + 1] = { 0 };
@@ -1887,7 +1887,7 @@ mtp_err_t _hutil_construct_object_entry_prop_list(mtp_uint32 store_id,
/* file write */
h_temp = _util_file_open(full_path,
MTP_FILE_WRITE, &error);
- if (h_temp != INVALID_FILE) {
+ if (h_temp != NULL) {
_util_file_write(h_temp, alb_buf,
sizeof(mtp_uchar) *alb_sz);
_util_file_close(h_temp);
@@ -2150,7 +2150,7 @@ mtp_err_t _hutil_get_object_prop_list(mtp_uint32 obj_handle, mtp_uint32 format,
}
_util_init_list(&(prop_list->prop_quad_list));
- _prop_init_ptparray(obj_arr, PTR_TYPE);
+ _prop_init_ptparray(obj_arr, UINT32_TYPE);
if (store != NULL) {
_entity_get_objects_from_store_till_depth(store, obj_handle,
@@ -2164,11 +2164,10 @@ mtp_err_t _hutil_get_object_prop_list(mtp_uint32 obj_handle, mtp_uint32 format,
}
if (obj_arr->num_ele != 0) {
- mtp_obj_t **ptr_obj;
- ptr_obj = obj_arr->array_entry;
+ mtp_uint32 *obj_handles = obj_arr->array_entry;
for (i = 0; i < obj_arr->num_ele; i++) {
- obj = ptr_obj[i];
+ obj = _entity_get_object_from_store(store, obj_handles[i]);
if (!obj)
continue;
diff --git a/src/mtp_event_handler.c b/src/mtp_event_handler.c
index ccab66a..14b6aa4 100755
--- a/src/mtp_event_handler.c
+++ b/src/mtp_event_handler.c
@@ -168,10 +168,10 @@ mtp_bool _eh_handle_usb_events(mtp_uint32 type)
DBG("USB disconnected but temp file is remaind.\
It will be deleted.");
- if (g_mgr->ftemp_st.fhandle != INVALID_FILE) {
+ if (g_mgr->ftemp_st.fhandle != NULL) {
DBG("handle is found. At first close file");
_util_file_close(g_mgr->ftemp_st.fhandle);
- g_mgr->ftemp_st.fhandle = INVALID_FILE;
+ g_mgr->ftemp_st.fhandle = NULL;
}
if (remove(g_mgr->ftemp_st.filepath) < 0) {
ERR_SECURE("remove(%s) Fail", g_mgr->ftemp_st.filepath);
diff --git a/src/transport/mtp_transport.c b/src/transport/mtp_transport.c
index 2e382c3..be5cdcd 100755
--- a/src/transport/mtp_transport.c
+++ b/src/transport/mtp_transport.c
@@ -66,14 +66,14 @@ void _transport_save_cmd_buffer(mtp_char *buffer, mtp_uint32 size)
mtp_err_t _transport_rcv_temp_file_data(mtp_byte *buffer, mtp_uint32 size,
mtp_uint32 *count)
{
- mtp_uint32 h_file = INVALID_FILE;
+ FILE* h_file = NULL;
mtp_int32 error = 0;
mtp_uint32 data_sz;
h_file = _util_file_open(g_mgr->ftemp_st.filepath,
MTP_FILE_READ, &error);
- if (h_file == INVALID_FILE) {
+ if (h_file == NULL) {
DBG_SECURE("_util_file_open(%s) Fail", g_mgr->ftemp_st.filepath);
return MTP_ERROR_NONE;
}
@@ -133,7 +133,7 @@ mtp_err_t _transport_rcv_temp_file_info(mtp_byte *buf, char *filepath,
g_strlcpy(g_mgr->ftemp_st.filepath, MTP_TEMP_FILE_DEFAULT,
MTP_MAX_PATHNAME_SIZE + 1);
- g_mgr->ftemp_st.fhandle = INVALID_FILE;
+ g_mgr->ftemp_st.fhandle = NULL;
g_mgr->ftemp_st.file_size = 0;
return MTP_ERROR_NONE;
diff --git a/src/util/mtp_fs.c b/src/util/mtp_fs.c
index ba9e3b2..ce1ead5 100755
--- a/src/util/mtp_fs.c
+++ b/src/util/mtp_fs.c
@@ -46,7 +46,7 @@
* @return This function returns the file handle on success,
or INVALID_FILE on failure
*/
-mtp_uint32 _util_file_open(const mtp_char *filename, file_mode_t mode,
+FILE* _util_file_open(const mtp_char *filename, file_mode_t mode,
mtp_int32 *error)
{
#ifdef __USE_STDIO__
@@ -77,7 +77,7 @@ mtp_uint32 _util_file_open(const mtp_char *filename, file_mode_t mode,
default:
ERR("Invalid mode : %d\n", mode);
*error = EINVAL;
- return INVALID_FILE;
+ return NULL;
}
fhandle = fopen(filename, fmode);
@@ -85,12 +85,12 @@ mtp_uint32 _util_file_open(const mtp_char *filename, file_mode_t mode,
ERR("File open Fail:mode[0x%x], errno [%d]\n", mode, errno);
ERR_SECURE("filename[%s]\n", filename);
*error = errno;
- return INVALID_FILE;
+ return NULL;
}
fcntl(fileno(fhandle), F_SETFL, O_NOATIME);
- return (mtp_uint32)fhandle;
+ return fhandle;
#else /* __USE_STDIO__ */
@@ -125,7 +125,7 @@ mtp_uint32 _util_file_open(const mtp_char *filename, file_mode_t mode,
default:
ERR("Invalid mode : %d\n", mode);
*error = EINVAL;
- return INVALID_FILE;
+ return NULL;
}
if (perm)
@@ -137,10 +137,10 @@ mtp_uint32 _util_file_open(const mtp_char *filename, file_mode_t mode,
ERR("File open Fail:mode[0x%x], errno [%d]\n", mode, errno);
ERR_SECURE("filename[%s]\n", filename);
*error = errno;
- return INVALID_FILE;
+ return NULL;
}
- return (mtp_uint32)fhandle;
+ return fhandle;
#endif /* __USE_STDIO__ */
}
@@ -156,13 +156,13 @@ mtp_uint32 _util_file_open(const mtp_char *filename, file_mode_t mode,
* @param[out] preadcount Will store the actual num bytes read.
* @return None
*/
-void _util_file_read(mtp_uint32 fhandle, void *bufptr, mtp_uint32 size,
+void _util_file_read(FILE* fhandle, void *bufptr, mtp_uint32 size,
mtp_uint32 *read_count)
{
mtp_uint32 bytes_read = 0;
#ifdef __USE_STDIO__
- bytes_read = fread_unlocked(bufptr, sizeof(mtp_char), size, (FILE *)fhandle);
+ bytes_read = fread_unlocked(bufptr, sizeof(mtp_char), size, fhandle);
#else /* __USE_STDIO__ */
bytes_read = read(fhandle, bufptr, size);
#endif /* __USE_STDIO__ */
@@ -180,12 +180,12 @@ void _util_file_read(mtp_uint32 fhandle, void *bufptr, mtp_uint32 size,
* @return This function returns num bytes written.
*/
-mtp_uint32 _util_file_write(mtp_uint32 fhandle, void *bufptr, mtp_uint32 size)
+mtp_uint32 _util_file_write(FILE* fhandle, void *bufptr, mtp_uint32 size)
{
mtp_uint32 bytes_written = 0;
#ifdef __USE_STDIO__
- bytes_written = fwrite_unlocked(bufptr, sizeof(mtp_char), size, (FILE *)fhandle);
+ bytes_written = fwrite_unlocked(bufptr, sizeof(mtp_char), size, fhandle);
#else /* __USE_STDIO__ */
mtp_int32 ret = 0;
@@ -206,10 +206,10 @@ mtp_uint32 _util_file_write(mtp_uint32 fhandle, void *bufptr, mtp_uint32 size)
* @param[in] handle Specifies the handle of file to close.
* @return 0 in case of success or EOF on failure.
*/
-mtp_int32 _util_file_close(mtp_uint32 fhandle)
+mtp_int32 _util_file_close(FILE* fhandle)
{
#ifdef __USE_STDIO__
- return fclose((FILE *)fhandle);
+ return fclose(fhandle);
#else /* __USE_STDIO__ */
return close(fhandle);
#endif /* __USE_STDIO__ */
@@ -223,12 +223,12 @@ mtp_int32 _util_file_close(mtp_uint32 fhandle)
* @param[in] whence Specifies the setting value
* @return Returns TRUE in case of success or FALSE on Failure.
*/
-mtp_bool _util_file_seek(mtp_uint32 handle, off_t offset, mtp_int32 whence)
+mtp_bool _util_file_seek(FILE* handle, off_t offset, mtp_int32 whence)
{
mtp_int64 ret_val = 0;
#ifdef __USE_STDIO__
- ret_val = fseek((FILE *)handle, offset, whence);
+ ret_val = fseek(handle, offset, whence);
#else /* __USE_STDIO__ */
ret_val = lseek(handle, offset, whence);
if (ret_val > 0)
@@ -779,9 +779,9 @@ mtp_bool _util_get_filesystem_info(mtp_char *storepath, fs_info_t *fs_info)
return TRUE;
}
-void _util_count_num_lines(mtp_uint32 fhandle, mtp_uint32 *num_lines)
+void _util_count_num_lines(FILE* fhandle, mtp_uint32 *num_lines)
{
- if (fhandle == INVALID_FILE)
+ if (fhandle == NULL)
return;
mtp_uint32 line_count = 0;
@@ -798,7 +798,7 @@ void _util_count_num_lines(mtp_uint32 fhandle, mtp_uint32 *num_lines)
#ifdef __USE_STDIO__
while((read_bytes = getline(&buffer,
- &line_max_length, (FILE *)fhandle)) != -1) {
+ (size_t *)&line_max_length, fhandle)) != -1) {
if (read_bytes > MTP_MAX_PATHNAME_SIZE + 1)
continue;
line_count++;
@@ -833,7 +833,7 @@ void _util_count_num_lines(mtp_uint32 fhandle, mtp_uint32 *num_lines)
}
void _util_fill_guid_array(void *guidarray, mtp_uint32 start_index,
- mtp_uint32 fhandle, mtp_uint32 size)
+ FILE* fhandle, mtp_uint32 size)
{
ptp_array_t *pguidarray = NULL;
mtp_uint32 *guidptr = NULL;
@@ -855,7 +855,7 @@ void _util_fill_guid_array(void *guidarray, mtp_uint32 start_index,
}
#ifdef __USE_STDIO__
- while ((len = getline(&buffer, &line_max_length, (FILE *)fhandle)) != -1 &&
+ while ((len = getline(&buffer, (size_t *)&line_max_length, fhandle)) != -1 &&
(num_lines - start_index) <= size) {
if (len > MTP_MAX_PATHNAME_SIZE + 1)
continue;
@@ -877,7 +877,7 @@ void _util_fill_guid_array(void *guidarray, mtp_uint32 start_index,
mtp_char file_name[MTP_MAX_PATHNAME_SIZE + 1];
mtp_int32 read_bytes;
- while ((read_bytes = read(fHandle, buffer,
+ while ((read_bytes = read(fhandle, buffer,
LINUX_MAX_PATHNAME_LENGTH)) > 0 &&
(num_lines - start_index) <= size) {