User Tools

Site Tools


negix:writeandsizet

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

negix:writeandsizet [2018/09/10 16:21]
127.0.0.1 external edit
negix:writeandsizet [2022/09/22 13:09] (current)
solar
Line 23: Line 23:
 So here is a magic type which can store the value range of a ''size_t'' //and// a ''-1''. Sadly, it can’t, as you could easily determine with five lines of C code and a ''sizeof()'': ''ssize_t'' and ''size_t'' have the same size. Means, //there is no difference in the returned value between a max-sized buffer and an error condition//. So here is a magic type which can store the value range of a ''size_t'' //and// a ''-1''. Sadly, it can’t, as you could easily determine with five lines of C code and a ''sizeof()'': ''ssize_t'' and ''size_t'' have the same size. Means, //there is no difference in the returned value between a max-sized buffer and an error condition//.
  
-We could discuss the probability now of someone wanting to write ''SIZE_MAX'' of data to a file handle at once. The point is, ''write()'' does //allow// to do so, without a note of warning that you will get a ''-1'' as return from the function no matter what. This might never lead to errors in the wild, which might be the reason why the POSIX people felt they could get away with it (”WONTFIX - works for me”). But proper domain testing //will// stumble over this. I can only assume the POSIX people have never heard of domain testing…+We could discuss the probability now of someone wanting to write ''SIZE_MAX'' of data to a file handle at once. The point is, ''write()'' does //allow// to do so, without a note of warning that you will get a ''-1'' as return from the function no matter what. This might never lead to errors in the wild, which might be the reason why the POSIX people felt they could get away with it (”WONTFIX - works for me”). But proper domain testing //will// stumble over this. I can only assume the POSIX people have never heard of domain testing
 + 
 +An ugly sideeffect of this is that comparing the return value of ''write()'' with ''count'' will give you a signedness mismatch warning. But I *know* that the POSIX people don't believe in compiler warnings
  
negix/writeandsizet.txt · Last modified: 2022/09/22 13:09 by solar