update ipkg patch to v1.99.154,
[openwrt.git] / openwrt / package / busybox / patches / 912-ipkg-no_warnings.patch
1 diff -ruN busybox-1.00-old/archival/libipkg/file_util.c busybox-1.00-new/archival/libipkg/file_util.c
2 --- busybox-1.00-old/archival/libipkg/file_util.c       2005-10-27 16:37:25.000000000 +0200
3 +++ busybox-1.00-new/archival/libipkg/file_util.c       2005-10-27 16:38:03.000000000 +0200
4 @@ -123,7 +123,7 @@
5  
6  int file_mkdir_hier(const char *path, long mode)
7  {
8 -    return bb_make_directory(path, mode, FILEUTILS_RECUR);
9 +    return bb_make_directory((char *)path, mode, FILEUTILS_RECUR);
10  }
11  
12  char *file_md5sum_alloc(const char *file_name)
13 diff -ruN busybox-1.00-old/archival/libipkg/ipkg_cmd.c busybox-1.00-new/archival/libipkg/ipkg_cmd.c
14 --- busybox-1.00-old/archival/libipkg/ipkg_cmd.c        2005-10-27 16:37:25.000000000 +0200
15 +++ busybox-1.00-new/archival/libipkg/ipkg_cmd.c        2005-10-27 16:38:03.000000000 +0200
16 @@ -251,7 +251,7 @@
17                    in = fopen (tmp_file_name, "r");
18                    out = fopen (list_file_name, "w");
19                    if (in && out)
20 -                       inflate_unzip (in, out);
21 +                       inflate_unzip (fileno(in), fileno(out));
22                    else
23                         err = 1;
24                    if (in)
25 @@ -807,14 +807,13 @@
26          pkg_vec_free(available);
27       } else {
28           pkg_vec_t *installed_pkgs = pkg_vec_alloc();
29 -         int i;
30           int flagged_pkg_count = 0;
31           int removed;
32  
33           pkg_hash_fetch_all_installed(&conf->pkg_hash, installed_pkgs);
34  
35           for (i = 0; i < installed_pkgs->len; i++) {
36 -              pkg_t *pkg = installed_pkgs->pkgs[i];
37 +              pkg = installed_pkgs->pkgs[i];
38                if (pkg->state_flag & SF_USER) {
39                     flagged_pkg_count++;
40                } else {
41 @@ -834,7 +833,7 @@
42           do {
43                removed = 0;
44                for (i = 0; i < installed_pkgs->len; i++) {
45 -                   pkg_t *pkg = installed_pkgs->pkgs[i];
46 +                   pkg = installed_pkgs->pkgs[i];
47                     if (!(pkg->state_flag & SF_USER)
48                         && !pkg_has_installed_dependents(conf, pkg->parent, pkg, NULL)) {
49                          removed++;
50 @@ -889,7 +888,7 @@
51  {
52       int i;
53       pkg_t *pkg;
54 -     const char *flags = argv[0];
55 +     char *flags = argv[0];
56      
57       global_conf = conf;
58       signal(SIGINT, sigint_handler);
59 diff -ruN busybox-1.00-old/archival/libipkg/ipkg_conf.c busybox-1.00-new/archival/libipkg/ipkg_conf.c
60 --- busybox-1.00-old/archival/libipkg/ipkg_conf.c       2005-10-27 16:37:25.000000000 +0200
61 +++ busybox-1.00-new/archival/libipkg/ipkg_conf.c       2005-10-27 16:38:03.000000000 +0200
62 @@ -540,14 +540,14 @@
63           if (strcmp(type, "option") == 0) {
64                ipkg_conf_set_option(options, name, value);
65           } else if (strcmp(type, "src") == 0) {
66 -              if (!nv_pair_list_find(pkg_src_list, name)) {
67 +              if (!nv_pair_list_find((nv_pair_list_t *)pkg_src_list, name)) {
68                     pkg_src_list_append (pkg_src_list, name, value, extra, 0);
69                } else {
70                     ipkg_message(conf, IPKG_ERROR, "ERROR: duplicate src declaration.  Skipping:\n\t src %s %s\n",
71                                  name, value);
72                }
73           } else if (strcmp(type, "src/gz") == 0) {
74 -              if (!nv_pair_list_find(pkg_src_list, name)) {
75 +              if (!nv_pair_list_find((nv_pair_list_t *)pkg_src_list, name)) {
76                     pkg_src_list_append (pkg_src_list, name, value, extra, 1);
77                } else {
78                     ipkg_message(conf, IPKG_ERROR, "ERROR: duplicate src declaration.  Skipping:\n\t src %s %s\n",
79 diff -ruN busybox-1.00-old/archival/libipkg/libipkg.c busybox-1.00-new/archival/libipkg/libipkg.c
80 --- busybox-1.00-old/archival/libipkg/libipkg.c 2005-10-27 16:37:25.000000000 +0200
81 +++ busybox-1.00-new/archival/libipkg/libipkg.c 2005-10-27 16:38:03.000000000 +0200
82 @@ -445,7 +445,7 @@
83  int
84  ipkg_op (int argc, char *argv[])
85  {
86 -       int err, optind;
87 +       int err, opt_index;
88         args_t args;
89         char *cmd_name;
90         ipkg_cmd_t *cmd;
91 @@ -453,13 +453,13 @@
92  
93         args_init (&args);
94  
95 -       optind = args_parse (&args, argc, argv);
96 -       if (optind == argc || optind < 0)
97 +       opt_index = args_parse (&args, argc, argv);
98 +       if (opt_index == argc || opt_index < 0)
99         {
100                 args_usage ("ipkg must have one sub-command argument");
101         }
102  
103 -       cmd_name = argv[optind++];
104 +       cmd_name = argv[opt_index++];
105  /* Pigi: added a flag to disable the checking of structures if the command does not need to 
106           read anything from there.
107  */
108 @@ -494,7 +494,7 @@
109                 args_usage (NULL);
110         }
111  
112 -       if (cmd->requires_args && optind == argc)
113 +       if (cmd->requires_args && opt_index == argc)
114         {
115                 fprintf (stderr,
116                          "%s: the ``%s'' command requires at least one argument\n",
117 @@ -502,7 +502,7 @@
118                 args_usage (NULL);
119         }
120  
121 -       err = ipkg_cmd_exec (cmd, &ipkg_conf, argc - optind, (const char **) (argv + optind), NULL);
122 +       err = ipkg_cmd_exec (cmd, &ipkg_conf, argc - opt_index, (const char **) (argv + opt_index), NULL);
123  
124         ipkg_conf_deinit (&ipkg_conf);
125  
126 diff -ruN busybox-1.00-old/archival/libipkg/md5.c busybox-1.00-new/archival/libipkg/md5.c
127 --- busybox-1.00-old/archival/libipkg/md5.c     2005-10-27 16:37:25.000000000 +0200
128 +++ busybox-1.00-new/archival/libipkg/md5.c     2005-10-27 16:38:03.000000000 +0200
129 @@ -25,7 +25,6 @@
130  int md5_stream(FILE *stream, void *resblock)
131  {
132         int fd;
133 -       int sum;
134         
135         if( (fd = fileno(stream)) == -1 ) {
136                 bb_error_msg("bad file descriptor");
137 diff -ruN busybox-1.00-old/archival/libipkg/pkg.c busybox-1.00-new/archival/libipkg/pkg.c
138 --- busybox-1.00-old/archival/libipkg/pkg.c     2005-10-27 16:37:25.000000000 +0200
139 +++ busybox-1.00-new/archival/libipkg/pkg.c     2005-10-27 16:38:03.000000000 +0200
140 @@ -527,6 +527,7 @@
141  char * pkg_formatted_field(pkg_t *pkg, const char *field )
142  {
143       static size_t LINE_LEN = 128;
144 +     char line_str[LINE_LEN];
145       char * temp = (char *)malloc(1);
146       int len = 0;
147       int flag_provide_false = 0;
148 @@ -566,7 +567,6 @@
149           if (strcasecmp(field, "Conffiles") == 0) {
150                /* Conffiles */
151                conffile_list_elt_t *iter;
152 -               char confstr[LINE_LEN];
153  
154                if (pkg->conffiles.head == NULL) {
155                     return temp;
156 @@ -587,15 +587,14 @@
157                 strncpy(temp, "Conffiles:\n", 12);
158                for (iter = pkg->conffiles.head; iter; iter = iter->next) {
159                     if (iter->data->name && iter->data->value) {
160 -                         snprintf(confstr, LINE_LEN, "%s %s\n", iter->data->name, iter->data->value);
161 -                         strncat(temp, confstr, strlen(confstr));           
162 +                         snprintf(line_str, LINE_LEN, "%s %s\n", iter->data->name, iter->data->value);
163 +                         strncat(temp, line_str, strlen(line_str));           
164                     }
165                }
166           } else if (strcasecmp(field, "Conflicts") == 0) {
167                int i;
168  
169                if (pkg->conflicts_count) {
170 -                    char conflictstr[LINE_LEN];
171                      len = 14 ;
172                     for(i = 0; i < pkg->conflicts_count; i++) {
173                          len = len + (strlen(pkg->conflicts_str[i])+5);
174 @@ -608,8 +607,8 @@
175                      temp[0]='\0';
176                      strncpy(temp, "Conflicts:", 11);
177                     for(i = 0; i < pkg->conflicts_count; i++) {
178 -                        snprintf(conflictstr, LINE_LEN, "%s %s", i == 0 ? "" : ",", pkg->conflicts_str[i]);
179 -                        strncat(temp, conflictstr, strlen(conflictstr));           
180 +                        snprintf(line_str, LINE_LEN, "%s %s", i == 0 ? "" : ",", pkg->conflicts_str[i]);
181 +                        strncat(temp, line_str, strlen(line_str));           
182                      }
183                      strncat(temp, "\n", strlen("\n")); 
184                }
185 @@ -624,7 +623,6 @@
186                int i;
187  
188                if (pkg->depends_count) {
189 -                    char depstr[LINE_LEN];
190                      len = 14 ;
191                     for(i = 0; i < pkg->depends_count; i++) {
192                          len = len + (strlen(pkg->depends_str[i])+4);
193 @@ -637,8 +635,8 @@
194                      temp[0]='\0';
195                      strncpy(temp, "Depends:", 10);
196                     for(i = 0; i < pkg->depends_count; i++) {
197 -                        snprintf(depstr, LINE_LEN, "%s %s", i == 0 ? "" : ",", pkg->depends_str[i]);
198 -                        strncat(temp, depstr, strlen(depstr));           
199 +                        snprintf(line_str, LINE_LEN, "%s %s", i == 0 ? "" : ",", pkg->depends_str[i]);
200 +                        strncat(temp, line_str, strlen(line_str));           
201                      }
202                      strncat(temp, "\n", strlen("\n")); 
203                }
204 @@ -803,7 +801,6 @@
205           /* Replaces | Recommends*/
206           if (strcasecmp (field, "Replaces") == 0) {
207                if (pkg->replaces_count) {
208 -                    char replstr[LINE_LEN];
209                      len = 14;
210                     for (i = 0; i < pkg->replaces_count; i++) {
211                          len = len + (strlen(pkg->replaces_str[i])+5);
212 @@ -816,14 +813,13 @@
213                      temp[0]='\0';
214                      strncpy(temp, "Replaces:", 12);
215                     for (i = 0; i < pkg->replaces_count; i++) {
216 -                        snprintf(replstr, LINE_LEN, "%s %s", i == 0 ? "" : ",", pkg->replaces_str[i]);
217 -                        strncat(temp, replstr, strlen(replstr));           
218 +                        snprintf(line_str, LINE_LEN, "%s %s", i == 0 ? "" : ",", pkg->replaces_str[i]);
219 +                        strncat(temp, line_str, strlen(line_str));           
220                      }
221                      strncat(temp, "\n", strlen("\n")); 
222                }
223           } else if (strcasecmp (field, "Recommends") == 0) {
224                if (pkg->recommends_count) {
225 -                    char recstr[LINE_LEN];
226                      len = 15;
227                     for(i = 0; i < pkg->recommends_count; i++) {
228                           len = len + (strlen( pkg->recommends_str[i])+5);
229 @@ -836,8 +832,8 @@
230                      temp[0]='\0';
231                      strncpy(temp, "Recommends:", 13);
232                     for(i = 0; i < pkg->recommends_count; i++) {
233 -                        snprintf(recstr, LINE_LEN, "%s %s", i == 0 ? "" : ",", pkg->recommends_str[i]);
234 -                        strncat(temp, recstr, strlen(recstr));           
235 +                        snprintf(line_str, LINE_LEN, "%s %s", i == 0 ? "" : ",", pkg->recommends_str[i]);
236 +                        strncat(temp, line_str, strlen(line_str));           
237                      }
238                      strncat(temp, "\n", strlen("\n")); 
239                }
240 @@ -906,7 +902,6 @@
241           } else if (strcasecmp(field, "Suggests") == 0) {
242                if (pkg->suggests_count) {
243                     int i;
244 -                    char sugstr[LINE_LEN];
245                      len = 13;
246                     for(i = 0; i < pkg->suggests_count; i++) {
247                          len = len + (strlen(pkg->suggests_str[i])+5);
248 @@ -919,8 +914,8 @@
249                      temp[0]='\0';
250                      strncpy(temp, "Suggests:", 10);
251                     for(i = 0; i < pkg->suggests_count; i++) {
252 -                        snprintf(sugstr, LINE_LEN, "%s %s", i == 0 ? "" : ",", pkg->suggests_str[i]);
253 -                        strncat(temp, sugstr, strlen(sugstr));           
254 +                        snprintf(line_str, LINE_LEN, "%s %s", i == 0 ? "" : ",", pkg->suggests_str[i]);
255 +                        strncat(temp, line_str, strlen(line_str));           
256                      }
257                      strncat(temp, "\n", strlen("\n")); 
258                }
259 @@ -1139,10 +1134,8 @@
260       return 0;
261  }
262  
263 -int pkg_name_version_and_architecture_compare(void *p1, void *p2)
264 +int pkg_name_version_and_architecture_compare(pkg_t *a, pkg_t *b)
265  {
266 -     const pkg_t *a = *(const pkg_t **)p1;
267 -     const pkg_t *b = *(const pkg_t **)p2;
268       int namecmp;
269       int vercmp;
270       if (!a->name || !b->name) {
271 @@ -1169,10 +1162,8 @@
272       return 0;
273  }
274  
275 -int abstract_pkg_name_compare(void *p1, void *p2)
276 +int abstract_pkg_name_compare(abstract_pkg_t *a, abstract_pkg_t *b)
277  {
278 -     const abstract_pkg_t *a = *(const abstract_pkg_t **)p1;
279 -     const abstract_pkg_t *b = *(const abstract_pkg_t **)p2;
280       if (!a->name || !b->name) {
281         fprintf(stderr, "abstract_pkg_name_compare: a=%p a->name=%p b=%p b->name=%p\n",
282                a, a->name, b, b->name);
283 @@ -1192,7 +1183,7 @@
284  #endif
285  
286       if (pkg->epoch) {
287 -         sprintf_alloc(&epoch_str, "%d:", pkg->epoch);
288 +         sprintf_alloc(&epoch_str, "%d:", (int)(pkg->epoch));
289       } else {
290           epoch_str = strdup("");
291       }
292 diff -ruN busybox-1.00-old/archival/libipkg/pkg.h busybox-1.00-new/archival/libipkg/pkg.h
293 --- busybox-1.00-old/archival/libipkg/pkg.h     2005-10-27 16:37:25.000000000 +0200
294 +++ busybox-1.00-new/archival/libipkg/pkg.h     2005-10-27 16:38:03.000000000 +0200
295 @@ -192,8 +192,8 @@
296  char *pkg_version_str_alloc(pkg_t *pkg);
297  
298  int pkg_compare_versions(const pkg_t *pkg, const pkg_t *ref_pkg);
299 -int pkg_name_version_and_architecture_compare(void *a, void *b);
300 -int abstract_pkg_name_compare(void *a, void *b);
301 +int pkg_name_version_and_architecture_compare(pkg_t *a, pkg_t *b);
302 +int abstract_pkg_name_compare(abstract_pkg_t *a, abstract_pkg_t *b);
303  
304  char * pkg_formatted_info(pkg_t *pkg );
305  char * pkg_formatted_field(pkg_t *pkg, const char *field );
306 diff -ruN busybox-1.00-old/archival/libipkg/pkg_depends.c busybox-1.00-new/archival/libipkg/pkg_depends.c
307 --- busybox-1.00-old/archival/libipkg/pkg_depends.c     2005-10-27 16:37:26.000000000 +0200
308 +++ busybox-1.00-new/archival/libipkg/pkg_depends.c     2005-10-27 16:38:03.000000000 +0200
309 @@ -68,7 +68,7 @@
310                                             pkg_vec_t *unsatisfied, char *** unresolved)
311  {
312       pkg_t * satisfier_entry_pkg;
313 -     register int i, j, k;
314 +     register int i, j, k, l;
315       int count, found;
316       char ** the_lost;
317       abstract_pkg_t * ab_pkg;
318 @@ -113,7 +113,6 @@
319                     abstract_pkg_vec_t *ab_provider_vec = abpkg->provided_by;
320                     int nposs = ab_provider_vec->len;
321                     abstract_pkg_t **ab_providers = ab_provider_vec->pkgs; 
322 -                   int l;
323                     for (l = 0; l < nposs; l++) {
324                          pkg_vec_t *test_vec = ab_providers[l]->pkgs;
325                          /* if no depends on this one, try the first package that Provides this one */
326 @@ -137,10 +136,9 @@
327                                                                                 tmp_vec,
328                                                                                 &newstuff);
329                                    if (newstuff == NULL) {
330 -                                       int i;
331                                         int ok = 1;
332 -                                       for (i = 0; i < rc; i++) {
333 -                                           pkg_t *p = tmp_vec->pkgs[i];
334 +                                       for (l = 0; l < rc; l++) {
335 +                                           pkg_t *p = tmp_vec->pkgs[l];
336                                             if (p->state_want == SW_INSTALL)
337                                                 continue;
338                                             ipkg_message(conf, IPKG_DEBUG, "not installing %s due to requirement for %s\n", pkg_scout->name, p->name);
339 @@ -810,27 +808,27 @@
340   *   [npredepends+nrecommends,npredepends+nrecommends+nsuggests) -> returns recommends_str[index]
341   *   [npredepends+nrecommends+nsuggests,npredepends+nrecommends+nsuggests+ndepends) -> returns depends_str[index]
342   */
343 -char *pkg_depend_str(pkg_t *pkg, int index)
344 +char *pkg_depend_str(pkg_t *pkg, int pkg_index)
345  {
346 -     if (index < pkg->pre_depends_count) {
347 -         return pkg->pre_depends_str[index];
348 +     if (pkg_index < pkg->pre_depends_count) {
349 +         return pkg->pre_depends_str[pkg_index];
350       }
351 -     index -= pkg->pre_depends_count;
352 +     pkg_index -= pkg->pre_depends_count;
353  
354 -     if (index < pkg->recommends_count) {
355 -         return pkg->recommends_str[index];
356 +     if (pkg_index < pkg->recommends_count) {
357 +         return pkg->recommends_str[pkg_index];
358       }
359 -     index -= pkg->recommends_count;
360 +     pkg_index -= pkg->recommends_count;
361  
362 -     if (index < pkg->suggests_count) {
363 -         return pkg->suggests_str[index];
364 +     if (pkg_index < pkg->suggests_count) {
365 +         return pkg->suggests_str[pkg_index];
366       }
367 -     index -= pkg->suggests_count;
368 +     pkg_index -= pkg->suggests_count;
369  
370 -     if (index < pkg->depends_count) {
371 -         return pkg->depends_str[index];
372 +     if (pkg_index < pkg->depends_count) {
373 +         return pkg->depends_str[pkg_index];
374       }
375 -     fprintf(stderr, "pkg_depend_str: index %d out of range for pkg=%s\n", index, pkg->name);
376 +     fprintf(stderr, "pkg_depend_str: index %d out of range for pkg=%s\n", pkg_index, pkg->name);
377       return NULL;
378  }
379  
380 diff -ruN busybox-1.00-old/archival/libipkg/pkg_depends.h busybox-1.00-new/archival/libipkg/pkg_depends.h
381 --- busybox-1.00-old/archival/libipkg/pkg_depends.h     2005-10-27 16:37:26.000000000 +0200
382 +++ busybox-1.00-new/archival/libipkg/pkg_depends.h     2005-10-27 16:38:03.000000000 +0200
383 @@ -92,7 +92,7 @@
384   */
385  int pkg_conflicts(pkg_t *pkg, pkg_t *conflicts);
386  
387 -char *pkg_depend_str(pkg_t *pkg, int index);
388 +char *pkg_depend_str(pkg_t *pkg, int pkg_index);
389  void buildDependedUponBy(pkg_t * pkg, abstract_pkg_t * ab_pkg);
390  void freeDepends(pkg_t *pkg);
391  void printDepends(pkg_t * pkg);
392 diff -ruN busybox-1.00-old/archival/libipkg/pkg_hash.c busybox-1.00-new/archival/libipkg/pkg_hash.c
393 --- busybox-1.00-old/archival/libipkg/pkg_hash.c        2005-10-27 16:37:26.000000000 +0200
394 +++ busybox-1.00-new/archival/libipkg/pkg_hash.c        2005-10-27 16:38:03.000000000 +0200
395 @@ -143,7 +143,7 @@
396  pkg_t *pkg_hash_fetch_best_installation_candidate(ipkg_conf_t *conf, abstract_pkg_t *apkg, 
397                                                   int (*constraint_fcn)(pkg_t *pkg, void *cdata), void *cdata, int quiet)
398  {
399 -     int i; 
400 +     int i, j;
401       int nprovides = 0;
402       int nmatching = 0;
403       pkg_vec_t *matching_pkgs = pkg_vec_alloc();
404 @@ -209,11 +209,10 @@
405           /* now check for supported architecture */
406           {
407                int max_count = 0;
408 -              int i;
409  
410                /* count packages matching max arch priority and keep track of last one */
411 -              for (i = 0; i < vec->len; i++) {
412 -                   pkg_t *maybe = vec->pkgs[i];
413 +              for (j = 0; j < vec->len; j++) {
414 +                   pkg_t *maybe = vec->pkgs[j];
415                     ipkg_message(conf, IPKG_DEBUG, "  %s arch=%s arch_priority=%d  \n",
416                                  maybe->name, maybe->architecture, maybe->arch_priority);
417                     if (maybe->arch_priority > 0)  {
418 diff -ruN busybox-1.00-old/archival/libipkg/pkg_vec.h busybox-1.00-new/archival/libipkg/pkg_vec.h
419 --- busybox-1.00-old/archival/libipkg/pkg_vec.h 2005-10-27 16:37:26.000000000 +0200
420 +++ busybox-1.00-new/archival/libipkg/pkg_vec.h 2005-10-27 16:39:05.000000000 +0200
421 @@ -35,6 +35,8 @@
422  };
423  typedef struct abstract_pkg_vec abstract_pkg_vec_t;
424  
425 +typedef int (*pkg_compar_t)(pkg_t *, pkg_t *);
426 +typedef int (*abstract_pkg_compar_t)(abstract_pkg_t *, abstract_pkg_t *);
427  
428  pkg_vec_t * pkg_vec_alloc(void);
429  void pkg_vec_free(pkg_vec_t *vec);