aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-09-28 22:35:42 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-09-28 22:35:42 +0000
commit54928843119f90b409d177977bac02fdd52d6de0 (patch)
tree48e60fa5b0628c2f3d4871161bd90d8d98258171
parent57308afb5b221c2ccbf7d3accc301fffb31aa7a5 (diff)
downloadbusybox-w32-54928843119f90b409d177977bac02fdd52d6de0.tar.gz
busybox-w32-54928843119f90b409d177977bac02fdd52d6de0.tar.bz2
busybox-w32-54928843119f90b409d177977bac02fdd52d6de0.zip
dpkg: style fixes; short -> int (generated code is smaller)
-rw-r--r--archival/dpkg.c108
1 files changed, 54 insertions, 54 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 304400c84..b26a11631 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -152,7 +152,7 @@ static int search_name_hashtable(const char *key)
152 make_hash(key, &probe_address, &probe_decrement, NAME_HASH_PRIME); 152 make_hash(key, &probe_address, &probe_decrement, NAME_HASH_PRIME);
153 while (name_hashtable[probe_address] != NULL) { 153 while (name_hashtable[probe_address] != NULL) {
154 if (strcmp(name_hashtable[probe_address], key) == 0) { 154 if (strcmp(name_hashtable[probe_address], key) == 0) {
155 return(probe_address); 155 return probe_address;
156 } else { 156 } else {
157 probe_address -= probe_decrement; 157 probe_address -= probe_decrement;
158 if ((int)probe_address < 0) { 158 if ((int)probe_address < 0) {
@@ -161,7 +161,7 @@ static int search_name_hashtable(const char *key)
161 } 161 }
162 } 162 }
163 name_hashtable[probe_address] = xstrdup(key); 163 name_hashtable[probe_address] = xstrdup(key);
164 return(probe_address); 164 return probe_address;
165} 165}
166 166
167/* this DOESNT add the key to the hashtable 167/* this DOESNT add the key to the hashtable
@@ -183,7 +183,7 @@ static unsigned int search_status_hashtable(const char *key)
183 } 183 }
184 } 184 }
185 } 185 }
186 return(probe_address); 186 return probe_address;
187} 187}
188 188
189/* Need to rethink version comparison, maybe the official dpkg has something i can use ? */ 189/* Need to rethink version comparison, maybe the official dpkg has something i can use ? */
@@ -247,7 +247,7 @@ static int version_compare_part(const char *version1, const char *version2)
247 } 247 }
248 ret = 0; 248 ret = 0;
249cleanup_version_compare_part: 249cleanup_version_compare_part:
250 return(ret); 250 return ret;
251} 251}
252 252
253/* if ver1 < ver2 return -1, 253/* if ver1 < ver2 return -1,
@@ -282,10 +282,10 @@ static int version_compare(const unsigned int ver1, const unsigned int ver2)
282 ver2_ptr = ch_ver2; 282 ver2_ptr = ch_ver2;
283 } 283 }
284 if (epoch1 < epoch2) { 284 if (epoch1 < epoch2) {
285 return(-1); 285 return -1;
286 } 286 }
287 else if (epoch1 > epoch2) { 287 else if (epoch1 > epoch2) {
288 return(1); 288 return 1;
289 } 289 }
290 290
291 /* Compare upstream version */ 291 /* Compare upstream version */
@@ -309,46 +309,46 @@ static int version_compare(const unsigned int ver1, const unsigned int ver2)
309 free(upstream_ver2); 309 free(upstream_ver2);
310 310
311 if (result != 0) { 311 if (result != 0) {
312 return(result); 312 return result;
313 } 313 }
314 314
315 /* Compare debian versions */ 315 /* Compare debian versions */
316 return(version_compare_part(deb_ver1, deb_ver2)); 316 return version_compare_part(deb_ver1, deb_ver2);
317} 317}
318 318
319static int test_version(const unsigned int version1, const unsigned int version2, const unsigned int operator) 319static int test_version(const unsigned int version1, const unsigned int version2, const unsigned int operator)
320{ 320{
321 const int version_result = version_compare(version1, version2); 321 const int version_result = version_compare(version1, version2);
322 switch (operator) { 322 switch (operator) {
323 case (VER_ANY): 323 case VER_ANY:
324 return(TRUE); 324 return TRUE;
325 case (VER_EQUAL): 325 case VER_EQUAL:
326 if (version_result == 0) { 326 if (version_result == 0) {
327 return(TRUE); 327 return TRUE;
328 } 328 }
329 break; 329 break;
330 case (VER_LESS): 330 case VER_LESS:
331 if (version_result < 0) { 331 if (version_result < 0) {
332 return(TRUE); 332 return TRUE;
333 } 333 }
334 break; 334 break;
335 case (VER_LESS_EQUAL): 335 case VER_LESS_EQUAL:
336 if (version_result <= 0) { 336 if (version_result <= 0) {
337 return(TRUE); 337 return TRUE;
338 } 338 }
339 break; 339 break;
340 case (VER_MORE): 340 case VER_MORE:
341 if (version_result > 0) { 341 if (version_result > 0) {
342 return(TRUE); 342 return TRUE;
343 } 343 }
344 break; 344 break;
345 case (VER_MORE_EQUAL): 345 case VER_MORE_EQUAL:
346 if (version_result >= 0) { 346 if (version_result >= 0) {
347 return(TRUE); 347 return TRUE;
348 } 348 }
349 break; 349 break;
350 } 350 }
351 return(FALSE); 351 return FALSE;
352} 352}
353 353
354 354
@@ -361,10 +361,10 @@ static int search_package_hashtable(const unsigned int name, const unsigned int
361 while (package_hashtable[probe_address] != NULL) { 361 while (package_hashtable[probe_address] != NULL) {
362 if (package_hashtable[probe_address]->name == name) { 362 if (package_hashtable[probe_address]->name == name) {
363 if (operator == VER_ANY) { 363 if (operator == VER_ANY) {
364 return(probe_address); 364 return probe_address;
365 } 365 }
366 if (test_version(package_hashtable[probe_address]->version, version, operator)) { 366 if (test_version(package_hashtable[probe_address]->version, version, operator)) {
367 return(probe_address); 367 return probe_address;
368 } 368 }
369 } 369 }
370 probe_address -= probe_decrement; 370 probe_address -= probe_decrement;
@@ -372,7 +372,7 @@ static int search_package_hashtable(const unsigned int name, const unsigned int
372 probe_address += PACKAGE_HASH_PRIME; 372 probe_address += PACKAGE_HASH_PRIME;
373 } 373 }
374 } 374 }
375 return(probe_address); 375 return probe_address;
376} 376}
377 377
378/* 378/*
@@ -525,7 +525,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
525 525
526static void free_package(common_node_t *node) 526static void free_package(common_node_t *node)
527{ 527{
528 unsigned short i; 528 unsigned i;
529 if (node) { 529 if (node) {
530 for (i = 0; i < node->num_of_edges; i++) { 530 for (i = 0; i < node->num_of_edges; i++) {
531 free(node->edge[i]); 531 free(node->edge[i]);
@@ -554,15 +554,15 @@ static int read_package_field(const char *package_buffer, char **field_name, cha
554 if (package_buffer == NULL) { 554 if (package_buffer == NULL) {
555 *field_name = NULL; 555 *field_name = NULL;
556 *field_value = NULL; 556 *field_value = NULL;
557 return(-1); 557 return -1;
558 } 558 }
559 while (1) { 559 while (1) {
560 next_offset = offset + 1; 560 next_offset = offset + 1;
561 switch (package_buffer[offset]) { 561 switch (package_buffer[offset]) {
562 case('\0'): 562 case '\0':
563 exit_flag = TRUE; 563 exit_flag = TRUE;
564 break; 564 break;
565 case(':'): 565 case ':':
566 if (offset_name_end == 0) { 566 if (offset_name_end == 0) {
567 offset_name_end = offset; 567 offset_name_end = offset;
568 offset_value_start = next_offset; 568 offset_value_start = next_offset;
@@ -570,14 +570,14 @@ static int read_package_field(const char *package_buffer, char **field_name, cha
570 /* TODO: Name might still have trailing spaces if ':' isnt 570 /* TODO: Name might still have trailing spaces if ':' isnt
571 * immediately after name */ 571 * immediately after name */
572 break; 572 break;
573 case('\n'): 573 case '\n':
574 /* TODO: The char next_offset may be out of bounds */ 574 /* TODO: The char next_offset may be out of bounds */
575 if (package_buffer[next_offset] != ' ') { 575 if (package_buffer[next_offset] != ' ') {
576 exit_flag = TRUE; 576 exit_flag = TRUE;
577 break; 577 break;
578 } 578 }
579 case('\t'): 579 case '\t':
580 case(' '): 580 case ' ':
581 /* increment the value start point if its a just filler */ 581 /* increment the value start point if its a just filler */
582 if (offset_name_start == offset) { 582 if (offset_name_start == offset) {
583 offset_name_start++; 583 offset_name_start++;
@@ -619,7 +619,7 @@ static int read_package_field(const char *package_buffer, char **field_name, cha
619 } else { 619 } else {
620 *field_value = NULL; 620 *field_value = NULL;
621 } 621 }
622 return(next_offset); 622 return next_offset;
623} 623}
624 624
625static unsigned int fill_package_struct(char *control_buffer) 625static unsigned int fill_package_struct(char *control_buffer)
@@ -638,7 +638,7 @@ static unsigned int fill_package_struct(char *control_buffer)
638 638
639 new_node->version = search_name_hashtable("unknown"); 639 new_node->version = search_name_hashtable("unknown");
640 while (field_start < buffer_length) { 640 while (field_start < buffer_length) {
641 unsigned short field_num; 641 unsigned field_num;
642 642
643 field_start += read_package_field(&control_buffer[field_start], 643 field_start += read_package_field(&control_buffer[field_start],
644 &field_name, &field_value); 644 &field_name, &field_value);
@@ -687,7 +687,7 @@ fill_package_struct_cleanup:
687 687
688 if (new_node->version == search_name_hashtable("unknown")) { 688 if (new_node->version == search_name_hashtable("unknown")) {
689 free_package(new_node); 689 free_package(new_node);
690 return(-1); 690 return -1;
691 } 691 }
692 num = search_package_hashtable(new_node->name, new_node->version, VER_EQUAL); 692 num = search_package_hashtable(new_node->name, new_node->version, VER_EQUAL);
693 if (package_hashtable[num] == NULL) { 693 if (package_hashtable[num] == NULL) {
@@ -695,7 +695,7 @@ fill_package_struct_cleanup:
695 } else { 695 } else {
696 free_package(new_node); 696 free_package(new_node);
697 } 697 }
698 return(num); 698 return num;
699} 699}
700 700
701/* if num = 1, it returns the want status, 2 returns flag, 3 returns status */ 701/* if num = 1, it returns the want status, 2 returns flag, 3 returns status */
@@ -718,7 +718,7 @@ static unsigned int get_status(const unsigned int status_node, const int num)
718 state_sub_string = xstrndup(status_string, len); 718 state_sub_string = xstrndup(status_string, len);
719 state_sub_num = search_name_hashtable(state_sub_string); 719 state_sub_num = search_name_hashtable(state_sub_string);
720 free(state_sub_string); 720 free(state_sub_string);
721 return(state_sub_num); 721 return state_sub_num;
722} 722}
723 723
724static void set_status(const unsigned int status_node_num, const char *new_value, const int position) 724static void set_status(const unsigned int status_node_num, const char *new_value, const int position)
@@ -734,15 +734,15 @@ static void set_status(const unsigned int status_node_num, const char *new_value
734 char *new_status; 734 char *new_status;
735 735
736 switch (position) { 736 switch (position) {
737 case (1): 737 case 1:
738 want = new_value_num; 738 want = new_value_num;
739 want_len = new_value_len; 739 want_len = new_value_len;
740 break; 740 break;
741 case (2): 741 case 2:
742 flag = new_value_num; 742 flag = new_value_num;
743 flag_len = new_value_len; 743 flag_len = new_value_len;
744 break; 744 break;
745 case (3): 745 case 3:
746 status = new_value_num; 746 status = new_value_num;
747 status_len = new_value_len; 747 status_len = new_value_len;
748 break; 748 break;
@@ -1189,7 +1189,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
1189 } 1189 }
1190 } 1190 }
1191 free(conflicts); 1191 free(conflicts);
1192 return(TRUE); 1192 return TRUE;
1193} 1193}
1194 1194
1195static char **create_list(const char *filename) 1195static char **create_list(const char *filename)
@@ -1202,7 +1202,7 @@ static char **create_list(const char *filename)
1202 /* don't use [xw]fopen here, handle error ourself */ 1202 /* don't use [xw]fopen here, handle error ourself */
1203 list_stream = fopen(filename, "r"); 1203 list_stream = fopen(filename, "r");
1204 if (list_stream == NULL) { 1204 if (list_stream == NULL) {
1205 return(NULL); 1205 return NULL;
1206 } 1206 }
1207 1207
1208 while ((line = bb_get_chomped_line_from_file(list_stream)) != NULL) { 1208 while ((line = bb_get_chomped_line_from_file(list_stream)) != NULL) {
@@ -1213,10 +1213,10 @@ static char **create_list(const char *filename)
1213 fclose(list_stream); 1213 fclose(list_stream);
1214 1214
1215 if (count == 0) { 1215 if (count == 0) {
1216 return(NULL); 1216 return NULL;
1217 } else { 1217 } else {
1218 file_list[count] = NULL; 1218 file_list[count] = NULL;
1219 return(file_list); 1219 return file_list;
1220 } 1220 }
1221} 1221}
1222 1222
@@ -1229,7 +1229,7 @@ static int remove_file_array(char **remove_names, char **exclude_names)
1229 int i,j; 1229 int i,j;
1230 1230
1231 if (remove_names == NULL) { 1231 if (remove_names == NULL) {
1232 return(FALSE); 1232 return FALSE;
1233 } 1233 }
1234 for (i = 0; remove_names[i] != NULL; i++) { 1234 for (i = 0; remove_names[i] != NULL; i++) {
1235 match_flag = FALSE; 1235 match_flag = FALSE;
@@ -1256,7 +1256,7 @@ static int remove_file_array(char **remove_names, char **exclude_names)
1256 } 1256 }
1257 } 1257 }
1258 } 1258 }
1259 return(remove_flag); 1259 return remove_flag;
1260} 1260}
1261 1261
1262static int run_package_script(const char *package_name, const char *script_type) 1262static int run_package_script(const char *package_name, const char *script_type)
@@ -1270,7 +1270,7 @@ static int run_package_script(const char *package_name, const char *script_type)
1270 /* If the file doesnt exist is isnt a fatal */ 1270 /* If the file doesnt exist is isnt a fatal */
1271 result = lstat(script_path, &path_stat) < 0 ? EXIT_SUCCESS : system(script_path); 1271 result = lstat(script_path, &path_stat) < 0 ? EXIT_SUCCESS : system(script_path);
1272 free(script_path); 1272 free(script_path);
1273 return(result); 1273 return result;
1274} 1274}
1275 1275
1276static const char *all_control_files[] = {"preinst", "postinst", "prerm", "postrm", 1276static const char *all_control_files[] = {"preinst", "postinst", "prerm", "postrm",
@@ -1278,7 +1278,7 @@ static const char *all_control_files[] = {"preinst", "postinst", "prerm", "postr
1278 1278
1279static char **all_control_list(const char *package_name) 1279static char **all_control_list(const char *package_name)
1280{ 1280{
1281 unsigned short i = 0; 1281 unsigned i = 0;
1282 char **remove_files; 1282 char **remove_files;
1283 1283
1284 /* Create a list of all /var/lib/dpkg/info/<package> files */ 1284 /* Create a list of all /var/lib/dpkg/info/<package> files */
@@ -1288,14 +1288,14 @@ static char **all_control_list(const char *package_name)
1288 i++; 1288 i++;
1289 } 1289 }
1290 1290
1291 return(remove_files); 1291 return remove_files;
1292} 1292}
1293 1293
1294static void free_array(char **array) 1294static void free_array(char **array)
1295{ 1295{
1296 1296
1297 if (array) { 1297 if (array) {
1298 unsigned short i = 0; 1298 unsigned i = 0;
1299 while (array[i]) { 1299 while (array[i]) {
1300 free(array[i]); 1300 free(array[i]);
1301 i++; 1301 i++;
@@ -1447,7 +1447,7 @@ static archive_handle_t *init_archive_deb_ar(const char *filename)
1447 ar_handle->filter = filter_accept_list_reassign; 1447 ar_handle->filter = filter_accept_list_reassign;
1448 ar_handle->src_fd = xopen(filename, O_RDONLY); 1448 ar_handle->src_fd = xopen(filename, O_RDONLY);
1449 1449
1450 return(ar_handle); 1450 return ar_handle;
1451} 1451}
1452 1452
1453static void init_archive_deb_control(archive_handle_t *ar_handle) 1453static void init_archive_deb_control(archive_handle_t *ar_handle)
@@ -1503,7 +1503,7 @@ static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, lli
1503 unpack_ar_archive(ar_handle); 1503 unpack_ar_archive(ar_handle);
1504 close(ar_handle->src_fd); 1504 close(ar_handle->src_fd);
1505 1505
1506 return(ar_handle->sub_archive->buffer); 1506 return ar_handle->sub_archive->buffer;
1507} 1507}
1508 1508
1509static void data_extract_all_prefix(archive_handle_t *archive_handle) 1509static void data_extract_all_prefix(archive_handle_t *archive_handle)
@@ -1659,7 +1659,7 @@ int dpkg_main(int argc, char **argv)
1659 bb_show_usage(); 1659 bb_show_usage();
1660 } 1660 }
1661 } 1661 }
1662 /* check for non-otion argument if expected */ 1662 /* check for non-option argument if expected */
1663 if ((dpkg_opt == 0) || ((argc == optind) && !(dpkg_opt && dpkg_opt_list_installed))) { 1663 if ((dpkg_opt == 0) || ((argc == optind) && !(dpkg_opt && dpkg_opt_list_installed))) {
1664 bb_show_usage(); 1664 bb_show_usage();
1665 } 1665 }
@@ -1670,7 +1670,7 @@ int dpkg_main(int argc, char **argv)
1670 /* if the list action was given print the installed packages and exit */ 1670 /* if the list action was given print the installed packages and exit */
1671 if (dpkg_opt & dpkg_opt_list_installed) { 1671 if (dpkg_opt & dpkg_opt_list_installed) {
1672 list_packages(); 1672 list_packages();
1673 return(EXIT_SUCCESS); 1673 return EXIT_SUCCESS;
1674 } 1674 }
1675 1675
1676 /* Read arguments and store relevant info in structs */ 1676 /* Read arguments and store relevant info in structs */
@@ -1814,5 +1814,5 @@ int dpkg_main(int argc, char **argv)
1814 free(name_hashtable); 1814 free(name_hashtable);
1815 } 1815 }
1816 1816
1817 return(EXIT_SUCCESS); 1817 return EXIT_SUCCESS;
1818} 1818}