Opened 17 years ago

Closed 9 years ago

#1590 closed defect (wontfix)

VSIFSeekL() (vsi_l_offset) is unsigned making negative seek impossible

Reported by: warmerdam Owned by: warmerdam
Priority: low Milestone:
Component: default Version: unspecified
Severity: normal Keywords: vsi
Cc:

Description

The frmts/gsg/gsagdataset.cpp code uses the following fairly common fseek() convention to move back one byte:

	    	if( VSIFSeekL( poGDS->fp, -1, SEEK_CUR ) != 0 )

but this produces the warning:

gsagdataset.cpp: In member function `virtual CPLErr GSAGRasterBand::IReadBlock(int, int, void*)':
gsagdataset.cpp:373: warning: passing negative value `-0x00000000000000001' for converting 2 of `int VSIFSeekL(FILE*, vsi_l_offset, int)'

because the offset argument is of type vsi_l_offset which is normall GUIntBig, an unsigned type.

In fseek() which this is supposed to be similar to the size_t type is used which i believe is always signed.

The question is should we change vsi_l_offset to be GIntBig or give up on use of VSIFSeekL() for backwards steps (using negative seeks relative to SEEK_CUR).

It is an objective of the VSI API that it operate in a POSIX like fashion with a minimum of surprises for folks. On the other hand using GIntBig for vsi_l_offset would be a subtle ABI change to a core component, and would also make it impossible to seek in the 2GB to 4GB region of files on systems which use 32bit types for GIntBig instead of 64bit types.

In practice I think very few systems lack 64 bit integer types now days. Possibly WinCE is an exception? So perhaps the seek limit is not a big deal.

Change History (4)

comment:1 by warmerdam, 16 years ago

Milestone: 1.5.0
Priority: normallow

defer from 1.5.

comment:2 by Jukka Rahkonen, 9 years ago

Opinions about this one? Still valid ticket, or not?

comment:3 by Jukka Rahkonen, 9 years ago

The only OS that was was recognized as potentially affected was WinCE and support for it has just dropped. However, I have no idea if this ticket is still valid or not.

comment:4 by Even Rouault, 9 years ago

Resolution: wontfix
Status: newclosed

The ticket is valid for all platforms, but there's no easy resolution. Changing vsi_l_offset to GIntBig just for that would be a bit of a pain. The workaround used up to know is to use VSIFSeekL( fp, VSIFTellL(fp) -1, SEEK_SET) instead.

Closing as wontfix.

Note: See TracTickets for help on using tickets.