Skip to content

Commit

Permalink
fix use of zero as null pointer constant
Browse files Browse the repository at this point in the history
  • Loading branch information
uecker committed Nov 13, 2024
1 parent 40c9958 commit efd3009
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/misc/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
double timestamp(void)
{
struct timeval tv;
gettimeofday(&tv, 0); // more accurate than <time.h>
gettimeofday(&tv, NULL); // more accurate than <time.h>

return (double)tv.tv_sec + 1e-6 * (double)tv.tv_usec;
}
Expand Down
2 changes: 1 addition & 1 deletion src/moba/recon.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ static void recon(const struct moba_conf* conf, struct moba_conf_s* data,
mconf.b = conf->sobolev_b;
mconf.cnstcoil_flags = TE_FLAG | CSHIFT_FLAG;

struct mobamod nl = { 0 };
struct mobamod nl = { };

switch (conf->mode) {

Expand Down
7 changes: 4 additions & 3 deletions src/networks/nlinvnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,9 @@ static nn_t nlinvnet_get_network_step(const struct nlinvnet_s* nlinvnet, struct
auto dummy = nn_from_nlop_F(nlop_del_out_create(dom->N, dom->dims));
dummy = nn_set_input_name_F(dummy, 0, "ref_col");

complex float zero[1] = { 0 };
join = nn_set_input_const_F2(join, 1, 0, dom->N, dom->dims, MD_SINGLETON_STRS(dom->N), true, zero);
complex float zero[1] = { 0. };

join = nn_set_input_const_F2(join, 1, NULL, dom->N, dom->dims, MD_SINGLETON_STRS(dom->N), true, zero);
join = nn_combine_FF(dummy, join);
}

Expand Down Expand Up @@ -722,7 +723,7 @@ static nn_t nlinvnet_valid_create(const struct nlinvnet_s* nlinvnet, struct name
result = nn_chain2_FF(result, 0, NULL, nn_from_nlop_F(noir_decomp_create(model)), 0, NULL);

auto cim_iov = named_data_list_get_iovec(valid_data, "ref");
auto valid_loss = nn_chain2_FF(result, 0, 0, val_measure_create(nlinvnet->valid_loss, cim_iov->N, cim_iov->dims), 0, NULL);
auto valid_loss = nn_chain2_FF(result, 0, NULL, val_measure_create(nlinvnet->valid_loss, cim_iov->N, cim_iov->dims), 0, NULL);
iovec_free(cim_iov);

valid_loss = nn_set_input_name_F(valid_loss, 0, "ref");
Expand Down
2 changes: 1 addition & 1 deletion src/nn/data_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ extern const struct nlop_s* nn_batchgen_create(struct bat_gen_conf_s* config, nn

if (IN_BATCH_GENERATOR == in_types[i]) {

assert(0 != names[i]);
assert(NULL != names[i]);

N = MAX(N, nn_generic_domain(network, 0, names[i])->N);
D++;
Expand Down
2 changes: 1 addition & 1 deletion src/nn/nn.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ void nn_export_graph(const char* filename, nn_t op)
FILE *fp;
fp = fopen(filename, "w+");

assert(0 != fp);
assert(NULL != fp);

fprintf(fp, "digraph {\nnewrank=true;\n");
fprintf(fp, "{\n%s}\n", str);
Expand Down
3 changes: 2 additions & 1 deletion src/noncart/nufft_chain.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,15 @@ extern struct linop_s* nufft_create_chain(int N,

ret = linop_chain_FF(ret, linop_fftc_create(N, os_cim_dims, flags));

if (0 != basis) {
if (NULL != basis) {

long ksp_max_dims[N];
md_max_dims(N, ~0UL, ksp_max_dims, ksp_dims, bas_dims);
assert(md_check_compat(N, ~0UL, ksp_dims, bas_dims));

ret = linop_chain_FF(ret, linop_interpolate_kb_create(N, flags, ksp_max_dims, os_cim_dims, traj_dims, traj, conf));
ret = linop_chain_FF(ret, linop_fmac_create(N, ksp_max_dims, ~md_nontriv_dims(N, ksp_dims), 0, ~md_nontriv_dims(N, bas_dims), basis));

} else {

ret = linop_chain_FF(ret, linop_interpolate_kb_create(N, flags, ksp_dims, os_cim_dims, traj_dims, traj, conf));
Expand Down
4 changes: 2 additions & 2 deletions src/num/lapack.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ void lapack_schur(long N, complex float W[N], complex float VS[N][N], complex fl
int sdim = 0;

// On output, A overwritten by Schur form T
LAPACKE(cgees, 'V', 'N', 0, N, &A[0][0], N, &sdim, &W[0], &VS[0][0], N);
LAPACKE(cgees, 'V', 'N', NULL, N, &A[0][0], N, &sdim, &W[0], &VS[0][0], N);
}

void lapack_schur_double(long N, complex double W[N], complex double VS[N][N], complex double A[N][N])
{
int sdim = 0;

// On output, A overwritten by Schur form T
LAPACKE(zgees, 'V', 'N', 0, N, &A[0][0], N, &sdim, &W[0], &VS[0][0], N);
LAPACKE(zgees, 'V', 'N', NULL, N, &A[0][0], N, &sdim, &W[0], &VS[0][0], N);
}

// Solves the complex Sylvester matrix equation
Expand Down
2 changes: 1 addition & 1 deletion src/num/multind.c
Original file line number Diff line number Diff line change
Expand Up @@ -2391,7 +2391,7 @@ void* md_alloc_sameplace(int D, const long dimensions[D], size_t size, const voi
#ifdef USE_CUDA
return (cuda_ondevice(ptr) ? md_alloc_gpu : md_alloc)(D, dimensions, size);
#else
assert(0 != ptr);
assert(NULL != ptr);
return md_alloc(D, dimensions, size);
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/num/vptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static struct mem_s* vptr_create(int N, const long dims[N], size_t size, struct
{
long len = md_calc_size(N, dims) * (long)size;

void* ptr = mmap(0, (size_t)len, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
void* ptr = mmap(NULL, (size_t)len, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);

PTR_ALLOC(struct mem_s, x);

Expand Down

0 comments on commit efd3009

Please sign in to comment.