Commit 1ede0574 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Fix assumptions about sizeof(long/ulong)

So I did a search through the code for sizeof.*long and was surprised to find some remaining (harmless) assumptions that a long is 32-bit.
parent d1300300
Pipeline #2858 passed with stage
in 10 minutes and 12 seconds
......@@ -381,11 +381,11 @@ void sbbs_t::qwk_sec()
int s;
uint i;
ulong msgcnt;
ulong *sav_ptr;
uint32_t* sav_ptr;
getusrdirs();
if((sav_ptr=(ulong *)malloc(sizeof(ulong)*cfg.total_subs))==NULL) {
errormsg(WHERE,ERR_ALLOC,nulstr,sizeof(ulong)*cfg.total_subs);
if((sav_ptr=(uint32_t *)malloc(sizeof(uint32_t)*cfg.total_subs))==NULL) {
errormsg(WHERE,ERR_ALLOC,nulstr,sizeof(uint32_t)*cfg.total_subs);
return;
}
for(i=0;i<cfg.total_subs;i++)
......
......@@ -158,7 +158,7 @@ int main(int argc, char **argv)
char str[256],tmp[128],tag[256],addr[256],*p;
int i,j,mode=0,cmd=0,o_mode,max_age=0;
ushort smm,sbl;
ulong *crc=NULL,curcrc,total_crcs=0,l;
uint32_t *crc=NULL,curcrc,total_crcs=0,l;
FILE *route,*users,*nodes;
time_t now;
smbmsg_t msg;
......@@ -315,10 +315,10 @@ int main(int argc, char **argv)
break;
if(l==total_crcs) {
total_crcs++;
if((crc=(ulong *)realloc(crc
,sizeof(ulong)*total_crcs))==NULL) {
if((crc=(uint32_t *)realloc(crc
,sizeof(uint32_t)*total_crcs))==NULL) {
printf("Error allocating %lu bytes\n"
,sizeof(ulong)*total_crcs);
,sizeof(uint32_t)*total_crcs);
break;
}
crc[l]=curcrc;
......
......@@ -2367,7 +2367,7 @@ int attachment(const char *bundlename, fidoaddr_t dest, enum attachment_mode mod
char str[MAX_PATH+1],*path,*p;
char bundle_list_filename[MAX_PATH+1];
int fmsg,file,error=0L;
long fncrc,*mfncrc=0L,num_mfncrc=0L,crcidx;
uint32_t fncrc,*mfncrc=0L,num_mfncrc=0L,crcidx;
attach_t attach;
fmsghdr_t hdr;
size_t f;
......@@ -2432,9 +2432,9 @@ int attachment(const char *bundlename, fidoaddr_t dest, enum attachment_mode mod
continue;
num_mfncrc++;
p=getfname(hdr.subj);
if((mfncrc=(long *)realloc(mfncrc,num_mfncrc*sizeof(long)))==NULL) {
if((mfncrc=(uint32_t *)realloc(mfncrc,num_mfncrc*sizeof(uint32_t)))==NULL) {
lprintf(LOG_ERR,"ERROR line %d allocating %lu for bundle name crc"
,__LINE__,num_mfncrc*sizeof(long));
,__LINE__,num_mfncrc*sizeof(uint32_t));
continue;
}
mfncrc[num_mfncrc-1]=crc32(strupr(p),0);
......
......@@ -580,7 +580,7 @@ BOOL read_msgs_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
if(k) {
if((cfg->qhub[i]->sub=(sub_t**)malloc(sizeof(sub_t*)*k))==NULL)
return allocerr(instream, error, maxerrlen, offset,fname,sizeof(ulong)*k);
return allocerr(instream, error, maxerrlen, offset,fname,sizeof(sub_t)*k);
if((cfg->qhub[i]->conf=(ushort *)malloc(sizeof(ushort)*k))==NULL)
return allocerr(instream, error, maxerrlen, offset,fname,sizeof(ushort)*k);
if((cfg->qhub[i]->mode=(char *)malloc(sizeof(char)*k))==NULL)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment