Spdk/test/unit/lib
GangCao 10f32b9f19 lib/blob: do not assume realloc(NULL, 0) returns a not-NULL value
There is situation that num_extent_pages is zero and original pointer is
also NULL, the realloc() could return a Not NULL pointer.

Related UT has been added and updated.
1) In the default allocation (num_clusters == 0), the extent_pages is not allocated as expected.
2) In the thin provisioning allocation (num_clusters != 0), the extent_pages will be allocated if extent_table is used.

More related information as below:

The crux of the problem is that according to POSIX:

realloc: "If ptr is NULL, then the call is equivalent to malloc(size)"
malloc: "If size is 0, then malloc returns either NULL or a unique pointer value that can later be successfully passed to free"

blobstore was relying on realloc(NULL, 0) always return a unique pointer value, and not NULL.  This is not portable behavior.

Change-Id: Ibc28d9696f15a3c0e2aa6bb2371dc23576c28954
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10470
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
2021-12-20 18:14:06 +00:00
..
accel lib/accel: remove batching from the framework and plug-in modules 2021-12-08 16:35:40 +00:00
bdev bdev/nvme: nvme_ctrlr_create() gets prchk_flags from nvme_async_probe_ctx 2021-12-08 08:31:24 +00:00
blob lib/blob: do not assume realloc(NULL, 0) returns a not-NULL value 2021-12-20 18:14:06 +00:00
blobfs test: optimize unit test .gitignore files 2021-08-20 07:29:57 +00:00
dma dma: Update memory domain context structure 2021-10-20 22:55:52 +00:00
env_dpdk test: optimize unit test .gitignore files 2021-08-20 07:29:57 +00:00
event scheduler/dynamic: don't adjust tsc too much for very busy cores 2021-09-28 07:29:03 +00:00
ftl spelling: test 2021-12-03 08:13:22 +00:00
idxd idxd: change NOTICELOGs to DEBUGLOGs 2021-11-17 10:58:17 +00:00
init spelling: test 2021-12-03 08:13:22 +00:00
ioat test: optimize unit test .gitignore files 2021-08-20 07:29:57 +00:00
iscsi spelling: test 2021-12-03 08:13:22 +00:00
json spelling: test 2021-12-03 08:13:22 +00:00
jsonrpc spelling: test 2021-12-03 08:13:22 +00:00
log test: optimize unit test .gitignore files 2021-08-20 07:29:57 +00:00
lvol test: optimize unit test .gitignore files 2021-08-20 07:29:57 +00:00
notify test: optimize unit test .gitignore files 2021-08-20 07:29:57 +00:00
nvme nvme: Remove nvme_ns_update 2021-12-20 08:49:41 +00:00
nvmf nvmf: update discovery log when removing hostnqn 2021-12-16 08:52:20 +00:00
reduce spelling: test 2021-12-03 08:13:22 +00:00
rpc ut/rpc: wrap syscalls using spdk.mock.unittest.mk 2021-09-27 20:59:37 +00:00
scsi spelling: test 2021-12-03 08:13:22 +00:00
sock spelling: test 2021-12-03 08:13:22 +00:00
thread spelling: test 2021-12-03 08:13:22 +00:00
util spelling: test 2021-12-03 08:13:22 +00:00
vhost spelling: test 2021-12-03 08:13:22 +00:00
json_mock.c ut/json_mock: Add spdk_json_write_string_fmt() 2021-02-09 11:29:53 +00:00
Makefile unittest/rpc: add rpc unittest 2021-09-06 09:55:33 +00:00