summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7ba502c)
raw | patch | inline | side by side (parent: 7ba502c)
author | Nicolas Pitre <nico@cam.org> | |
Wed, 17 Oct 2007 01:55:49 +0000 (21:55 -0400) | ||
committer | Shawn O. Pearce <spearce@spearce.org> | |
Wed, 17 Oct 2007 06:54:57 +0000 (02:54 -0400) |
Two functions, namely write_idx_file() and open_pack_file(), currently
return a const pointer. However that pointer is either a copy of the
first argument, or set to a malloc'd buffer when that first argument
is null. In the later case it is wrong to qualify that pointer as const
since ownership of the buffer is transferred to the caller to dispose of,
and obviously the free() function is not meant to be passed const
pointers.
Making the return pointer not const causes a warning when the first
argument is returned since that argument is also marked const.
The correct thing to do is therefore to remove the const qualifiers,
avoiding the need for ugly casts only to silence some warnings.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
return a const pointer. However that pointer is either a copy of the
first argument, or set to a malloc'd buffer when that first argument
is null. In the later case it is wrong to qualify that pointer as const
since ownership of the buffer is transferred to the caller to dispose of,
and obviously the free() function is not meant to be passed const
pointers.
Making the return pointer not const causes a warning when the first
argument is returned since that argument is also marked const.
The correct thing to do is therefore to remove the const qualifiers,
avoiding the need for ugly casts only to silence some warnings.
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
builtin-pack-objects.c | patch | blob | history | |
index-pack.c | patch | blob | history | |
pack-write.c | patch | blob | history | |
pack.h | patch | blob | history |
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 933c2526f88375700b8f2e2d1c806e8d9414121a..15d375061642d816c83a5d18daad20ee98dc0354 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
umask(mode);
mode = 0444 & ~mode;
- idx_tmp_name = (char *) write_idx_file(NULL,
+ idx_tmp_name = write_idx_file(NULL,
(struct pack_idx_entry **) written_list,
nr_written, sha1);
snprintf(tmpname, sizeof(tmpname), "%s-%s.pack",
diff --git a/index-pack.c b/index-pack.c
index c784decd2493a464db3a490664dcf7c0ce959a43..60173d51925dd67d0816eb821c9600e02d3c232c 100644 (file)
--- a/index-pack.c
+++ b/index-pack.c
consumed_bytes += bytes;
}
-static const char *open_pack_file(const char *pack_name)
+static char *open_pack_file(char *pack_name)
{
if (from_stdin) {
input_fd = 0;
int main(int argc, char **argv)
{
int i, fix_thin_pack = 0;
- const char *curr_pack, *pack_name = NULL;
- const char *curr_index, *index_name = NULL;
+ char *curr_pack, *pack_name = NULL;
+ char *curr_index, *index_name = NULL;
const char *keep_name = NULL, *keep_msg = NULL;
char *index_name_buf = NULL, *keep_name_buf = NULL;
struct pack_idx_entry **idx_objects;
unsigned char sha1[20];
for (i = 1; i < argc; i++) {
- const char *arg = argv[i];
+ char *arg = argv[i];
if (*arg == '-') {
if (!strcmp(arg, "--stdin")) {
diff --git a/pack-write.c b/pack-write.c
index e59b197e5ebb301107f9a18b7765e18097a1c8e3..d1ed3abe21502464ca0ec6b90c1b3272e3db6176 100644 (file)
--- a/pack-write.c
+++ b/pack-write.c
* the SHA1 hash of sorted object names. The objects array passed in
* will be sorted by SHA1 on exit.
*/
-const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1)
+char *write_idx_file(char *index_name, struct pack_idx_entry **objects,
+ int nr_objects, unsigned char *sha1)
{
struct sha1file *f;
struct pack_idx_entry **sorted_by_sha, **list, **last;
index f357c9f4282d5bc8bbcff6f3a44b9812415745a6..cab4aa8381a83980558d8e26f0b3ce06746d8962 100644 (file)
--- a/pack.h
+++ b/pack.h
off_t offset;
};
-extern const char *write_idx_file(const char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1);
+extern char *write_idx_file(char *index_name, struct pack_idx_entry **objects, int nr_objects, unsigned char *sha1);
extern int verify_pack(struct packed_git *, int);
extern void fixup_pack_header_footer(int, unsigned char *, const char *, uint32_t);