Skip to content

Commit

Permalink
Merge pull request Unidata#2787 from seanm/UBSan-shift
Browse files Browse the repository at this point in the history
Fixed various UBSan warnings about invalid bit shifting
  • Loading branch information
WardF authored Nov 14, 2023
2 parents 16841a9 + 1162f64 commit 99f2295
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libdispatch/ncexhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ ncexinit(void)
int i;
bitmasks[0] = 0;
for(i=1;i<NCEXHASHKEYBITS;i++)
bitmasks[i] = (1 << i) - 1;
bitmasks[i] = (1ULL << i) - 1;
ncexinitialized = 1;
}

Expand Down Expand Up @@ -855,7 +855,7 @@ ncexhashprintstats(NCexhashmap* map)
fprintf(stderr," |leaf|=%d nactive/nleaves=%g", map->leaflen, leafavg);
fprintf(stderr," load=%g",leafload);
fprintf(stderr,"]\n");
dirsize = (1<<(map->depth))*((unsigned long long)sizeof(void*));
dirsize = (1ULL<<(map->depth))*((unsigned long long)sizeof(void*));
leafsize = (nleaves)*((unsigned long long)sizeof(NCexleaf));
total = dirsize + leafsize;
fprintf(stderr,"\tsizeof(directory)=%llu sizeof(leaves)=%lld total=%lld\n",
Expand Down
6 changes: 3 additions & 3 deletions libdispatch/nclistmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ free_NCList(void)
int
add_to_NCList(NC* ncp)
{
int i;
int new_id;
unsigned int i;
unsigned int new_id;
if(nc_filelist == NULL) {
if (!(nc_filelist = calloc(1, sizeof(NC*)*NCFILELISTLENGTH)))
return NC_ENOMEM;
Expand All @@ -96,7 +96,7 @@ add_to_NCList(NC* ncp)
if(new_id == 0) return NC_ENOMEM; /* no more slots */
nc_filelist[new_id] = ncp;
numfiles++;
ncp->ext_ncid = (new_id << ID_SHIFT);
ncp->ext_ncid = (int)(new_id << ID_SHIFT);
return NC_NOERR;
}

Expand Down

0 comments on commit 99f2295

Please sign in to comment.