Skip to content

Commit ab1900a

Browse files
avargitster
authored andcommitted
Appease Sun Studio by renaming "tmpfile"
On Solaris the system headers define the "tmpfile" name, which'll cause Git compiled with Sun Studio 12 Update 1 to whine about us redefining the name: "pack-write.c", line 76: warning: name redefined by pragma redefine_extname declared static: tmpfile (E_PRAGMA_REDEFINE_STATIC) "sha1_file.c", line 2455: warning: name redefined by pragma redefine_extname declared static: tmpfile (E_PRAGMA_REDEFINE_STATIC) "fast-import.c", line 858: warning: name redefined by pragma redefine_extname declared static: tmpfile (E_PRAGMA_REDEFINE_STATIC) "builtin/index-pack.c", line 175: warning: name redefined by pragma redefine_extname declared static: tmpfile (E_PRAGMA_REDEFINE_STATIC) Just renaming the "tmpfile" variable to "tmp_file" in the relevant places is the easiest way to fix this. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 952fba9 commit ab1900a

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

builtin/index-pack.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ static const char *open_pack_file(const char *pack_name)
172172
if (from_stdin) {
173173
input_fd = 0;
174174
if (!pack_name) {
175-
static char tmpfile[PATH_MAX];
176-
output_fd = odb_mkstemp(tmpfile, sizeof(tmpfile),
175+
static char tmp_file[PATH_MAX];
176+
output_fd = odb_mkstemp(tmp_file, sizeof(tmp_file),
177177
"pack/tmp_pack_XXXXXX");
178-
pack_name = xstrdup(tmpfile);
178+
pack_name = xstrdup(tmp_file);
179179
} else
180180
output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);
181181
if (output_fd < 0)

fast-import.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -855,15 +855,15 @@ static struct tree_content *dup_tree_content(struct tree_content *s)
855855

856856
static void start_packfile(void)
857857
{
858-
static char tmpfile[PATH_MAX];
858+
static char tmp_file[PATH_MAX];
859859
struct packed_git *p;
860860
struct pack_header hdr;
861861
int pack_fd;
862862

863-
pack_fd = odb_mkstemp(tmpfile, sizeof(tmpfile),
863+
pack_fd = odb_mkstemp(tmp_file, sizeof(tmp_file),
864864
"pack/tmp_pack_XXXXXX");
865-
p = xcalloc(1, sizeof(*p) + strlen(tmpfile) + 2);
866-
strcpy(p->pack_name, tmpfile);
865+
p = xcalloc(1, sizeof(*p) + strlen(tmp_file) + 2);
866+
strcpy(p->pack_name, tmp_file);
867867
p->pack_fd = pack_fd;
868868
p->do_not_close = 1;
869869
pack_file = sha1fd(pack_fd, p->pack_name);

pack-write.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
7373
f = sha1fd_check(index_name);
7474
} else {
7575
if (!index_name) {
76-
static char tmpfile[PATH_MAX];
77-
fd = odb_mkstemp(tmpfile, sizeof(tmpfile), "pack/tmp_idx_XXXXXX");
78-
index_name = xstrdup(tmpfile);
76+
static char tmp_file[PATH_MAX];
77+
fd = odb_mkstemp(tmp_file, sizeof(tmp_file), "pack/tmp_idx_XXXXXX");
78+
index_name = xstrdup(tmp_file);
7979
} else {
8080
unlink(index_name);
8181
fd = open(index_name, O_CREAT|O_EXCL|O_WRONLY, 0600);

sha1_file.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,15 +2452,15 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
24522452
git_SHA_CTX c;
24532453
unsigned char parano_sha1[20];
24542454
char *filename;
2455-
static char tmpfile[PATH_MAX];
2455+
static char tmp_file[PATH_MAX];
24562456

24572457
filename = sha1_file_name(sha1);
2458-
fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
2458+
fd = create_tmpfile(tmp_file, sizeof(tmp_file), filename);
24592459
if (fd < 0) {
24602460
if (errno == EACCES)
24612461
return error("insufficient permission for adding an object to repository database %s\n", get_object_directory());
24622462
else
2463-
return error("unable to create temporary sha1 filename %s: %s\n", tmpfile, strerror(errno));
2463+
return error("unable to create temporary sha1 filename %s: %s\n", tmp_file, strerror(errno));
24642464
}
24652465

24662466
/* Set it up */
@@ -2505,12 +2505,12 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
25052505
struct utimbuf utb;
25062506
utb.actime = mtime;
25072507
utb.modtime = mtime;
2508-
if (utime(tmpfile, &utb) < 0)
2508+
if (utime(tmp_file, &utb) < 0)
25092509
warning("failed utime() on %s: %s",
2510-
tmpfile, strerror(errno));
2510+
tmp_file, strerror(errno));
25112511
}
25122512

2513-
return move_temp_to_file(tmpfile, filename);
2513+
return move_temp_to_file(tmp_file, filename);
25142514
}
25152515

25162516
int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *returnsha1)

0 commit comments

Comments
 (0)