SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Werror-implicit-function-declaration")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Werror")
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fexceptions -fvisibility=hidden -fprofile-arcs -ftest-coverage")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE")
mtp_obj_t *_entity_get_last_object_from_store(mtp_store_t *store,
mtp_uint32 handle);
mtp_obj_t *_entity_get_object_from_store_by_path(mtp_store_t *store,
- mtp_char *file_path);
+ const mtp_char *file_path);
mtp_uint32 _entity_get_objects_from_store(mtp_store_t *store,
mtp_uint32 obj_handle, mtp_uint32 fmt, ptp_array_t *obj_arr);
mtp_uint32 _entity_get_objects_from_store_till_depth(mtp_store_t *store,
};
#endif
-#define cpu_to_le16(x) htole16(x)
-#define cpu_to_le32(x) htole32(x)
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define cpu_to_le16(x) (x)
+#define cpu_to_le32(x) (x)
+#else
+#define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
+#define cpu_to_le32(x) \
+ ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >> 8) | \
+ (((x) & 0x0000ff00u) << 8) | (((x) & 0x000000ffu) << 24))
+#endif
#define le32_to_cpu(x) le32toh(x)
#define le16_to_cpu(x) le16toh(x)
mtp_uint32 ii;
for (ii = 0; ii < prop_info->supp_value_list.nnodes;
ii++, node = node->link) {
- if (value == (mtp_uint32) node->value)
+ if (value == GPOINTER_TO_UINT(node->value))
return TRUE;
/* LCOV_EXCL_STOP */
}
ii < prop->propinfo.supp_value_list.nnodes;
ii++, node = node->link) {
- value = (mtp_uint32)node->value;
+ value = GPOINTER_TO_UINT(node->value);
memcpy(temp, &value, prop->propinfo.dts_size);
#ifdef __BIG_ENDIAN__
_util_conv_byte_order(temp, prop->propinfo.dts_size);
ii < prop->propinfo.supp_value_list.nnodes;
ii++, node = node->link) {
- value = (mtp_uint32)node->value;
+ value = GPOINTER_TO_UINT(node->value);
memcpy(temp, &value, prop->propinfo.dts_size);
#ifdef __BIG_ENDIAN__
_util_conv_byte_order(temp, prop->propinfo.dts_size);
}
/* Create the node and append it. */
- _util_add_node(&(prop_info->supp_value_list), (void *)value);
+ _util_add_node(&(prop_info->supp_value_list), GUINT_TO_POINTER(value));
return TRUE;
}
}
mtp_obj_t *_entity_get_object_from_store_by_path(mtp_store_t *store,
- mtp_char *file_path)
+ const mtp_char *file_path)
{
mtp_obj_t *obj = NULL;
slist_iterator *iter = NULL;
return;
}
- memcpy(&(cancelreq_data.io_code), buffer, sizeof(mtp_word));
- memcpy(&(cancelreq_data.tid), &buffer[2], sizeof(mtp_dword));
+ memcpy(&(cancelreq_data.io_code), buffer, sizeof(mtp_uint16));
+ memcpy(&(cancelreq_data.tid), &buffer[2], sizeof(mtp_uint32));
DBG("cancel io code [%d], transaction id [%du]\n",
cancelreq_data.io_code, cancelreq_data.tid);
break;
#include <glib/gprintf.h>
#include <unistd.h>
#include <sys/wait.h>
+#include <stdint.h>
#include "mtp_support.h"
#include "ptp_datacodes.h"
#include "mtp_util.h"
ret_if(src == NULL);
ret_if(dest == NULL);
- if (!((int)dest & 0x1) && !((int)src & 0x1)) {
+ if (!((uintptr_t)dest & 0x1) && !((uintptr_t)src & 0x1)) {
/* 2-byte aligned */
mtp_wchar *temp = dest;
ret_if(src == NULL);
ret_if(dest == NULL);
- if (!((int)dest & 0x1) && !((int)src & 0x1)) { /* 2-byte aligned */
+ if (!((uintptr_t)dest & 0x1) && !((uintptr_t)src & 0x1)) { /* 2-byte aligned */
temp = dest;
while (n && (*temp++ = *src++))
*/
size_t _util_wchar_len(const mtp_wchar *s)
{
- if (!((int)s & 0x1)) { /* 2-byte aligned */
+ if (!((uintptr_t)s & 0x1)) { /* 2-byte aligned */
mtp_wchar *temp = (mtp_wchar *)s;
while (*temp++)
//DBG("storage id: %d, path: %s", storage_id, path);
if (type == STORAGE_TYPE_EXTERNAL && path != NULL) {
- strncpy(storage_path, path, strlen(path)+1);
- storage_path[strlen(path)] = 0;
+ strncpy(storage_path, path, MTP_MAX_PATHNAME_SIZE);
+ storage_path[MTP_MAX_PATHNAME_SIZE] = 0;
//DBG("external storage path : %s", storage_path);
}
/* LCOV_EXCL_START */
ERR("get external storage path Fail");
if (external_path != NULL) {
- strncpy(external_path, MTP_EXTERNAL_PATH_CHAR, sizeof(MTP_EXTERNAL_PATH_CHAR));
+ strncpy(external_path, MTP_EXTERNAL_PATH_CHAR, MTP_MAX_PATHNAME_SIZE);
external_path[sizeof(MTP_EXTERNAL_PATH_CHAR) - 1] = 0;
}
}
if (active_name == NULL) {
/* LCOV_EXCL_START */
ERR("active_name is NULL");
- strncpy(internal_path, MTP_USER_DIRECTORY, sizeof(MTP_USER_DIRECTORY));
+ strncpy(internal_path, MTP_USER_DIRECTORY, MTP_MAX_PATHNAME_SIZE);
internal_path[sizeof(MTP_USER_DIRECTORY) - 1] = 0;
return;
/* LCOV_EXCL_STOP */
}
if (internal_path != NULL) {
- strncpy(internal_path, MTP_INTERNAL_PATH_CHAR, sizeof(MTP_INTERNAL_PATH_CHAR));
- strncat(internal_path, active_name, strlen(active_name) + 1);
+ strncpy(internal_path, MTP_INTERNAL_PATH_CHAR, MTP_MAX_PATHNAME_SIZE);
+ strncat(internal_path, active_name, MTP_MAX_PATHNAME_SIZE - sizeof(MTP_INTERNAL_PATH_CHAR));
strncat(internal_path, "/media", 7);
internal_path[strlen(internal_path)] = 0;
}