git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Soria Parra <sn_@gmx.net>
To: git@vger.kernel.org
Cc: David Soria Parra <dsp@php.net>
Subject: [PATCH 1/2] Improvate portability: Display pid_t's always as long
Date: Wed, 27 Aug 2008 19:39:02 +0200	[thread overview]
Message-ID: <1219858743-4476-2-git-send-email-sn_@gmx.net> (raw)
In-Reply-To: <1219858743-4476-1-git-send-email-sn_@gmx.net>

From: David Soria Parra <dsp@php.net>

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.

Signed-off-by: David Soria Parra <dsp@php.net>
---
 builtin-commit.c     |    2 +-
 builtin-fetch-pack.c |    2 +-
 daemon.c             |    2 +-
 fast-import.c        |    6 +++---
 receive-pack.c       |    2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index 649c8be..b4c940f 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -320,7 +320,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix)
 		die("unable to write new_index file");
 
 	fd = hold_lock_file_for_update(&false_lock,
-				       git_path("next-index-%d", getpid()), 1);
+				       git_path("next-index-%ld", (long) getpid()), 1);
 
 	create_base_index();
 	add_remove_files(&partial);
diff --git a/builtin-fetch-pack.c b/builtin-fetch-pack.c
index 273239a..46bb3e2 100644
--- a/builtin-fetch-pack.c
+++ b/builtin-fetch-pack.c
@@ -540,7 +540,7 @@ static int get_pack(int xd[2], char **pack_lockfile)
 			*av++ = "--fix-thin";
 		if (args.lock_pack || unpack_limit) {
 			int s = sprintf(keep_arg,
-					"--keep=fetch-pack %d on ", getpid());
+					"--keep=fetch-pack %ld on ", (long) getpid());
 			if (gethostname(keep_arg + s, sizeof(keep_arg) - s))
 				strcpy(keep_arg + s, "localhost");
 			*av++ = keep_arg;
diff --git a/daemon.c b/daemon.c
index 23278e2..1e5cb58 100644
--- a/daemon.c
+++ b/daemon.c
@@ -923,7 +923,7 @@ static void store_pid(const char *path)
 	FILE *f = fopen(path, "w");
 	if (!f)
 		die("cannot open pid file %s: %s", path, strerror(errno));
-	if (fprintf(f, "%d\n", getpid()) < 0 || fclose(f) != 0)
+	if (fprintf(f, "%ld\n", (long) getpid()) < 0 || fclose(f) != 0)
 		die("failed to write pid file %s: %s", path, strerror(errno));
 }
 
diff --git a/fast-import.c b/fast-import.c
index 7089e6f..e04ed94 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -376,7 +376,7 @@ static void dump_marks_helper(FILE *, uintmax_t, struct mark_set *);
 
 static void write_crash_report(const char *err)
 {
-	char *loc = git_path("fast_import_crash_%d", getpid());
+	char *loc = git_path("fast_import_crash_%ld", (long) getpid());
 	FILE *rpt = fopen(loc, "w");
 	struct branch *b;
 	unsigned long lu;
@@ -390,8 +390,8 @@ static void write_crash_report(const char *err)
 	fprintf(stderr, "fast-import: dumping crash report to %s\n", loc);
 
 	fprintf(rpt, "fast-import crash report:\n");
-	fprintf(rpt, "    fast-import process: %d\n", getpid());
-	fprintf(rpt, "    parent process     : %d\n", getppid());
+	fprintf(rpt, "    fast-import process: %ld\n", (long) getpid());
+	fprintf(rpt, "    parent process     : %ld\n", (long) getppid());
 	fprintf(rpt, "    at %s\n", show_date(time(NULL), 0, DATE_LOCAL));
 	fputc('\n', rpt);
 
diff --git a/receive-pack.c b/receive-pack.c
index d44c19e..0a82f73 100644
--- a/receive-pack.c
+++ b/receive-pack.c
@@ -407,7 +407,7 @@ static const char *unpack(void)
 		char keep_arg[256];
 		struct child_process ip;
 
-		s = sprintf(keep_arg, "--keep=receive-pack %i on ", getpid());
+		s = sprintf(keep_arg, "--keep=receive-pack %li on ", (long) getpid());
 		if (gethostname(keep_arg + s, sizeof(keep_arg) - s))
 			strcpy(keep_arg + s, "localhost");
 
-- 
1.6.0.174.gd789c

  reply	other threads:[~2008-08-27 17:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-27 17:39 [PATCH 0/2] Improve portability for OpenSolaris David Soria Parra
2008-08-27 17:39 ` David Soria Parra [this message]
2008-08-27 17:39   ` [PATCH 2/2] Improve portability: Avoid SS constant as it is already defined David Soria Parra
2008-08-27 18:56     ` Junio C Hamano
2008-08-27 19:17       ` Junio C Hamano
2008-08-28  0:34         ` David Soria Parra
2008-08-27 19:03   ` [PATCH 1/2] Improvate portability: Display pid_t's always as long Junio C Hamano
2008-08-30 20:40     ` David Soria Parra
2008-08-31  7:15       ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1219858743-4476-2-git-send-email-sn_@gmx.net \
    --to=sn_@gmx.net \
    --cc=dsp@php.net \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).