Skip to content

Commit

Permalink
common: fixing malloc sizes
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Gromadzki <tomasz.gromadzki@intel.com>
  • Loading branch information
grom72 committed Oct 24, 2023
1 parent de0c594 commit fbb9d96
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/libpmem2/auto_flush_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ check_domain_in_region(const char *region_path)
char *domain_path = NULL;
int cpu_cache = 0;

domain_path = Malloc(PATH_MAX);
domain_path = Malloc(PATH_MAX * sizeof(char));
if (domain_path == NULL) {
ERR("!Malloc");
cpu_cache = -1;
Expand Down
5 changes: 3 additions & 2 deletions src/libpmem2/deep_flush_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ pmem2_deep_flush_write(unsigned region_id)
int deep_flush_fd = -1;
char rbuf[2];

deep_flush_path = Malloc(PATH_MAX);
deep_flush_path = Malloc(PATH_MAX * sizeof(char));
if (deep_flush_path == NULL) {
ERR("!Malloc");
ret = -1;
errno = ENOMEM;
ret = PMEM2_E_ERRNO;
goto end;
}

Expand Down
4 changes: 2 additions & 2 deletions src/libpmem2/pmem2_utils_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pmem2_get_type_from_stat(const os_stat_t *st, enum pmem2_file_type *type)
char *spath = NULL;
char *npath = NULL;

spath = Malloc(PATH_MAX);
spath = Malloc(PATH_MAX * sizeof(char));
if (spath == NULL) {
errno = ENOMEM;
ERR("!Malloc");
Expand All @@ -63,7 +63,7 @@ pmem2_get_type_from_stat(const os_stat_t *st, enum pmem2_file_type *type)

LOG(4, "device subsystem path \"%s\"", spath);

npath = Malloc(PATH_MAX);
npath = Malloc(PATH_MAX * sizeof(char));
if (npath == NULL) {
errno = ENOMEM;
ERR("!Malloc");
Expand Down
4 changes: 2 additions & 2 deletions src/libpmem2/region_namespace_ndctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ndctl_match_devdax(dev_t st_rdev, const char *devname)
if (*devname == '\0')
return 1;

path = Malloc(PATH_MAX);
path = Malloc(PATH_MAX * sizeof(char));
if (path == NULL) {
errno = ENOMEM;
ERR("!Malloc");
Expand Down Expand Up @@ -87,7 +87,7 @@ ndctl_match_fsdax(dev_t st_dev, const char *devname)
if (*devname == '\0')
return 1;

path = Malloc(PATH_MAX);
path = Malloc(PATH_MAX * sizeof(char));
if (path == NULL) {
errno = ENOMEM;
ERR("!Malloc");
Expand Down
60 changes: 30 additions & 30 deletions src/stats/stack-usage-debug.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,6 @@
8448 out_common : src/debug/libpmemobj/out.su:out.c dynamic,bounded
8448 out_common : src/debug/libpmem2/out.su:out.c dynamic,bounded
8448 out_common : src/debug/core/out.su:out.c dynamic,bounded
8288 pmem2_get_type_from_stat : src/debug/libpmempool/pmem2_utils_linux.su:pmem2_utils_linux.c dynamic,bounded
8288 pmem2_get_type_from_stat : src/debug/libpmem/pmem2_utils_linux.su:pmem2_utils_linux.c dynamic,bounded
8288 pmem2_get_type_from_stat : src/debug/libpmemobj/pmem2_utils_linux.su:pmem2_utils_linux.c dynamic,bounded
8288 pmem2_get_type_from_stat : src/debug/libpmem2/pmem2_utils_linux.su:pmem2_utils_linux.c dynamic,bounded
8288 pmem2_get_type_from_stat : src/debug/common/pmem2_utils_linux.su:pmem2_utils_linux.c dynamic,bounded
8272 replica_check_store_size : src/debug/libpmempool/replica.su:replica.c dynamic,bounded
6768 memset_movnt_sse2_noflush_wcbarrier : src/debug/libpmem/memset_nt_sse2.su:memset_nt_sse2.c dynamic,bounded
6768 memset_movnt_sse2_noflush_wcbarrier : src/debug/libpmem2/memset_nt_sse2.su:memset_nt_sse2.c dynamic,bounded
Expand Down Expand Up @@ -166,39 +161,14 @@
5936 memset_mov_avx_clflushopt : src/debug/libpmem/memset_t_avx.su:memset_t_avx.c dynamic,bounded
5936 memset_mov_avx_clflushopt : src/debug/libpmem2/memset_t_avx.su:memset_t_avx.c dynamic,bounded
4384 pool_params_parse : src/debug/libpmempool/pool.su:pool.c dynamic,bounded
4352 out_init : src/debug/libpmempool/out.su:out.c dynamic,bounded
4352 out_init : src/debug/libpmem/out.su:out.c dynamic,bounded
4352 out_init : src/debug/libpmemobj/out.su:out.c dynamic,bounded
4352 out_init : src/debug/libpmem2/out.su:out.c dynamic,bounded
4352 out_init : src/debug/core/out.su:out.c dynamic,bounded
4320 ndctl_match_fsdax : src/debug/libpmem/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
4320 ndctl_match_fsdax : src/debug/libpmempool/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
4320 ndctl_match_fsdax : src/debug/libpmemobj/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
4320 ndctl_match_fsdax : src/debug/libpmem2/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
4320 ndctl_match_fsdax : src/debug/common/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
4288 pool_set_map : src/debug/libpmempool/pool.su:pool.c dynamic,bounded
4288 ndctl_match_devdax : src/debug/libpmem/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
4288 ndctl_match_devdax : src/debug/libpmempool/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
4288 ndctl_match_devdax : src/debug/libpmemobj/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
4288 ndctl_match_devdax : src/debug/libpmem2/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
4288 ndctl_match_devdax : src/debug/common/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
4208 util_header_check : src/debug/libpmempool/set.su:set.c dynamic,bounded
4208 util_header_check : src/debug/libpmemobj/set.su:set.c dynamic,bounded
4208 util_header_check : src/debug/common/set.su:set.c dynamic,bounded
4176 features_check : src/debug/libpmempool/feature.su:feature.c static
4160 pool_hdr_default_fix : src/debug/libpmempool/check_pool_hdr.su:check_pool_hdr.c dynamic,bounded
4160 pmem2_deep_flush_write : src/debug/libpmempool/deep_flush_linux.su:deep_flush_linux.c static
4160 pmem2_deep_flush_write : src/debug/libpmemobj/deep_flush_linux.su:deep_flush_linux.c static
4160 pmem2_deep_flush_write : src/debug/libpmem/deep_flush_linux.su:deep_flush_linux.c static
4160 pmem2_deep_flush_write : src/debug/libpmem2/deep_flush_linux.su:deep_flush_linux.c static
4160 pmem2_deep_flush_write : src/debug/common/deep_flush_linux.su:deep_flush_linux.c static
4160 check_pool_hdr_uuids : src/debug/libpmempool/check_pool_hdr.su:check_pool_hdr.c static
4160 check_pool_hdr : src/debug/libpmempool/check_pool_hdr.su:check_pool_hdr.c static
4160 check_domain_in_region : src/debug/libpmempool/auto_flush_linux.su:auto_flush_linux.c static
4160 check_domain_in_region : src/debug/libpmemobj/auto_flush_linux.su:auto_flush_linux.c static
4160 check_domain_in_region : src/debug/libpmem/auto_flush_linux.su:auto_flush_linux.c static
4160 check_domain_in_region : src/debug/libpmem2/auto_flush_linux.su:auto_flush_linux.c static
4160 check_domain_in_region : src/debug/common/auto_flush_linux.su:auto_flush_linux.c static
4144 pool_set_type : src/debug/libpmempool/pool.su:pool.c static
4144 pool_hdr_default_check : src/debug/libpmempool/check_pool_hdr.su:check_pool_hdr.c static
3200 memset_mov_sse2_noflush : src/debug/libpmem/memset_t_sse2.su:memset_t_sse2.c dynamic,bounded
Expand Down Expand Up @@ -354,6 +324,11 @@
256 out_nonl : src/debug/libpmemobj/out.su:out.c dynamic,bounded
256 out_nonl : src/debug/libpmem2/out.su:out.c dynamic,bounded
256 out_nonl : src/debug/core/out.su:out.c dynamic,bounded
256 out_init : src/debug/libpmempool/out.su:out.c dynamic,bounded
256 out_init : src/debug/libpmem/out.su:out.c dynamic,bounded
256 out_init : src/debug/libpmemobj/out.su:out.c dynamic,bounded
256 out_init : src/debug/libpmem2/out.su:out.c dynamic,bounded
256 out_init : src/debug/core/out.su:out.c dynamic,bounded
256 out_err : src/debug/libpmempool/out.su:out.c static
256 out_err : src/debug/libpmem/out.su:out.c static
256 out_err : src/debug/libpmemobj/out.su:out.c static
Expand All @@ -373,6 +348,11 @@
240 os_open : src/debug/libpmemobj/os_posix.su:os_posix.c static
240 os_open : src/debug/libpmem2/os_posix.su:os_posix.c static
240 os_open : src/debug/core/os_posix.su:os_posix.c static
240 ndctl_match_fsdax : src/debug/libpmem/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
240 ndctl_match_fsdax : src/debug/libpmempool/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
240 ndctl_match_fsdax : src/debug/libpmemobj/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
240 ndctl_match_fsdax : src/debug/libpmem2/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
240 ndctl_match_fsdax : src/debug/common/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
240 huge_ensure_header_type : src/debug/libpmemobj/memblock.su:memblock.c dynamic,bounded
224 util_poolset_chmod : src/debug/libpmempool/set.su:set.c dynamic,bounded
224 util_poolset_chmod : src/debug/libpmemobj/set.su:set.c dynamic,bounded
Expand Down Expand Up @@ -403,6 +383,11 @@
208 pmem2_map_delete : src/debug/libpmem2/map_posix.su:map_posix.c static
208 palloc_reservation_clear : src/debug/libpmemobj/palloc.su:palloc.c static
208 operation_init : src/debug/libpmemobj/memops.su:memops.c static
208 ndctl_match_devdax : src/debug/libpmem/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
208 ndctl_match_devdax : src/debug/libpmempool/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
208 ndctl_match_devdax : src/debug/libpmemobj/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
208 ndctl_match_devdax : src/debug/libpmem2/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
208 ndctl_match_devdax : src/debug/common/region_namespace_ndctl.su:region_namespace_ndctl.c dynamic,bounded
208 list_insert : src/debug/libpmemobj/list.su:list.c dynamic,bounded
208 constructor_zrealloc_root : src/debug/libpmemobj/obj.su:obj.c dynamic,bounded
208 check_shutdown_state : src/debug/libpmempool/replica.su:replica.c dynamic,bounded
Expand Down Expand Up @@ -934,6 +919,11 @@
112 pmem2_source_device_usc : src/debug/libpmem2/usc_ndctl.su:usc_ndctl.c dynamic,bounded
112 pmem2_source_device_usc : src/debug/common/usc_ndctl.su:usc_ndctl.c dynamic,bounded
112 pmem2_log_flush : src/debug/libpmem2/persist.su:persist.c dynamic,bounded
112 pmem2_get_type_from_stat : src/debug/libpmempool/pmem2_utils_linux.su:pmem2_utils_linux.c dynamic,bounded
112 pmem2_get_type_from_stat : src/debug/libpmem/pmem2_utils_linux.su:pmem2_utils_linux.c dynamic,bounded
112 pmem2_get_type_from_stat : src/debug/libpmemobj/pmem2_utils_linux.su:pmem2_utils_linux.c dynamic,bounded
112 pmem2_get_type_from_stat : src/debug/libpmem2/pmem2_utils_linux.su:pmem2_utils_linux.c dynamic,bounded
112 pmem2_get_type_from_stat : src/debug/common/pmem2_utils_linux.su:pmem2_utils_linux.c dynamic,bounded
112 pmem2_flush_file_buffers : src/debug/libpmem2/persist.su:persist.c static
112 pmem2_deep_flush : src/debug/libpmem2/deep_flush.su:deep_flush.c dynamic,bounded
112 pmem2_badblock_next_region : src/debug/libpmempool/badblocks_ndctl.su:badblocks_ndctl.c dynamic,bounded
Expand Down Expand Up @@ -1377,6 +1367,11 @@
80 check_replica_sizes : src/debug/libpmempool/replica.su:replica.c dynamic,bounded
80 check_replica_cycles : src/debug/libpmempool/replica.su:replica.c dynamic,bounded
80 check_poolset_uuids : src/debug/libpmempool/replica.su:replica.c dynamic,bounded
80 check_domain_in_region : src/debug/libpmempool/auto_flush_linux.su:auto_flush_linux.c static
80 check_domain_in_region : src/debug/libpmemobj/auto_flush_linux.su:auto_flush_linux.c static
80 check_domain_in_region : src/debug/libpmem/auto_flush_linux.su:auto_flush_linux.c static
80 check_domain_in_region : src/debug/libpmem2/auto_flush_linux.su:auto_flush_linux.c static
80 check_domain_in_region : src/debug/common/auto_flush_linux.su:auto_flush_linux.c static
80 check_answer_loop : src/debug/libpmempool/check_util.su:check_util.c static
80 badblocks_recovery_file_exists : src/debug/libpmempool/set_badblocks.su:set_badblocks.c static
80 badblocks_recovery_file_exists : src/debug/libpmemobj/set_badblocks.su:set_badblocks.c static
Expand Down Expand Up @@ -1618,6 +1613,11 @@
64 pmem2_realloc : src/debug/libpmemobj/pmem2_utils.su:pmem2_utils.c static
64 pmem2_realloc : src/debug/libpmem2/pmem2_utils.su:pmem2_utils.c static
64 pmem2_realloc : src/debug/common/pmem2_utils.su:pmem2_utils.c static
64 pmem2_deep_flush_write : src/debug/libpmempool/deep_flush_linux.su:deep_flush_linux.c static
64 pmem2_deep_flush_write : src/debug/libpmemobj/deep_flush_linux.su:deep_flush_linux.c static
64 pmem2_deep_flush_write : src/debug/libpmem/deep_flush_linux.su:deep_flush_linux.c static
64 pmem2_deep_flush_write : src/debug/libpmem2/deep_flush_linux.su:deep_flush_linux.c static
64 pmem2_deep_flush_write : src/debug/common/deep_flush_linux.su:deep_flush_linux.c static
64 pmem2_deep_flush_page : src/debug/libpmem2/persist.su:persist.c dynamic,bounded
64 pmem2_config_set_vm_reservation : src/debug/libpmempool/config.su:config.c static
64 pmem2_config_set_vm_reservation : src/debug/libpmemobj/config.su:config.c static
Expand Down
Loading

0 comments on commit fbb9d96

Please sign in to comment.