From 00883ff8bef0a4f7549fa55256a165ebdadedf2b Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Mon, 20 Apr 2026 23:39:42 +0200 Subject: [PATCH] Use write results and fix queue/dbm/trustee warning leftovers --- opt/comm.c | 4 ++-- opt/sendm.c | 12 ++++++------ src/nwdbm.c | 26 +++++++++++++------------- src/nwqueue.c | 8 ++++---- src/trustee.c | 26 +++++++++++++------------- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/opt/comm.c b/opt/comm.c index 0db2f1d..f27773a 100644 --- a/opt/comm.c +++ b/opt/comm.c @@ -198,7 +198,7 @@ int main(int argc, char **argv) *p++ = 32; } *p++='\0'; - write(fdout, buf, (int)(p-buf)); + if (write(fdout, buf, (int)(p-buf))) {} close(fdout); @@ -206,7 +206,7 @@ int main(int argc, char **argv) memset(buf, 0, 512); while (0 < (size = loc_read(fdin, buf, 512 /*sizeof(buf)*/))) { - write(1, buf, size); + if (write(1, buf, size)) {} loc_lseek(fdin, 0, 2); } diff --git a/opt/sendm.c b/opt/sendm.c index 332701c..61d82b9 100644 --- a/opt/sendm.c +++ b/opt/sendm.c @@ -43,26 +43,26 @@ int main(int argc, char **argv) int size; char buf[1024]; while(--argc >0) { - write(fdout, *pp, strlen(*pp)); + if (write(fdout, *pp, strlen(*pp))) {} ++pp; - write(fdout, &b, 1); + if (write(fdout, &b, 1)) {} } b=0; - write(fdout, &b, 1); + if (write(fdout, &b, 1)) {} close(fdout); fdout=dup(fdin); if (6 == (size = read(fdin, buf, 6)) && !memcmp(buf, "+++++\n", 6)) { /* now write stdin -> sendmail */ if (is_pipe) { while (0 < (size = fread(buf, 1, sizeof(buf), stdin))) - write(fdout, buf, size); + if (write(fdout, buf, size)) {} } } else if (size > 0) - write(1, buf, size); /* probably errormessage */ + if (write(1, buf, size)) {} /* probably errormessage */ close(fdout); /* now we print errors */ while (0 < (size = read(fdin, buf, sizeof(buf)))) { - write(1, buf, size); + if (write(1, buf, size)) {} } close(fdin); return(0); diff --git a/src/nwdbm.c b/src/nwdbm.c index d1c178a..760edd5 100644 --- a/src/nwdbm.c +++ b/src/nwdbm.c @@ -2001,7 +2001,7 @@ static uint8 *test_add_dir(uint8 *unixname, uint8 *pp, int flags, else { chmod(unixname, permiss); if (uid >-1 && gid > -1) - (void)chown(unixname, uid, gid); + if (chown(unixname, uid, gid)) {} XDPRINTF((1, 0, "Created dir '%s'", unixname)); } } else { @@ -2018,7 +2018,7 @@ static uint8 *test_add_dir(uint8 *unixname, uint8 *pp, int flags, if (flags&2) { chmod(unixname, permiss); if (uid >-1 && gid > -1) - (void)chown(unixname, uid, gid); + if (chown(unixname, uid, gid)) {} } } if (flags&1) { @@ -2060,7 +2060,7 @@ static void correct_user_dirs(uint32 objid, uint8 *objname, int uid, int gid) (void)mkdir(fndir, mask); (void)chmod(fndir, mask); - (void)chown(fndir, uid, gid); + if (chown(fndir, uid, gid)) {} if ((f=opendir(fndir)) != (DIR*)NULL) { struct dirent* dirbuff; @@ -2075,7 +2075,7 @@ static void correct_user_dirs(uint32 objid, uint8 *objname, int uid, int gid) if (f) { fprintf(f, "REM auto created by mars_nwe\r\n"); fclose(f); - (void)chown(fndir, uid, gid); + if (chown(fndir, uid, gid)) {} chmod(fndir, 0600); } } @@ -2091,7 +2091,7 @@ static void correct_user_dirs(uint32 objid, uint8 *objname, int uid, int gid) && !S_ISLNK(lstatb.st_mode) && lstatb.st_uid != 0 && lstatb.st_gid != 0 && lstatb.st_uid != uid) { - (void)chown(fndir, uid, gid); + if (chown(fndir, uid, gid)) {} if (sys_has_trustee) { chmod(fndir, S_ISDIR(lstatb.st_mode) ? 700 : 600); } @@ -2108,7 +2108,7 @@ static void correct_user_dirs(uint32 objid, uint8 *objname, int uid, int gid) else downstr(p1+5); unlink(fndir); - (void)symlink(buf1, fndir); + if (symlink(buf1, fndir)) {} } void test_ins_unx_user(uint32 id) @@ -3050,7 +3050,7 @@ static void bcreate_obj(uint32 id, char *name, int type, /* 1/mstover -> ../id/1/2/3/4 */ slprintf(buf1,sizeof(buf1)-1, "../id/%s", id_buf); - (void)symlink(buf1, buf); + if (symlink(buf1, buf)) {} /* id/1/2/3/4 creat */ len = slprintf(buf, sizeof(buf)-2,"%s/id/%s", path_bindery, id_buf); @@ -3063,17 +3063,17 @@ static void bcreate_obj(uint32 id, char *name, int type, strmaxcpy(buf+len, "name.o", sizeof(buf)-1-len); strmaxcpy(buf1, name, sizeof(buf1)-1); downstr(buf1); - (void)symlink(buf1, buf); + if (symlink(buf1, buf)) {} /* typ -> 1 */ strmaxcpy(buf+len, "typ.o", sizeof(buf)-1-len); slprintf(buf1, sizeof(buf1)-1,"%x", type); - (void)symlink(buf1, buf); + if (symlink(buf1, buf)) {} /* flags & security */ strmaxcpy(buf+len, "f+s.o", sizeof(buf)-1-len); slprintf(buf1, sizeof(buf1)-1,"%02x%02x", flags&0xff, security&0xff); - (void)symlink(buf1, buf); + if (symlink(buf1, buf)) {} } @@ -3118,7 +3118,7 @@ static void bcreate_prop(uint32 id, int prop_id, char *name, /* id.p -> name */ slprintf(buf1,sizeof(buf1)-1, "%s", name); downstr(buf1); - (void)symlink(buf1, buf); + if (symlink(buf1, buf)) {} /* x/name creat */ @@ -3132,7 +3132,7 @@ static void bcreate_prop(uint32 id, int prop_id, char *name, /* flags & security */ strmaxcpy(buf+len, "f+s", sizeof(buf)-1-len); slprintf(buf1, sizeof(buf1)-1,"%02x%02x", propflags&0xff, propsecurity&0xff); - (void)symlink(buf1, buf); + if (symlink(buf1, buf)) {} } @@ -3181,7 +3181,7 @@ static void bcreate_val(uint32 id, int prop_id, int segment, sprintf(p1, "%02x", (int) *p++); p1+=2; } - (void)symlink(buf1, buf); + if (symlink(buf1, buf)) {} } diff --git a/src/nwqueue.c b/src/nwqueue.c index 937d08e..9cf9ac1 100644 --- a/src/nwqueue.c +++ b/src/nwqueue.c @@ -313,14 +313,14 @@ static time_t get_time_field(uint8 *timef) static void build_queue_file_name(uint8 *job_file_name, INT_QUEUE_JOB *jo) { *job_file_name = (uint8) sprintf((char*)job_file_name+1, - "%08lX.%03d", jo->file_entry_time, jo->job_id); + "%08X.%03d", (unsigned int)jo->file_entry_time, jo->job_id); } static void build_unix_queue_file(uint8 *buf, NWE_QUEUE *q, INT_QUEUE_JOB *jo) { if (q->queuedir_len) { memcpy(buf, q->queuedir, q->queuedir_len); - sprintf(buf+q->queuedir_len, "/%08lX.%03d", jo->file_entry_time, jo->job_id); + sprintf((char*)buf+q->queuedir_len, "/%08X.%03d", (unsigned int)jo->file_entry_time, jo->job_id); if (q->queuedir_downshift) downstr(buf+q->queuedir_len+1); } else *buf='\0'; @@ -485,7 +485,7 @@ int nw_close_queue_job(uint32 q_id, int job_id, } else result=-0xff; } - XDPRINTF(((result<0) ? 1 : 5, 0, "nw_close_queue_job, q=%lx, job=%d, result=%d", + XDPRINTF(((result<0) ? 1 : 5, 0, "nw_close_queue_job, q=%x, job=%d, result=%d", q_id, job_id, result)); return(result); } @@ -915,7 +915,7 @@ int nw_creat_queue(int q_typ, uint8 *q_name, int q_name_len, path_len=10; path=q_directory+path_len; } - sprintf(path, "/%08lX.QDR", obj.id); + sprintf(path, "/%08X.QDR", obj.id); *q_id = obj.id; nw_new_obj_prop(obj.id, NULL, 0, 0, 0, "Q_DIRECTORY", P_FL_ITEM, 0x31, diff --git a/src/trustee.c b/src/trustee.c index e25ab60..1982a5e 100644 --- a/src/trustee.c +++ b/src/trustee.c @@ -398,10 +398,10 @@ static int del_trustee_from_disk(int volume, dev_t dev, ino_t inode, uint32 id) (int) buf_uc[2], (int) buf_uc[3], (unsigned int)id); - (void)seteuid(0); + if (seteuid(0)) {} if (!unlink(buf)) result=0; - (void)reseteuid(); + if (reseteuid()) {} return(result); } @@ -423,12 +423,12 @@ unsigned int tru_vol_sernum(int volume, int mode) } if (mode) { if (++sernum==MAX_U32) sernum=1; - (void)seteuid(0); + if (seteuid(0)) {} unlink(buf); slprintf(buf1, sizeof(buf1)-1, "%x", sernum); if (symlink(buf1, buf)) errorp(0, "rw_trustee_sernum", "symlink %s %s failed", buf1, buf); - (void)reseteuid(); + if (reseteuid()) {} tru_free_cache(volume); } return(sernum); @@ -449,12 +449,12 @@ void tru_free_file_trustees_from_disk(int volume, int dev, ino_t inode) (int) buf_uc[1], (int) buf_uc[2]); slprintf(buf+len, sizeof(buf) - len -1, "t.%x", (int)buf_uc[3]); - (void)seteuid(0); + if (seteuid(0)) {} unx_xrmdir(buf); /* now we remove the name of the dir/file */ slprintf(buf+len, sizeof(buf) -len -1, "n.%x", (int)buf_uc[3]); unlink(buf); - (void)reseteuid(); + if (reseteuid()) {} } int tru_del_trustee(int volume, uint8 *unixname, struct stat *stb, uint32 id) @@ -601,7 +601,7 @@ static int local_tru_add_trustee_set(int volume, uint8 *unixname, int volumenamelen = get_volume_unixnamlen(volume); uint8 ufnbuf[2]; uint8 *ufn; - (void)seteuid(0); + if (seteuid(0)) {} while (count--) { if (! ((own_eff_rights & TRUSTEE_S) || (act_id_flags&1)) ) { /* only user with TRUSTEE_S are allowed to set TRUSTEE_S */ @@ -614,7 +614,7 @@ static int local_tru_add_trustee_set(int volume, uint8 *unixname, nwoic->id, nwoic->trustee, volume, unixname, -result); }) if (result){ - (void)reseteuid(); + if (reseteuid()) {} goto func_err; } nwoic++; @@ -626,7 +626,7 @@ static int local_tru_add_trustee_set(int volume, uint8 *unixname, *(ufn+1)='\0'; } creat_trustee_path(volume, stb->st_dev, stb->st_ino, ufn); - (void)reseteuid(); + if (reseteuid()) {} #if 0 /* now in tru_add_trustee_set */ tru_vol_sernum(volume, 1); /* trustee sernum needs updated */ #endif @@ -652,7 +652,7 @@ int tru_add_trustee_set(int volume, uint8 *unixname, char *p = unixname+len; char *volp = unixname+vollen; - (void)seteuid(0); + if (seteuid(0)) {} while (--p > volp) { if (*p == '/') { struct stat statb; @@ -675,7 +675,7 @@ int tru_add_trustee_set(int volume, uint8 *unixname, *p='/'; } } - (void)reseteuid(); + if (reseteuid()) {} tru_vol_sernum(volume, 1); /* trustee sernum needs updated */ } return (result); @@ -715,9 +715,9 @@ int tru_set_inherited_mask(int volume, uint8 *unixname, FILE_TRUSTEE_NODE *tr=find_trustee_node(volume, stb->st_dev, stb->st_ino); if (tr && (!(tr->mode_flags&0x1e) || !act_uid)) { int result; - (void)seteuid(0); + if (seteuid(0)) {} result=put_trustee_to_disk(volume, stb->st_dev, stb->st_ino, 0L, new_mask); - (void)reseteuid(); + if (reseteuid()) {} if (!result) tru_vol_sernum(volume, 1); /* trustee sernum needs updated */ return(result);