Re: [PATCH 02/13] declare overflow during base128 decoding when 1 MSB nonzero, not 7

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Dana How" <danahow@xxxxxxxxx> writes:

> Concerning SEEK_SET,
> you are correct: my unistd.h #define's SEEK_SET to 0.

My understanding of the history is back when there was seek()
but not lseek() nor SEEK_X macros, everybody passed bare
integers and it was quite well established that 0 meant what
SEEK_SET means now, so I would be quite surprised if there is
_any_ platform that defines SEEK_SET to anything but zero.

Having said that, I wonder if this kind of thing can be caught
with sparse.  We should be able to express (or perhaps sparse
could have a built-in rule that says) something like "although
the standard says the third parameter to lseek() can be any
integer, you should not use anything but SEEK_X preprocessor
macros; also SEEK_X preprocessor macros, although they are
typically just "#define"s of small integer literals, can never
appear anywhere other than the third parameter as seek() and
lseek()".  I realize that there needs some data-flow analysis to
allow a code like this, though:

	int move_to(int fd, ofs_t offset, int relative)
	{
		int whence = SEEK_SET;

	        if (relative) {
                	whence = SEEK_CUR;
	                offset += relative;
	        }
		return lseek(fd, offset, whence) != (off_t)-1;
	}

> But if someone edits this, the arg order might remain.

Very true, and that is why I said I am going to take the patch.

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]