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

Re: [PATCH] This patch is to allow 12 different OS's to compile and run git.

From
BGBoyd Lynn Gerber <gerberb@zenez.com>
Date
Jun 6, 2008, 23:23 UTC
Message-ID
<Pine.LNX.4.64.0806061718420.18454@xenau.zenez.com>
In-Reply-To
<7vmylyrwkg.fsf@gitster.siamese.dyndns.org>
On Fri, 6 Jun 2008, Junio C Hamano wrote:
Show 22 quoted lines
> Boyd Lynn Gerber <gerberb@zenez.com> writes:
> > diff --git a/progress.c b/progress.c
> > index d19f80c..295c4e3 100644
> > --- a/progress.c
> > +++ b/progress.c
> > @@ -241,7 +241,8 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
> >  	*p_progress = NULL;
> >  	if (progress->last_value != -1) {
> >  		/* Force the last update */
> > -		char buf[strlen(msg) + 5];
> > +		/* char buf[strlen(msg) + 5]; */
> > +		char *buf = alloca (strlen(msg) + 5 );
> >  		struct throughput *tp = progress->throughput;
> >  		if (tp) {
> >  			unsigned int rate = !tp->avg_misecs ? 0 :
> 
> I do not know the situation over there these days, but I have a distant
> but bitter memory of having to deal with AIX X-<.  It insisted that
> inclusion of <alloca.h> to be the very first thing in the source before
> anything else.  I would want to keep alloca() out of the codebase without
> very good reason.  Not that I care much about portability to AIX, but not
> having to worry about alloca() unless necessary is a good thing.
You hit the nail on the head, AIX and any Novell derived Compiler code 
requires it.  Also the SCO OS's
 
Show 15 quoted lines
> I do not think progress_msg() is a good reason to even worrying about a
> dynamically sized array.  The function is designed to spit out a single
> line of message (so the incoming msg is expected to be shorter than 80
> chars or so).  If you "git grep stop_progress_msg", you will see that
> there are only two callers of this function, one in progress.c itself that
> says "done", and the other one in index-pack.c that gives a string
> formatted into 48-byte buffer.
> 
> So we can be lazy and say:
> 
> 	char buf[128];
>         ...
>         snprintf(buf, sizeof(buf), ", %s.\n", msg)
> 
> and be done with it.
I like the idea.
Show 37 quoted lines
> If you really wanted to be safe and anal, you could do something like
> this, which would be just as efficient and much more straightforward:
> 
>  progress.c |   11 ++++++++---
>  1 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/progress.c b/progress.c
> index d19f80c..55a8687 100644
> --- a/progress.c
> +++ b/progress.c
> @@ -241,16 +241,21 @@ void stop_progress_msg(struct progress **p_progress, const char *msg)
>  	*p_progress = NULL;
>  	if (progress->last_value != -1) {
>  		/* Force the last update */
> -		char buf[strlen(msg) + 5];
> +		char buf[128], *bufp;
> +		size_t len = strlen(msg) + 5;
>  		struct throughput *tp = progress->throughput;
> +
> +		bufp = (len < sizeof(buf)) ? buf : xmalloc(len + 1);
>  		if (tp) {
>  			unsigned int rate = !tp->avg_misecs ? 0 :
>  					tp->avg_bytes / tp->avg_misecs;
>  			throughput_string(tp, tp->curr_total, rate);
>  		}
>  		progress_update = 1;
> -		sprintf(buf, ", %s.\n", msg);
> -		display(progress, progress->last_value, buf);
> +		sprintf(bufp, ", %s.\n", msg);
> +		display(progress, progress->last_value, bufp);
> +		if (buf != bufp)
> +			free(bufp);
>  	}
>  	clear_progress_signal();
>  	free(progress->throughput);
> 
> 

Thanks for the suggestions. I am making changes based on all the feed back. I will remove all the debug junk from the final patch. I am putting options in and out a lot at the moment. Trying to make sure I do not break anything on the 12 OS's. It is a real pain testing all the changes on them to make sure I did not break anything.

Thanks,

-- Boyd Gerber <gerberb@zenez.com> ZENEZ 1042 East Fort Union #135, Midvale Utah 84047

Previous: Junio C HamanoNext: Boyd Lynn Gerber
Message 9 of 24 in “This patch is to allow 12 different OS's to compile and run git.”
  1. This patch is to allow 12 different OS's to compile and run git.Boyd Lynn Gerber, Jun 6, 2008
  2. Jeremy Maitin-ShepardJun 6, 2008
  3. Boyd Lynn GerberJun 6, 2008
  4. Stephan BeyerJun 6, 2008
  5. Linus TorvaldsJun 6, 2008
  6. Boyd Lynn GerberJun 6, 2008
  7. Brandon CaseyJun 6, 2008
  8. Junio C HamanoJun 6, 2008
  9. Boyd Lynn GerberJun 6, 2008
  10. Boyd Lynn GerberJun 7, 2008
  11. Daniel BarkalowJun 7, 2008
  12. Boyd Lynn GerberJun 7, 2008
  13. Junio C HamanoJun 7, 2008
  14. Boyd Lynn GerberJun 7, 2008
  15. Daniel BarkalowJun 7, 2008
  16. Boyd Lynn GerberJun 8, 2008
  17. Junio C HamanoJun 8, 2008
  18. progress.c: avoid use of dynamic-sized arrayBoyd Lynn Gerber, Jun 8, 2008
  19. Port to 12 other Platforms.Boyd Lynn Gerber, Jun 8, 2008
  20. Boyd Lynn GerberJun 8, 2008
  21. Boyd Lynn GerberJun 8, 2008
  22. Thomas HarningJun 6, 2008
  23. Daniel BarkalowJun 6, 2008
  24. Boyd Lynn GerberJun 6, 2008

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.