numam-spdk/lib/blob
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
..
blob_bs_dev.c blob: use uint64_t for unmap and write_zeroes lba count 2021-10-14 08:17:16 +00:00
blobstore.c lib/blob: do not assume realloc(NULL, 0) returns a not-NULL value 2021-12-20 18:14:06 +00:00
blobstore.h spelling: lib 2021-12-03 08:12:55 +00:00
Makefile blob: use uint64_t for unmap and write_zeroes lba count 2021-10-14 08:17:16 +00:00
request.c blob: use uint64_t for unmap and write_zeroes lba count 2021-10-14 08:17:16 +00:00
request.h blob: use uint64_t for unmap and write_zeroes lba count 2021-10-14 08:17:16 +00:00
spdk_blob.map lib/blob: add a map file. 2020-04-15 22:10:08 +00:00
zeroes.c blob: use uint64_t for unmap and write_zeroes lba count 2021-10-14 08:17:16 +00:00