#define DEBUG_ERROR(frmt, args...) \
do { SLOG(LOG_ERROR,FONT_SERVICE_TAG, "[font_service] %s: "frmt"\n",\
__func__, ##args);} while (0)
+#define DEBUG_ERROR_ERRNO(frmt, args...) \
+ do { \
+ char error_string[255] = { 0 }; \
+ strerror_r(errno, error_string, sizeof(error_string)); \
+ SLOG(LOG_ERROR,FONT_SERVICE_TAG, "[font_service] %s: "frmt": %s\n",\
+ __func__, ##args, error_string);} while (0)
static const char *PARENT_PATH = "/opt/share/fonts";
static const char *DOWNLOAD_PATH = "/opt/share/fonts/download";
if ((in = fopen(srcpath, "rb")) == NULL)
{
- DEBUG_ERROR("copyfile is failed. The srcpath[%s] is not opened with read permission. fopen(): %s\n", srcpath, strerror(errno));
+ DEBUG_ERROR_ERRNO("copyfile is failed. The srcpath[%s] is not opened with read permission. fopen()", srcpath);
goto FAIL;
}
if ((out = fopen(destpath, "wb")) == NULL)
{
- DEBUG_ERROR("copyfile is failed. The destpath[%s] is not opened with write permission. fopen(): %s\n", destpath, strerror(errno));
+ DEBUG_ERROR_ERRNO("copyfile is failed. The destpath[%s] is not opened with write permission. fopen()", destpath);
goto FAIL;
}
if ((buf = (char *) malloc(COPY_BUF_SIZE)) == NULL)
{
- DEBUG_ERROR("copyfile is failed. Memory allocation for copy buffer is failed. Request size [%d]. malloc(): %s\n", COPY_BUF_SIZE, strerror(errno));
+ DEBUG_ERROR_ERRNO("copyfile is failed. Memory allocation for copy buffer is failed. Request size [%d]. malloc()", COPY_BUF_SIZE);
goto FAIL;
}
{
/* Reads "len" string. But, it fails to write file.
We need to remove wrong result. */
- DEBUG_ERROR("copyfile is failed. fwrite fails to write. fwrite(): %s\n", strerror(errno));
+ DEBUG_ERROR_ERRNO("copyfile is failed. fwrite fails to write. fwrite()");
fclose(out);
out = NULL;
if (remove(destpath) == -1)
- DEBUG_ERROR("removing copied file with error is failed. remove(): %s\n", strerror(errno));
+ DEBUG_ERROR_ERRNO("removing copied file with error is failed. remove()");
goto FAIL;
}
}
if (remove(srcdir) == -1)
- DEBUG_ERROR("removing src file[%s] is failed. remove(): %s\n", srcdir, strerror(errno));
+ DEBUG_ERROR_ERRNO("removing src file[%s] is failed. remove()", srcdir);
}
}
if (access(deletedir, F_OK) == -1)
{
- DEBUG_ERROR("dest directory(%s) is not exist: %s\n", deletedir, strerror(errno));
+ DEBUG_ERROR_ERRNO("dest directory(%s) is not exist", deletedir);
goto FAIL;
}
ret = make_dir(PARENT_PATH);
if (ret < 0)
{
- DEBUG_ERROR("make current directory(%s) is failed: %s\n", PARENT_PATH, strerror(errno));
+ DEBUG_ERROR_ERRNO("make current directory(%s) is failed", PARENT_PATH);
goto FAIL;
}
ret = make_dir(dest_path);
if (ret < 0)
{
- DEBUG_ERROR("make current directory(%s) is failed: %s\n", dest_path, strerror(errno));
+ DEBUG_ERROR_ERRNO("make current directory(%s) is failed", dest_path);
goto FAIL;
}
if (access(deletedir, F_OK) == -1)
{
- DEBUG_ERROR("dest directory(%s) is not exist: %s\n", deletedir, strerror(errno));
+ DEBUG_ERROR_ERRNO("dest directory(%s) is not exist", deletedir);
goto FAIL;
}