git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Type mismatches in safe_read and friends?

From
RDRogan Dawes <lists@dawes.za.net>
Date
Mar 27, 2007, 10:34 UTC
Message-ID
<4608F31B.8070204@dawes.za.net>
In-Reply-To
<20070326164755.GH13247@spearce.org>
Shawn O. Pearce wrote:
Show 9 quoted lines
>  
>> Or is it just a case that we don't really care, since we control the 
>> ranges of the values, and the underlying types are int anyway? Patches 
>> to follow if I get an indication that anyone cares, otherwise I'd be 
>> posting my question to a C newbies group. ;-)
> 
> It is sort of a case we don't care.  These probably should be fixed.
> A patch would be nice.  You want to learn C...  ;-)
> 

Ok. So I did a little patch, but I'm not sure whether I solved anything. Now we have an implicit cast from size_t to ssize_t in packet_read_line.

I guess this echoes your comment about requesting a large size_t, and getting a ssize_t result back. I suppose in theory we should be refusing to handle a length greater than that which would fit into a ssize_t? Or simply making sure to always return data smaller than max(ssize_t)?

Patch to follow.
Rogan
Previous: Shawn O. Pearce
Message 3 of 3 in “Type mismatches in safe_read and friends?”
  1. Rogan DawesMar 26, 2007
  2. Shawn O. PearceMar 26, 2007
  3. Rogan DawesMar 27, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.