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

Re: [PATCH] Limit filename for format-patch

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
Feb 23, 2007, 21:39 UTC
Message-ID
<200702232239.19504.robin.rosenberg@dewire.com>
In-Reply-To
<Pine.LNX.4.63.0702230143370.22628@wbgn013.biozentrum.uni-wuerzburg.de>
fredag 23 februari 2007 01:49 skrev Johannes Schindelin:
Show 12 quoted lines
> Hi,
> 
> I agree that your patch fixes a long-time issue.
> 
> On Fri, 23 Feb 2007, Robin Rosenberg wrote:
> 
> > +		if (strlen(output_directory) > sizeof filename - suffix_len)
> 
> I know that "sizeof filename" works, but in git.git, `git grep sizeof' 
> returns > 700 instances, only 23 of which do not use the 
> "sizeof(filename)" form. It's just a style issue, but I prefer the latter 
> nevertheless...
Actually there are (only) about 500 of them that are not the sizeof(type) kind.

I prefer not to use extra parentheses except for grouping complex expressions for readability.

Show 16 quoted lines
> >  		for (j = 0;
> 
> Does this:
> 
> > +		     j< 64-suffix_len-5 && 
> >  		     len < sizeof(filename) - suffix_len &&
> >  			     sol[j] && sol[j] != '\n';
> >  		     j++) {
> 
> not make this:
> 
> > +	if (len + strlen(fmt_patch_suffix) >= sizeof filename)
> > +		return error("Patch pathname too long");
> 
> unnecessary for the case that there _was_ an output directory specified? 
> I'd make that an "else if"... But I might be missing something.

The last statement errs out if the total length is too long which is a different issue than truncating the patch name. There is no reason to two paths when one does perfectly well. But I could replace strlen there.

-- robin
Previous: Johannes SchindelinNext: Robin Rosenberg
Message 3 of 9 in “Limit filename for format-patch”
  1. Limit filename for format-patchRobin Rosenberg, Feb 23, 2007
  2. Johannes SchindelinFeb 23, 2007
  3. Robin RosenbergFeb 23, 2007
  4. Limit filename for format-patchRobin Rosenberg, Feb 23, 2007
  5. Limit filename for format-patchRobin Rosenberg, Feb 23, 2007
  6. Johannes SchindelinFeb 24, 2007
  7. Junio C HamanoFeb 24, 2007
  8. Junio C HamanoFeb 24, 2007
  9. Robin RosenbergFeb 24, 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.