Fix build warnings for gcc 9 49/220949/1
authorSemun Lee <semun.lee@samsung.com>
Thu, 26 Dec 2019 04:55:51 +0000 (13:55 +0900)
committerSemun Lee <semun.lee@samsung.com>
Thu, 26 Dec 2019 04:55:51 +0000 (13:55 +0900)
Change-Id: Ibc2b5ba5b6bbf4912428a59667172d12ff4d1a35
Signed-off-by: Semun Lee <semun.lee@samsung.com>
CMakeLists.txt
include/entity/mtp_store.h
include/transport/mtp_descs_strings.h
src/entity/mtp_store.c
src/util/mtp_util.c

index f256ee6..3c916cf 100644 (file)
@@ -23,7 +23,7 @@ FOREACH(flag ${pkgs_CFLAGS})
        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")
index 569fc54..7d298c2 100644 (file)
@@ -96,7 +96,7 @@ mtp_obj_t *_entity_get_object_from_store(mtp_store_t *store, mtp_uint32 handle);
 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,
index 37747ba..26cf650 100644 (file)
@@ -28,8 +28,10 @@ enum functionfs_flags {
 };
 #endif
 
-#define cpu_to_le16(x)  htole16(x)
-#define cpu_to_le32(x)  htole32(x)
+#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))
 #define le32_to_cpu(x)  le32toh(x)
 #define le16_to_cpu(x)  le16toh(x)
 
index d8fc4a8..b778cc7 100644 (file)
@@ -408,7 +408,7 @@ mtp_obj_t *_entity_get_last_object_from_store(mtp_store_t *store,
 }
 
 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;
index c16783a..21f077d 100644 (file)
@@ -348,8 +348,8 @@ static bool _util_device_external_supported_cb(int storage_id, storage_type_e ty
        //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);
        }
 
@@ -367,7 +367,7 @@ void _util_get_external_path(char *external_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;
                }
        }
@@ -461,15 +461,15 @@ void _util_get_internal_path(char *internal_path)
        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;
        }