Skip to content

Commit 5d6ccf5

Browse files
Jason McMullanLinus Torvalds
authored andcommitted
[PATCH] Anal retentive 'const unsigned char *sha1'
Make 'sha1' parameters const where possible Signed-off-by: Jason McMullan <jason.mcmullan@timesys.com> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent e0f0e89 commit 5d6ccf5

File tree

14 files changed

+22
-22
lines changed

14 files changed

+22
-22
lines changed

blob.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
const char *blob_type = "blob";
66

7-
struct blob *lookup_blob(unsigned char *sha1)
7+
struct blob *lookup_blob(const unsigned char *sha1)
88
{
99
struct object *obj = lookup_object(sha1);
1010
if (!obj) {

blob.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ struct blob {
99
struct object object;
1010
};
1111

12-
struct blob *lookup_blob(unsigned char *sha1);
12+
struct blob *lookup_blob(const unsigned char *sha1);
1313

1414
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
1515

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ extern void * unpack_sha1_file(void *map, unsigned long mapsize, char *type, uns
167167
extern void * read_sha1_file(const unsigned char *sha1, char *type, unsigned long *size);
168168
extern int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
169169

170-
extern int check_sha1_signature(unsigned char *sha1, void *buf, unsigned long size, const char *type);
170+
extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
171171

172172
/* Read a tree into the cache */
173173
extern int read_tree(void *buffer, unsigned long size, int stage);

commit.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
const char *commit_type = "commit";
77

8-
static struct commit *check_commit(struct object *obj, unsigned char *sha1)
8+
static struct commit *check_commit(struct object *obj, const unsigned char *sha1)
99
{
1010
if (obj->type != commit_type) {
1111
error("Object %s is a %s, not a commit",
@@ -15,7 +15,7 @@ static struct commit *check_commit(struct object *obj, unsigned char *sha1)
1515
return (struct commit *) obj;
1616
}
1717

18-
struct commit *lookup_commit_reference(unsigned char *sha1)
18+
struct commit *lookup_commit_reference(const unsigned char *sha1)
1919
{
2020
struct object *obj = parse_object(sha1);
2121

@@ -26,7 +26,7 @@ struct commit *lookup_commit_reference(unsigned char *sha1)
2626
return check_commit(obj, sha1);
2727
}
2828

29-
struct commit *lookup_commit(unsigned char *sha1)
29+
struct commit *lookup_commit(const unsigned char *sha1)
3030
{
3131
struct object *obj = lookup_object(sha1);
3232
if (!obj) {

commit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ struct commit {
1919

2020
extern const char *commit_type;
2121

22-
struct commit *lookup_commit(unsigned char *sha1);
23-
struct commit *lookup_commit_reference(unsigned char *sha1);
22+
struct commit *lookup_commit(const unsigned char *sha1);
23+
struct commit *lookup_commit_reference(const unsigned char *sha1);
2424

2525
int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size);
2626

delta.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct delta {
1717
} u;
1818
};
1919

20-
struct delta *lookup_delta(unsigned char *sha1)
20+
struct delta *lookup_delta(const unsigned char *sha1)
2121
{
2222
struct object *obj = lookup_object(sha1);
2323
if (!obj) {

delta.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern void *patch_delta(void *src_buf, unsigned long src_size,
1212
/* handling of delta objects */
1313
struct delta;
1414
struct object_list;
15-
extern struct delta *lookup_delta(unsigned char *sha1);
15+
extern struct delta *lookup_delta(const unsigned char *sha1);
1616
extern int parse_delta_buffer(struct delta *item, void *buffer, unsigned long size);
1717
extern int parse_delta(struct delta *item, unsigned char sha1);
1818
extern int process_deltas(void *src, unsigned long src_size,

object.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct object **objs;
1010
int nr_objs;
1111
static int obj_allocs;
1212

13-
static int find_object(unsigned char *sha1)
13+
static int find_object(const unsigned char *sha1)
1414
{
1515
int first = 0, last = nr_objs;
1616

@@ -31,15 +31,15 @@ static int find_object(unsigned char *sha1)
3131
return -first-1;
3232
}
3333

34-
struct object *lookup_object(unsigned char *sha1)
34+
struct object *lookup_object(const unsigned char *sha1)
3535
{
3636
int pos = find_object(sha1);
3737
if (pos >= 0)
3838
return objs[pos];
3939
return NULL;
4040
}
4141

42-
void created_object(unsigned char *sha1, struct object *obj)
42+
void created_object(const unsigned char *sha1, struct object *obj)
4343
{
4444
int pos = find_object(sha1);
4545

@@ -98,7 +98,7 @@ void mark_reachable(struct object *obj, unsigned int mask)
9898
}
9999
}
100100

101-
struct object *parse_object(unsigned char *sha1)
101+
struct object *parse_object(const unsigned char *sha1)
102102
{
103103
unsigned long mapsize;
104104
void *map = map_sha1_file(sha1, &mapsize);

object.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ struct object {
2121
extern int nr_objs;
2222
extern struct object **objs;
2323

24-
struct object *lookup_object(unsigned char *sha1);
24+
struct object *lookup_object(const unsigned char *sha1);
2525

26-
void created_object(unsigned char *sha1, struct object *obj);
26+
void created_object(const unsigned char *sha1, struct object *obj);
2727

2828
/** Returns the object, having parsed it to find out what it is. **/
29-
struct object *parse_object(unsigned char *sha1);
29+
struct object *parse_object(const unsigned char *sha1);
3030

3131
void add_ref(struct object *refer, struct object *target);
3232

sha1_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static char *find_sha1_file(const unsigned char *sha1, struct stat *st)
266266
return NULL;
267267
}
268268

269-
int check_sha1_signature(unsigned char *sha1, void *map, unsigned long size, const char *type)
269+
int check_sha1_signature(const unsigned char *sha1, void *map, unsigned long size, const char *type)
270270
{
271271
char header[100];
272272
unsigned char real_sha1[20];

0 commit comments

Comments
 (0)