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

Re: [PATCH 1/2] Improvate portability: Display pid_t's always as long

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 27, 2008, 19:03 UTC
Message-ID
<7vsksqp9f1.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1219858743-4476-2-git-send-email-sn_@gmx.net>
David Soria Parra <sn_@gmx.net> writes:
> Some systems (like e.g. OpenSolaris) define pid_t as long,
> therefore all our sprintf that use %i cause a compiler warning
> beacuse if the implicit long->int cast. So to make sure that
> we fit the limits we display pids as longs and cast them explicitly.

This patch just makes one wonder what needs to happen when the next random platform has pid_t as long long or int32_t or whatever signed integral type that was picked arbitrarily by the platform.

I think these *printf()s are mostly for informational purposes and if you favor minimum change, you might be better off casting it to "int" without changing the format specifiers.

On the other hand, if you are shooting for maximum compatibility perhaps you may want to cast it to "intmax_t" and format as such.

Casting to "long" does not make much sense from either perspective, does it?

Previous: David Soria ParraNext: David Soria Parra
Message 7 of 9 in “Improve portability for OpenSolaris”
  1. 0/2 Improve portability for OpenSolarisDavid Soria Parra, Aug 27, 2008
  2. 1/2 Improvate portability: Display pid_t's always as longDavid Soria Parra, Aug 27, 2008
  3. 2/2 Improve portability: Avoid SS constant as it is already definedDavid Soria Parra, Aug 27, 2008
  4. Junio C HamanoAug 27, 2008
  5. Junio C HamanoAug 27, 2008
  6. David Soria ParraAug 28, 2008
  7. Junio C HamanoAug 27, 2008
  8. David Soria ParraAug 30, 2008
  9. Junio C HamanoAug 31, 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.