Browse Source

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 <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Ævar Arnfjörð Bjarmason 13 years ago committed by Junio C Hamano
parent
commit
ab1900a36e
  1. 6
      builtin/index-pack.c
  2. 8
      fast-import.c
  3. 6
      pack-write.c
  4. 12
      sha1_file.c

6
builtin/index-pack.c

@ -172,10 +172,10 @@ static const char *open_pack_file(const char *pack_name)
if (from_stdin) { if (from_stdin) {
input_fd = 0; input_fd = 0;
if (!pack_name) { if (!pack_name) {
static char tmpfile[PATH_MAX]; static char tmp_file[PATH_MAX];
output_fd = odb_mkstemp(tmpfile, sizeof(tmpfile), output_fd = odb_mkstemp(tmp_file, sizeof(tmp_file),
"pack/tmp_pack_XXXXXX"); "pack/tmp_pack_XXXXXX");
pack_name = xstrdup(tmpfile); pack_name = xstrdup(tmp_file);
} else } else
output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600); output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);
if (output_fd < 0) if (output_fd < 0)

8
fast-import.c

@ -855,15 +855,15 @@ static struct tree_content *dup_tree_content(struct tree_content *s)


static void start_packfile(void) static void start_packfile(void)
{ {
static char tmpfile[PATH_MAX]; static char tmp_file[PATH_MAX];
struct packed_git *p; struct packed_git *p;
struct pack_header hdr; struct pack_header hdr;
int pack_fd; int pack_fd;


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

6
pack-write.c

@ -73,9 +73,9 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
f = sha1fd_check(index_name); f = sha1fd_check(index_name);
} else { } else {
if (!index_name) { if (!index_name) {
static char tmpfile[PATH_MAX]; static char tmp_file[PATH_MAX];
fd = odb_mkstemp(tmpfile, sizeof(tmpfile), "pack/tmp_idx_XXXXXX"); fd = odb_mkstemp(tmp_file, sizeof(tmp_file), "pack/tmp_idx_XXXXXX");
index_name = xstrdup(tmpfile); index_name = xstrdup(tmp_file);
} else { } else {
unlink(index_name); unlink(index_name);
fd = open(index_name, O_CREAT|O_EXCL|O_WRONLY, 0600); fd = open(index_name, O_CREAT|O_EXCL|O_WRONLY, 0600);

12
sha1_file.c

@ -2452,15 +2452,15 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
git_SHA_CTX c; git_SHA_CTX c;
unsigned char parano_sha1[20]; unsigned char parano_sha1[20];
char *filename; char *filename;
static char tmpfile[PATH_MAX]; static char tmp_file[PATH_MAX];


filename = sha1_file_name(sha1); filename = sha1_file_name(sha1);
fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename); fd = create_tmpfile(tmp_file, sizeof(tmp_file), filename);
if (fd < 0) { if (fd < 0) {
if (errno == EACCES) if (errno == EACCES)
return error("insufficient permission for adding an object to repository database %s\n", get_object_directory()); return error("insufficient permission for adding an object to repository database %s\n", get_object_directory());
else else
return error("unable to create temporary sha1 filename %s: %s\n", tmpfile, strerror(errno)); return error("unable to create temporary sha1 filename %s: %s\n", tmp_file, strerror(errno));
} }


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


return move_temp_to_file(tmpfile, filename); return move_temp_to_file(tmp_file, filename);
} }


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

Loading…
Cancel
Save