tzip: fix type size mismatching issue 94/55694/1
authorTaeyoung Kim <ty317.kim@samsung.com>
Tue, 29 Dec 2015 00:31:24 +0000 (09:31 +0900)
committerTaeyoung Kim <ty317.kim@samsung.com>
Tue, 29 Dec 2015 00:31:24 +0000 (09:31 +0900)
- Size of pointer in 32bit arch is 4byte, but size of uint64_t is 8byte.
  This occurs the size mismatching issue.
- The issue is fixed by checking type of architecture

Change-Id: If696b7465df81ba401458b94b8559b8521458f84
Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
CMakeLists.txt
packaging/deviced.spec
src/tzip/tzip-utility.c
src/tzip/tzip.c

index 7138627..57216be 100755 (executable)
@@ -10,6 +10,12 @@ ELSEIF("${ARCH}" STREQUAL "arm")
        OPTION(USE_ARM "Use Arm" ON)
 ENDIF()
 
+IF("${ARCH_BIT}" STREQUAL "32")
+       OPTION(USE_32BIT "Use 32bit architecture" ON)
+ELSEIF("${ARCH_BIT}" STREQUAL "64")
+       OPTION(USE_64BIT "Use 64bit architecture" ON)
+ENDIF()
+
 ########################################################
 # Deviced Macros
 ########################################################
@@ -199,6 +205,11 @@ IF(USE_ARM)
 ELSEIF(USE_EMULATOR)
        ADD_DEFINITIONS("-DEMULATOR")
 ENDIF()
+IF(USE_32BIT)
+       ADD_DEFINITIONS("-DARCH_32BIT")
+ELSEIF(USE_64BIT)
+       ADD_DEFINITIONS("-DARCH_64BIT")
+ENDIF()
 ADD_DEFINITIONS("-DDEBUG")
 
 ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
index efd2b0c..c5d94ea 100644 (file)
@@ -225,9 +225,19 @@ Haptic Device manager library for device control (devel)
 %prep
 %setup -q
 %if %{with emulator}
-%define ARCH emulator
+       %define ARCH emulator
 %else
-%define ARCH arm
+       %ifarch %{arm} aarch64
+               %define ARCH arm
+       %else
+               %define ARCH x86
+       %endif
+%endif
+
+%ifarch %{arm} %ix86
+       %define ARCH_BIT 32
+%else
+       %define ARCH_BIT 64
 %endif
 
 %define DPMS none
@@ -242,6 +252,7 @@ Haptic Device manager library for device control (devel)
        -DTZ_SYS_ETC=%TZ_SYS_ETC \
        -DCMAKE_INSTALL_PREFIX=%{_prefix} \
        -DARCH=%{ARCH} \
+       -DARCH_BIT=%{ARCH_BIT} \
        -DDPMS=%{DPMS} \
        -DPROFILE=%{profile} \
        -DBATTERY_MODULE=%{battery_module} \
index 79939fd..0728551 100644 (file)
@@ -23,6 +23,7 @@
 #include <unzip.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 #include <unistd.h>
 #include <semaphore.h>
 #include <errno.h>
index d1fdc61..4f5ba43 100644 (file)
@@ -208,7 +208,12 @@ static int tzip_open(const char *path, struct fuse_file_info *fi)
        handle->path = zippath;
        handle->file = file;
 
+#ifdef ARCH_32BIT
+       int hd = (int)handle;
+       fi->fh = (uint64_t)hd;
+#else
        fi->fh = (uint64_t)handle;
+#endif
        return 0;
 
 out_unlock:
@@ -236,7 +241,13 @@ static int tzip_read(const char *path, char *buf, size_t size, off_t offset,
                _E("Invalid Zip Handle ");
                return -EINVAL;
        }
+
+#ifdef ARCH_32BIT
+       int hd = (int)fi->fh;
+       handle = (struct tzip_handle *)hd;
+#else
        handle = (struct tzip_handle *)(fi->fh);
+#endif
 
        _D("Read - Path : %s  size : %zd offset : %jd ", path, size, offset);
        ret = read_zipfile(handle, buf, size, offset);
@@ -256,7 +267,13 @@ static int tzip_release(const char *path, struct fuse_file_info *fi)
                _E("Invalid Zip Handle ");
                return -EINVAL;
        }
+
+#ifdef ARCH_32BIT
+       int hd = (int)fi->fh;
+       handle = (struct tzip_handle *)hd;
+#else
        handle = (struct tzip_handle *)(fi->fh);
+#endif
 
        unzCloseCurrentFile(handle->zipfile);
        unzClose(handle->zipfile);