GlobalArrays / ga

Partitioned Global Address Space (PGAS) library for distributed arrays
http://hpc.pnl.gov/globalarrays/
Other
101 stars 38 forks source link

PARMCI_Wait either has unnecessary NULL checks or does UB #353

Open jeffhammond opened 1 month ago

jeffhammond commented 1 month ago

The checks if (nb_handle) imply that this argument can be NULL. However, SAMECLUSNODE unconditionally dereferences this pointer, so it cannot be NULL.

This code should be cleaned up to do at most one NULL check on the argument. I might work on this at some point.

int PARMCI_Wait(armci_hdl_t* usr_hdl)
{
    armci_ihdl_t nb_handle = (armci_ihdl_t)usr_hdl;
    int success=0;
    int direct = SAMECLUSNODE(nb_handle->proc);

    if(direct) {
        return(success);
    }

    if(nb_handle) {
        if(nb_handle->agg_flag) {
            armci_agg_complete(nb_handle, UNSET);
            return (success);
        }
    }

    if(nb_handle){