Commits (1)
......@@ -57,19 +57,19 @@ off_t smb_allocdat(smb_t* smb, off_t length, uint16_t refs)
}
}
if((long)offset<0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s invalid data offset: %lu", __FUNCTION__, offset);
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s invalid data offset: %" PRIdOFF, __FUNCTION__, offset);
return(SMB_ERR_DAT_OFFSET);
}
clearerr(smb->sda_fp);
if(fseeko(smb->sda_fp,(offset/SDT_BLOCK_LEN)*sizeof(refs),SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s seeking to: %ld", __FUNCTION__
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s seeking to: %" PRIdOFF, __FUNCTION__
,(offset/SDT_BLOCK_LEN)*sizeof(refs));
return(SMB_ERR_SEEK);
}
for(l=0;l<blocks;l++)
if(!fwrite(&refs,sizeof(refs),1,smb->sda_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s writing allocation bytes at offset %ld", __FUNCTION__
,"%s writing allocation bytes at offset %" PRIdOFF, __FUNCTION__
,((offset/SDT_BLOCK_LEN)+l)*sizeof(refs));
return(SMB_ERR_WRITE);
}
......@@ -100,7 +100,7 @@ off_t smb_fallocdat(smb_t* smb, off_t length, uint16_t refs)
offset=(ftell(smb->sda_fp)/sizeof(refs))*SDT_BLOCK_LEN;
if((long)offset<0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s invalid data offset: %lu", __FUNCTION__, offset);
,"%s invalid data offset: %" PRIdOFF, __FUNCTION__, offset);
return(SMB_ERR_DAT_OFFSET);
}
for(l=0;l<blocks;l++)
......@@ -158,15 +158,15 @@ int smb_freemsgdat(smb_t* smb, off_t offset, ulong length, uint16_t refs)
sda_offset=((offset/SDT_BLOCK_LEN)+l)*sizeof(i);
if(fseeko(smb->sda_fp,sda_offset,SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s %d '%s' seeking to %lu (0x%lX) of allocation file", __FUNCTION__
,"%s %d '%s' seeking to %" PRIdOFF " of allocation file", __FUNCTION__
,get_errno(),STRERROR(get_errno())
,sda_offset,sda_offset);
,sda_offset);
retval=SMB_ERR_SEEK;
break;
}
if(smb_fread(smb,&i,sizeof(i),smb->sda_fp)!=sizeof(i)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s reading allocation record at offset %ld", __FUNCTION__
,"%s reading allocation record at offset %" PRIdOFF, __FUNCTION__
,sda_offset);
retval=SMB_ERR_READ;
break;
......@@ -193,7 +193,7 @@ int smb_freemsgdat(smb_t* smb, off_t offset, ulong length, uint16_t refs)
}
if(!fwrite(&i,sizeof(i),1,smb->sda_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s writing allocation bytes at offset %ld", __FUNCTION__
,"%s writing allocation bytes at offset %" PRIdOFF, __FUNCTION__
,sda_offset);
retval=SMB_ERR_WRITE;
break;
......@@ -227,13 +227,13 @@ int smb_incdat(smb_t* smb, off_t offset, ulong length, uint16_t refs)
blocks=smb_datblocks(length);
for(l=0;l<blocks;l++) {
if(fseeko(smb->sda_fp,((offset/SDT_BLOCK_LEN)+l)*sizeof(i),SEEK_SET)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s seeking to %ld", __FUNCTION__
safe_snprintf(smb->last_error,sizeof(smb->last_error),"%s seeking to %" PRIdOFF, __FUNCTION__
,((offset/SDT_BLOCK_LEN)+l)*sizeof(i));
return(SMB_ERR_SEEK);
}
if(smb_fread(smb,&i,sizeof(i),smb->sda_fp)!=sizeof(i)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s reading allocation record at offset %ld", __FUNCTION__
,"%s reading allocation record at offset %" PRIdOFF, __FUNCTION__
,((offset/SDT_BLOCK_LEN)+l)*sizeof(i));
return(SMB_ERR_READ);
}
......@@ -244,7 +244,7 @@ int smb_incdat(smb_t* smb, off_t offset, ulong length, uint16_t refs)
}
if(!fwrite(&i,sizeof(i),1,smb->sda_fp)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s writing allocation record at offset %ld", __FUNCTION__
,"%s writing allocation record at offset %" PRIdOFF, __FUNCTION__
,((offset/SDT_BLOCK_LEN)+l)*sizeof(i));
return(SMB_ERR_WRITE);
}
......@@ -493,7 +493,7 @@ off_t smb_hallocdat(smb_t* smb)
offset=filelength(fileno(smb->sdt_fp));
if(offset<0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s invalid file length: %lu", __FUNCTION__,(ulong)offset);
,"%s invalid file length: %" PRIdOFF, __FUNCTION__, offset);
return(SMB_ERR_FILE_LEN);
}
if(fseek(smb->sdt_fp,0L,SEEK_END)) {
......@@ -503,7 +503,7 @@ off_t smb_hallocdat(smb_t* smb)
offset=ftell(smb->sdt_fp);
if(offset<0) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s invalid file offset: %ld", __FUNCTION__,offset);
,"%s invalid file offset: %" PRIdOFF, __FUNCTION__, offset);
return(SMB_ERR_DAT_OFFSET);
}
......
......@@ -447,13 +447,13 @@ int smb_getmsgidx(smb_t* smb, smbmsg_t* msg)
length=filelength(fileno(smb->sid_fp));
if(length<(long)idxreclen) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s invalid index file length: %ld", __FUNCTION__,length);
,"%s invalid index file length: %" PRIdOFF, __FUNCTION__,length);
return(SMB_ERR_FILE_LEN);
}
total=(ulong)(length/idxreclen);
if(!total) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s invalid index file length: %ld", __FUNCTION__,length);
,"%s invalid index file length: %" PRIdOFF, __FUNCTION__,length);
return(SMB_ERR_FILE_LEN);
}
......@@ -464,7 +464,7 @@ int smb_getmsgidx(smb_t* smb, smbmsg_t* msg)
byte_offset=msg->idx_offset*idxreclen;
if(byte_offset>=length) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s invalid index offset: %ld, byte offset: %ld, length: %ld", __FUNCTION__
,"%s invalid index offset: %ld, byte offset: %ld, length: %" PRIdOFF, __FUNCTION__
,(long)msg->idx_offset, byte_offset, length);
return(SMB_ERR_HDR_OFFSET);
}
......@@ -601,7 +601,7 @@ int smb_getlastidx(smb_t* smb, idxrec_t *idx)
length=filelength(fileno(smb->sid_fp));
if(length<(long)idxreclen) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s invalid index file length: %ld", __FUNCTION__,length);
,"%s invalid index file length: %" PRIdOFF, __FUNCTION__,length);
return(SMB_ERR_FILE_LEN);
}
if(fseeko(smb->sid_fp,length-idxreclen,SEEK_SET)) {
......@@ -1531,7 +1531,7 @@ int smb_addcrc(smb_t* smb, uint32_t crc)
if(length<0L || length%sizeof(uint32_t)) {
close(file);
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s invalid file length: %ld", __FUNCTION__, length);
,"%s invalid file length: %" PRIdOFF, __FUNCTION__, length);
return(SMB_ERR_FILE_LEN);
}
......@@ -1539,7 +1539,7 @@ int smb_addcrc(smb_t* smb, uint32_t crc)
if((buf=(uint32_t*)malloc((size_t)length))==NULL) {
close(file);
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s malloc failure of %ld bytes", __FUNCTION__
,"%s malloc failure of %" PRIdOFF " bytes", __FUNCTION__
,length);
return(SMB_ERR_MEM);
}
......@@ -1548,7 +1548,7 @@ int smb_addcrc(smb_t* smb, uint32_t crc)
close(file);
free(buf);
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s %d '%s' reading %ld bytes", __FUNCTION__
,"%s %d '%s' reading %" PRIdOFF " bytes", __FUNCTION__
,get_errno(),STRERROR(get_errno()),length);
return(SMB_ERR_READ);
}
......@@ -1629,7 +1629,7 @@ int smb_addmsghdr(smb_t* smb, smbmsg_t* msg, int storage)
idxlen = filelength(fileno(smb->sid_fp));
if(idxlen != (smb->status.total_msgs * idxreclen)) {
safe_snprintf(smb->last_error, sizeof(smb->last_error)
,"%s index file length (%ld), expected (%ld)", __FUNCTION__
,"%s index file length (%" PRIdOFF "), expected (%ld)", __FUNCTION__
,idxlen, smb->status.total_msgs * idxreclen);
smb_unlocksmbhdr(smb);
return SMB_ERR_FILE_LEN;
......@@ -1851,7 +1851,7 @@ int smb_putmsgidx(smb_t* smb, smbmsg_t* msg)
length = filelength(fileno(smb->sid_fp));
if(length < (long)(msg->idx_offset*idxreclen)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s invalid index offset: %ld, byte offset: %lu, length: %lu", __FUNCTION__
,"%s invalid index offset: %ld, byte offset: %lu, length: %" PRIdOFF, __FUNCTION__
,(long)msg->idx_offset, msg->idx_offset*idxreclen, length);
return(SMB_ERR_HDR_OFFSET);
}
......