Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 6d36a29d authored by Rob Swindell's avatar Rob Swindell 💬

Resolve some GCC warnings about uncheck return values from std C functions

write()
chsize()
parent 095a7b4b
Pipeline #2429 passed with stage
in 9 minutes and 28 seconds
......@@ -180,7 +180,7 @@ int smb_freemsgdat(smb_t* smb, off_t offset, ulong length, uint16_t refs)
continue;
}
}
if(fseek(smb->sda_fp,-(int)sizeof(i),SEEK_CUR)) {
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s %d '%s' seeking backwards 2 bytes in allocation file", __FUNCTION__
......@@ -192,13 +192,14 @@ int smb_freemsgdat(smb_t* smb, off_t offset, ulong length, uint16_t refs)
safe_snprintf(smb->last_error,sizeof(smb->last_error)
,"%s writing allocation bytes at offset %ld", __FUNCTION__
,sda_offset);
retval=SMB_ERR_WRITE;
retval=SMB_ERR_WRITE;
break;
}
}
fflush(smb->sda_fp);
if(filelength(fileno(smb->sdt_fp)) / SDT_BLOCK_LEN > (long)(filelength(fileno(smb->sda_fp)) / sizeof(uint16_t)))
chsize(fileno(smb->sdt_fp), (long)(filelength(fileno(smb->sda_fp)) / sizeof(uint16_t)) * SDT_BLOCK_LEN);
if(chsize(fileno(smb->sdt_fp), (long)(filelength(fileno(smb->sda_fp)) / sizeof(uint16_t)) * SDT_BLOCK_LEN) != 0)
retval = SMB_ERR_TRUNCATE;
if(da_opened)
smb_close_da(smb);
smb_unlocksmbhdr(smb);
......@@ -307,7 +308,8 @@ int smb_freemsghdr(smb_t* smb, off_t offset, ulong length)
sha_offset = offset/SHD_BLOCK_LEN;
if(filelength(fileno(smb->sha_fp)) <= (sha_offset + blocks)) {
if(chsize(fileno(smb->sha_fp), (long)sha_offset) == 0) {
chsize(fileno(smb->shd_fp), (long)(smb->status.header_offset + offset));
if(chsize(fileno(smb->shd_fp), (long)(smb->status.header_offset + offset)) != 0)
return SMB_ERR_TRUNCATE;
return SMB_SUCCESS;
}
}
......
......@@ -1492,6 +1492,7 @@ int smb_addcrc(smb_t* smb, uint32_t crc)
char str[MAX_PATH+1];
int file;
int wr;
int result = SMB_SUCCESS;
off_t length;
long newlen;
ulong l;
......@@ -1562,9 +1563,13 @@ int smb_addcrc(smb_t* smb, uint32_t crc)
if(length>=(long)(smb->status.max_crcs*sizeof(int32_t))) {
newlen=(smb->status.max_crcs-1)*sizeof(int32_t);
chsize(file,0); /* truncate it */
lseek(file,0L,SEEK_SET);
write(file,buf+(length-newlen),newlen);
if(chsize(file,0) != 0) { /* truncate it */
result = SMB_ERR_TRUNCATE;
} else {
lseek(file,0L,SEEK_SET);
if(write(file,buf+(length-newlen),newlen) != newlen)
result = SMB_ERR_WRITE;
}
}
free(buf);
}
......@@ -1578,7 +1583,7 @@ int smb_addcrc(smb_t* smb, uint32_t crc)
return(SMB_ERR_WRITE);
}
return(SMB_SUCCESS);
return result;
}
/****************************************************************************/
......@@ -2009,13 +2014,16 @@ int smb_create(smb_t* smb)
return retval;
rewind(smb->shd_fp);
chsize(fileno(smb->shd_fp),sizeof(smbhdr_t)+sizeof(smbstatus_t));
if(chsize(fileno(smb->shd_fp),sizeof(smbhdr_t)+sizeof(smbstatus_t)) != 0)
return SMB_ERR_TRUNCATE;
fflush(smb->shd_fp);
rewind(smb->sdt_fp);
chsize(fileno(smb->sdt_fp),0L);
if(chsize(fileno(smb->sdt_fp),0L) != 0)
return SMB_ERR_TRUNCATE;
rewind(smb->sid_fp);
chsize(fileno(smb->sid_fp),0L);
if(chsize(fileno(smb->sid_fp),0L) != 0)
return SMB_ERR_TRUNCATE;
SAFEPRINTF(str,"%s.ini",smb->file);
if((fp = fopen(str, "w")) != NULL) {
......
......@@ -68,6 +68,7 @@
#define SMB_ERR_DELETE -207 /* File deletion error */
#define SMB_ERR_UNLOCK -208 /* File unlock error */
#define SMB_ERR_RENAME -209 /* File rename error */
#define SMB_ERR_TRUNCATE -210 /* File truncation error */
#define SMB_ERR_MEM -300 /* Memory allocation error */
#define SMB_DUPE_MSG 1 /* Duplicate message detected by smb_addcrc() */
......
......@@ -128,6 +128,8 @@ BOOL semfile_signal(const char* fname, const char* text)
{
int file;
struct utimbuf ut;
size_t textlen = 0;
ssize_t wrlen = 0;
#if !defined(NO_SOCKET_SUPPORT)
char hostname[128];
......@@ -137,10 +139,10 @@ BOOL semfile_signal(const char* fname, const char* text)
if((file=open(fname,O_CREAT|O_WRONLY, DEFFILEMODE))<0) /* use sopen instead? */
return(FALSE);
if(text!=NULL)
write(file,text,strlen(text));
wrlen = write(file,text,textlen = strlen(text));
close(file);
/* update the time stamp */
ut.actime = ut.modtime = time(NULL);
return utime(fname, &ut)==0;
return utime(fname, &ut)==0 && wrlen == textlen;
}
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