1 Star 0 Fork 17

zhangtao2020/nvml

forked from src-openEuler/nvml 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
fix-build-error.patch 4.07 KB
一键复制 编辑 原始数据 按行查看 历史
jackie_wu 提交于 2020-07-28 10:41 . fix build error
diff --git a/pmdk-1.4.2/src/examples/libpmemobj/array/array.c b/pmdk-1.4.2-edit/src/examples/libpmemobj/array/array.c
index 993ada2..68c422a 100644
--- a/src/examples/libpmemobj/array/array.c
+++ b/src/examples/libpmemobj/array/array.c
@@ -471,7 +471,7 @@ do_alloc(int argc, char *argv[])
POBJ_FREE(&array_info);
POBJ_ZNEW(pop, &array_info, struct array_info);
struct array_info *info = D_RW(array_info);
- strncpy(info->name, argv[0], MAX_BUFFLEN);
+ strncpy(info->name, argv[0], MAX_BUFFLEN - 1);
info->name[MAX_BUFFLEN - 1] = '\0';
info->size = size;
info->type = type;
diff --git a/pmdk-1.4.2/src/test/blk_rw/blk_rw.c b/pmdk-1.4.2-edit/src/test/blk_rw/blk_rw.c
index 484c442..cb0cf43 100644
--- a/src/test/blk_rw/blk_rw.c
+++ b/src/test/blk_rw/blk_rw.c
@@ -92,7 +92,7 @@ main(int argc, char *argv[])
const char *path = argv[2];
- PMEMblkpool *handle;
+ PMEMblkpool *handle = NULL;
switch (*argv[3]) {
case 'c':
handle = pmemblk_create(path, Bsize, 0,
diff --git a/pmdk-1.4.2/src/test/obj_realloc/obj_realloc.c b/pmdk-1.4.2-edit/src/test/obj_realloc/obj_realloc.c
index 0264f12..3b12619 100644
--- a/src/test/obj_realloc/obj_realloc.c
+++ b/src/test/obj_realloc/obj_realloc.c
@@ -139,8 +139,8 @@ test_realloc(PMEMobjpool *pop, size_t size_from, size_t size_to,
UT_ASSERT(usable_size_from >= size_from);
- size_t check_size;
- uint16_t checksum;
+ size_t check_size = 0;
+ uint16_t checksum = 0;
if (zrealloc) {
UT_ASSERT(util_is_zeroed(D_RO(D_RO(root)->obj),
diff --git a/pmdk-1.4.2/src/test/rpmemd_db/rpmemd_db_test.c b/pmdk-1.4.2-edit/src/test/rpmemd_db/rpmemd_db_test.c
index 8e40a85..6535436 100644
--- a/src/test/rpmemd_db/rpmemd_db_test.c
+++ b/src/test/rpmemd_db/rpmemd_db_test.c
@@ -585,7 +585,7 @@ test_remove(const char *root_dir, const char *pool_desc)
struct rpmemd_db *db;
int ret;
char path[PATH_MAX];
- snprintf(path, PATH_MAX, "%s/%s", root_dir, pool_desc);
+ SNPRINTF(path, PATH_MAX, "%s/%s", root_dir, pool_desc);
fill_rand(&attr, sizeof(attr));
strncpy((char *)attr.poolset_uuid, "TEST", sizeof(attr.poolset_uuid));
diff --git a/pmdk-1.4.2/src/test/unittest/unittest.h b/pmdk-1.4.2-edit/src/test/unittest/unittest.h
index 6acc627..75abf2e 100644
--- a/src/test/unittest/unittest.h
+++ b/src/test/unittest/unittest.h
@@ -131,6 +131,13 @@ int ut_get_uuid_str(char *);
/* XXX - fix this temp hack dup'ing util_strerror when we get mock for win */
void ut_strerror(int errnum, char *buff, size_t bufflen);
+int ut_snprintf(const char *file, int line, const char *func,
+ char *str, size_t size, const char *format, ...);
+
+#define SNPRINTF(str, size, format, ...) \
+ ut_snprintf(__FILE__, __LINE__, __func__, \
+ str, size, format, __VA_ARGS__)
+
/* XXX - eliminate duplicated definitions in unittest.h and util.h */
#ifdef _WIN32
static inline int ut_util_statW(const wchar_t *path,
diff --git a/pmdk-1.4.2/src/test/unittest/Makefile b/pmdk-1.4.2-edit/src/test/unittest/Makefile
index a8a17da..96ae2d4 100644
--- a/src/test/unittest/Makefile
+++ b/src/test/unittest/Makefile
@@ -42,7 +42,7 @@ vpath %.h $(TOP)/src/common
TARGET = libut.a
OBJS = ut.o ut_alloc.o ut_file.o ut_pthread.o ut_signal.o ut_backtrace.o\
- os_posix.o os_thread_posix.o
+ os_posix.o os_thread_posix.o
CFLAGS = -I$(TOP)/src/include
CFLAGS += -I$(TOP)/src/common
CFLAGS += $(OS_INCS)
diff --git a/pmdk-1.4.2/src/test/unittest/ut.c b/pmdk-1.4.2-edit/src/test/unittest/ut.c
index 95fcd8f..9bb57e4 100644
--- a/src/test/unittest/ut.c
+++ b/src/test/unittest/ut.c
@@ -1003,3 +1003,24 @@ ut_toUTF16(const char *wstr)
return str;
}
#endif
+
+int
+ut_snprintf(const char *file, int line, const char *func,
+ char *str, size_t size, const char *format, ...)
+ {
+ va_list ap;
+ va_start(ap, format);
+ int ret = vsnprintf(str, size, format, ap);
+ va_end(ap);
+
+ if (ret < 0) {
+ if (!errno)
+ errno = EIO;
+ ut_fatal(file, line, func, "!snprintf");
+ } else if ((size_t)ret >= size) {
+ errno = ENOBUFS;
+ ut_fatal(file, line, func, "!snprintf");
+ }
+
+ return ret;
+ }
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangtao2020/nvml.git
git@gitee.com:zhangtao2020/nvml.git
zhangtao2020
nvml
nvml
master

搜索帮助