Make a couple of functions static, and return void since they cannot fail.
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Wed, 25 Nov 2009 04:22:20 +0000 (04:22 +0000)
committergraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Wed, 25 Nov 2009 04:22:20 +0000 (04:22 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@368 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/pkg.c
libopkg/pkg.h
libopkg/pkg_hash.c

index bba04ff75f95aae85079c85025146a81cc9807a6..4ce3fb09988dbd4d3e643854f1a27c997f7909a3 100644 (file)
@@ -75,17 +75,8 @@ static const enum_map_t pkg_state_status_map[] = {
 static int verrevcmp(const char *val, const char *ref);
 
 
-pkg_t *pkg_new(void)
-{
-     pkg_t *pkg;
-
-     pkg = xcalloc(1, sizeof(pkg_t));
-     pkg_init(pkg);
-
-     return pkg;
-}
-
-int pkg_init(pkg_t *pkg)
+static void
+pkg_init(pkg_t *pkg)
 {
      pkg->name = NULL;
      pkg->epoch = 0;
@@ -139,8 +130,16 @@ int pkg_init(pkg_t *pkg)
      pkg->installed_files_ref_cnt = 0;
      pkg->essential = 0;
      pkg->provided_by_hand = 0;
+}
 
-     return 0;
+pkg_t *pkg_new(void)
+{
+     pkg_t *pkg;
+
+     pkg = xcalloc(1, sizeof(pkg_t));
+     pkg_init(pkg);
+
+     return pkg;
 }
 
 void compound_depend_deinit (compound_depend_t *depends)
@@ -449,35 +448,24 @@ int pkg_merge(pkg_t *oldpkg, pkg_t *newpkg, int set_status)
      return 0;
 }
 
+static void
+abstract_pkg_init(abstract_pkg_t *ab_pkg)
+{
+     ab_pkg->provided_by = abstract_pkg_vec_alloc();
+     ab_pkg->dependencies_checked = 0;
+     ab_pkg->state_status = SS_NOT_INSTALLED;
+}
+
 abstract_pkg_t *abstract_pkg_new(void)
 {
      abstract_pkg_t * ab_pkg;
 
      ab_pkg = xcalloc(1, sizeof(abstract_pkg_t));
-
-     if (ab_pkg == NULL) {
-         fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
-         return NULL;
-     }
-
-     if ( abstract_pkg_init(ab_pkg) < 0 ) 
-        return NULL;
+     abstract_pkg_init(ab_pkg);
 
      return ab_pkg;
 }
 
-int abstract_pkg_init(abstract_pkg_t *ab_pkg)
-{
-     ab_pkg->provided_by = abstract_pkg_vec_alloc();
-     if (ab_pkg->provided_by==NULL){
-        return -1;
-     }
-     ab_pkg->dependencies_checked = 0;
-     ab_pkg->state_status = SS_NOT_INSTALLED;
-
-     return 0;
-}
-
 void set_flags_from_control(opkg_conf_t *conf, pkg_t *pkg){
      char *file_name;
      FILE *fp;
index 694bda95d5680cd2af460aa45758bf3d2bef46d3..328d4791ed83f02afea705626e391b0814be7b03 100644 (file)
@@ -188,11 +188,9 @@ struct pkg
 };
 
 pkg_t *pkg_new(void);
-int pkg_init(pkg_t *pkg);
 void pkg_deinit(pkg_t *pkg);
 int pkg_init_from_file(opkg_conf_t *conf, pkg_t *pkg, const char *filename);
 abstract_pkg_t *abstract_pkg_new(void);
-int abstract_pkg_init(abstract_pkg_t *ab_pkg);
 
 /* 
  * merges fields from newpkg into oldpkg.
index ace26bf0cbcc90eceafe2effcc72952c6b228899..83415ab96e70b6c7e4a231bf5769e2a032353f36 100644 (file)
@@ -609,7 +609,6 @@ static abstract_pkg_t * add_new_abstract_pkg_by_name(hash_table_t * hash, const
   abstract_pkg_t * ab_pkg;
 
   ab_pkg = abstract_pkg_new();
-  if (ab_pkg == NULL) { return NULL; }
 
   ab_pkg->name = xstrdup(pkg_name);
   hash_table_insert(hash, pkg_name, ab_pkg);