@matheusbsbs / matheus-bagliano / commits / bd22c904a0
Fork 0

Fix sparse warnings

Make some functions static and convert func() function prototypes to to func(void). Fix declaration after statement, missing declaration and redundant declaration warnings. Signed-off-by: Timo Hirvonen <tihirvon@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Timo Hirvonen committed Nov 21, 2005 at 02:52 UTC bd22c904a0f1c88a3a7bfa96bbf690de2f5cb278
4 files changed +31 -32
cache.h
+1
@@ -203,6 +203,7 @@ int git_mkstemp(char *path, size_t n, const char *template);
203
204 int safe_create_leading_directories(char *path);
205 char *safe_strncpy(char *, const char *, size_t);
206 +char *enter_repo(char *path, int strict);
207
208 /* Read and unpack a sha1 file into memory, write memory to a sha1 file */
209 extern int unpack_sha1_header(z_stream *stream, void *map, unsigned long mapsize, void *buffer, unsigned long size);
name-rev.c
-2
@@ -230,8 +230,6 @@ int main(int argc, char **argv)
230 fwrite(p_start, p - p_start, 1, stdout);
231 }
232 } else if (all) {
233 - extern struct object **objs;
234 - extern int nr_objs;
233 int i;
234
235 for (i = 0; i < nr_objs; i++)
pack-redundant.c
+29 -29
@@ -11,19 +11,19 @@
11 static const char pack_redundant_usage[] =
12 "git-pack-redundant [ --verbose ] [ --alt-odb ] < --all | <.pack filename> ...>";
13
14 -int load_all_packs = 0, verbose = 0, alt_odb = 0;
14 +static int load_all_packs = 0, verbose = 0, alt_odb = 0;
15
16 struct llist_item {
17 struct llist_item *next;
18 char *sha1;
19 };
20 -struct llist {
20 +static struct llist {
21 struct llist_item *front;
22 struct llist_item *back;
23 size_t size;
24 } *all_objects; /* all objects which must be present in local packfiles */
25
26 -struct pack_list {
26 +static struct pack_list {
27 struct pack_list *next;
28 struct packed_git *pack;
29 struct llist *unique_objects;
@@ -36,7 +36,7 @@ struct pll {
36 size_t pl_size;
37 };
38
39 -inline void llist_free(struct llist *list)
39 +static inline void llist_free(struct llist *list)
40 {
41 while((list->back = list->front)) {
42 list->front = list->front->next;
@@ -45,14 +45,14 @@ inline void llist_free(struct llist *list)
45 free(list);
46 }
47
48 -inline void llist_init(struct llist **list)
48 +static inline void llist_init(struct llist **list)
49 {
50 *list = xmalloc(sizeof(struct llist));
51 (*list)->front = (*list)->back = NULL;
52 (*list)->size = 0;
53 }
54
55 -struct llist * llist_copy(struct llist *list)
55 +static struct llist * llist_copy(struct llist *list)
56 {
57 struct llist *ret;
58 struct llist_item *new, *old, *prev;
@@ -79,7 +79,7 @@ struct llist * llist_copy(struct llist *list)
79 return ret;
80 }
81
82 -inline struct llist_item * llist_insert(struct llist *list,
82 +static inline struct llist_item * llist_insert(struct llist *list,
83 struct llist_item *after, char *sha1)
84 {
85 struct llist_item *new = xmalloc(sizeof(struct llist_item));
@@ -102,12 +102,12 @@ inline struct llist_item * llist_insert(struct llist *list,
102 return new;
103 }
104
105 -inline struct llist_item * llist_insert_back(struct llist *list, char *sha1)
105 +static inline struct llist_item * llist_insert_back(struct llist *list, char *sha1)
106 {
107 return llist_insert(list, list->back, sha1);
108 }
109
110 -inline struct llist_item * llist_insert_sorted_unique(struct llist *list,
110 +static inline struct llist_item * llist_insert_sorted_unique(struct llist *list,
111 char *sha1, struct llist_item *hint)
112 {
113 struct llist_item *prev = NULL, *l;
@@ -129,7 +129,7 @@ inline struct llist_item * llist_insert_sorted_unique(struct llist *list,
129 }
130
131 /* returns a pointer to an item in front of sha1 */
132 -inline struct llist_item * llist_sorted_remove(struct llist *list, char *sha1,
132 +static inline struct llist_item * llist_sorted_remove(struct llist *list, char *sha1,
133 struct llist_item *hint)
134 {
135 struct llist_item *prev, *l;
@@ -164,7 +164,7 @@ redo_from_start:
164 }
165
166 /* computes A\B */
167 -void llist_sorted_difference_inplace(struct llist *A,
167 +static void llist_sorted_difference_inplace(struct llist *A,
168 struct llist *B)
169 {
170 struct llist_item *hint, *b;
@@ -178,7 +178,7 @@ void llist_sorted_difference_inplace(struct llist *A,
178 }
179 }
180
181 -inline struct pack_list * pack_list_insert(struct pack_list **pl,
181 +static inline struct pack_list * pack_list_insert(struct pack_list **pl,
182 struct pack_list *entry)
183 {
184 struct pack_list *p = xmalloc(sizeof(struct pack_list));
@@ -188,7 +188,7 @@ inline struct pack_list * pack_list_insert(struct pack_list **pl,
188 return p;
189 }
190
191 -inline size_t pack_list_size(struct pack_list *pl)
191 +static inline size_t pack_list_size(struct pack_list *pl)
192 {
193 size_t ret = 0;
194 while(pl) {
@@ -198,7 +198,7 @@ inline size_t pack_list_size(struct pack_list *pl)
198 return ret;
199 }
200
201 -struct pack_list * pack_list_difference(struct pack_list *A,
201 +static struct pack_list * pack_list_difference(struct pack_list *A,
202 struct pack_list *B)
203 {
204 struct pack_list *ret, *pl;
@@ -218,7 +218,7 @@ struct pack_list * pack_list_difference(struct pack_list *A,
218 return ret;
219 }
220
221 -void cmp_two_packs(struct pack_list *p1, struct pack_list *p2)
221 +static void cmp_two_packs(struct pack_list *p1, struct pack_list *p2)
222 {
223 int p1_off, p2_off;
224 void *p1_base, *p2_base;
@@ -250,7 +250,7 @@ void cmp_two_packs(struct pack_list *p1, struct pack_list *p2)
250 }
251 }
252
253 -void pll_insert(struct pll **pll, struct pll **hint_table)
253 +static void pll_insert(struct pll **pll, struct pll **hint_table)
254 {
255 struct pll *prev;
256 int i = (*pll)->pl_size - 1;
@@ -276,7 +276,7 @@ void pll_insert(struct pll **pll, struct pll **hint_table)
276 /* all the permutations have to be free()d at the same time,
277 * since they refer to each other
278 */
279 -struct pll * get_all_permutations(struct pack_list *list)
279 +static struct pll * get_all_permutations(struct pack_list *list)
280 {
281 struct pll *subset, *pll, *new_pll = NULL; /*silence warning*/
282 static struct pll **hint = NULL;
@@ -323,7 +323,7 @@ struct pll * get_all_permutations(struct pack_list *list)
323 return hint[0];
324 }
325
326 -int is_superset(struct pack_list *pl, struct llist *list)
326 +static int is_superset(struct pack_list *pl, struct llist *list)
327 {
328 struct llist *diff;
329
@@ -342,7 +342,7 @@ int is_superset(struct pack_list *pl, struct llist *list)
342 return 0;
343 }
344
345 -size_t sizeof_union(struct packed_git *p1, struct packed_git *p2)
345 +static size_t sizeof_union(struct packed_git *p1, struct packed_git *p2)
346 {
347 size_t ret = 0;
348 int p1_off, p2_off;
@@ -373,14 +373,14 @@ size_t sizeof_union(struct packed_git *p1, struct packed_git *p2)
373 }
374
375 /* another O(n^2) function ... */
376 -size_t get_pack_redundancy(struct pack_list *pl)
376 +static size_t get_pack_redundancy(struct pack_list *pl)
377 {
378 struct pack_list *subset;
379 + size_t ret = 0;
380
381 if (pl == NULL)
382 return 0;
383
383 - size_t ret = 0;
384 while ((subset = pl->next)) {
385 while(subset) {
386 ret += sizeof_union(pl->pack, subset->pack);
@@ -391,7 +391,7 @@ size_t get_pack_redundancy(struct pack_list *pl)
391 return ret;
392 }
393
394 -inline size_t pack_set_bytecount(struct pack_list *pl)
394 +static inline size_t pack_set_bytecount(struct pack_list *pl)
395 {
396 size_t ret = 0;
397 while (pl) {
@@ -402,7 +402,7 @@ inline size_t pack_set_bytecount(struct pack_list *pl)
402 return ret;
403 }
404
405 -void minimize(struct pack_list **min)
405 +static void minimize(struct pack_list **min)
406 {
407 struct pack_list *pl, *unique = NULL,
408 *non_unique = NULL, *min_perm = NULL;
@@ -469,7 +469,7 @@ void minimize(struct pack_list **min)
469 }
470 }
471
472 -void load_all_objects()
472 +static void load_all_objects(void)
473 {
474 struct pack_list *pl = local_packs;
475 struct llist_item *hint, *l;
@@ -497,7 +497,7 @@ void load_all_objects()
497 }
498
499 /* this scales like O(n^2) */
500 -void cmp_local_packs()
500 +static void cmp_local_packs(void)
501 {
502 struct pack_list *subset, *pl = local_packs;
503
@@ -508,7 +508,7 @@ void cmp_local_packs()
508 }
509 }
510
511 -void scan_alt_odb_packs()
511 +static void scan_alt_odb_packs(void)
512 {
513 struct pack_list *local, *alt;
514
@@ -524,7 +524,7 @@ void scan_alt_odb_packs()
524 }
525 }
526
527 -struct pack_list * add_pack(struct packed_git *p)
527 +static struct pack_list * add_pack(struct packed_git *p)
528 {
529 struct pack_list l;
530 size_t off;
@@ -550,7 +550,7 @@ struct pack_list * add_pack(struct packed_git *p)
550 return pack_list_insert(&altodb_packs, &l);
551 }
552
553 -struct pack_list * add_pack_file(char *filename)
553 +static struct pack_list * add_pack_file(char *filename)
554 {
555 struct packed_git *p = packed_git;
556
@@ -565,7 +565,7 @@ struct pack_list * add_pack_file(char *filename)
565 die("Filename %s not found in packed_git\n", filename);
566 }
567
568 -void load_all()
568 +static void load_all(void)
569 {
570 struct packed_git *p = packed_git;
571
path.c
+1 -1
@@ -131,7 +131,7 @@ int validate_symref(const char *path)
131 return -1;
132 }
133
134 -static char *current_dir()
134 +static char *current_dir(void)
135 {
136 return getcwd(pathname, sizeof(pathname));
137 }