From: Alan Cox Date: Sat, 9 Apr 2016 16:07:28 +0000 (+0100) Subject: utent: Fix casting X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=b07edebf908658aabcea503dad39b092cc3b250e;p=FUZIX.git utent: Fix casting sizeof is an size_t (unsigned 16bit in some cases), we therefore need to cast it to 32bit signed *before* negation. --- diff --git a/Library/libs/utent.c b/Library/libs/utent.c index f271c993..44d13b1f 100644 --- a/Library/libs/utent.c +++ b/Library/libs/utent.c @@ -89,7 +89,7 @@ getutline(const struct utmp * utmp_entry) #if 0 /* This is driving me nuts. It's not an implementation problem - it's a matter of how things _SHOULD_ behave. Groan. */ if (ut_fd!=-1) - lseek(ut_fd, (off_t) -sizeof(struct utmp), SEEK_CUR); + lseek(ut_fd, -(off_t)sizeof(struct utmp), SEEK_CUR); #endif while ((utmp=getutent())!=NULL) @@ -113,11 +113,11 @@ pututline(const struct utmp * utmp_entry) /* Ignore the return value. That way, if they've already positioned the file pointer where they want it, everything will work out. */ if (ut_fd!=-1) - (void) lseek(ut_fd, (off_t) -sizeof(struct utmp), SEEK_CUR); + (void) lseek(ut_fd, -(off_t)sizeof(struct utmp), SEEK_CUR); #endif if ((ut=getutid(utmp_entry))!=NULL) - lseek(ut_fd, (off_t) -sizeof(struct utmp), SEEK_CUR); + lseek(ut_fd, -(off_t)sizeof(struct utmp), SEEK_CUR); else if( ut_fd==-1 ) return NULL; else @@ -133,7 +133,7 @@ pututline(const struct utmp * utmp_entry) return NULL; /* I think this final lseek gets the result Nat was after ... RdB */ - lseek(ut_fd, (off_t) -sizeof(struct utmp), SEEK_CUR); + lseek(ut_fd, -(off_t) sizeof(struct utmp), SEEK_CUR); /* Ignoring untrapped errors */ errno=xerrno;