On Sun, Nov 16, 2014 at 23:33, Ingo Schwarze wrote: > Hi Tobias, > > Tobias Stoeckmann wrote on Sun, Nov 16, 2014 at 09:58:43PM +0100: >> On Sun, Nov 16, 2014 at 09:39:32PM +0100, Alexander Bluhm wrote: > >>> Can we change p_filesize type to off_t instead? > >> Definitely, but it takes closer looks for a review. Diff exists, > > OK schwarze@ (from careful code review) > >> I was just not sure if it's worth to support patch files >> which are larger than 2 GB on 32 bit systems. > > I think that question is of limited relevance. Using the canonical > data types for their respective purposes reduces the risk of having > bugs and improves readability of the code, even when it can be shown > that a different data type is actually good enough for a particular > case. For example, what if people change the code in the future?
Sorry, I haven't really been looking at the diffs, but a general comment. I think using the correct data type is the right thing to do. If it's the size of a file, it goes in an off_t. The only thing to watch for is passing an off_t to malloc(), where it can wrap and be truncated. Using long/size_t to store a filesize "solves" that problem by truncating early, which may help avoid memory corruption bugs later, but I don't it's the best approach long term.
