Date: Thu, 29 Nov 2007 19:18:03 GMT From: Garrett Cooper <gcooper@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 129783 for review Message-ID: <200711291918.lATJI3qZ096842@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=129783 Change 129783 by gcooper@shiina-ibook on 2007/11/29 19:18:01 Style and logic consolidation. Affected files ... .. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/libpkg/pkg.c#2 edit Differences ... ==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/libpkg/pkg.c#2 (text+ko) ==== @@ -69,12 +69,11 @@ return NULL; pkg = malloc(sizeof(struct pkg)); - if (!pkg) { + if (pkg == NULL) return NULL; - } pkg->pkg_name = strdup(pkg_name); - if (!pkg->pkg_name) { + if (pkg->pkg_name == NULL) { free(pkg); return NULL; } @@ -311,10 +310,7 @@ struct pkgfile ** pkg_get_control_files(struct pkg *pkg) { - if (!pkg) - return NULL; - - if (pkg->pkg_get_control_files) + if (pkg != NULL && pkg->pkg_get_control_files != NULL) return pkg->pkg_get_control_files(pkg); return NULL; @@ -329,10 +325,7 @@ struct pkgfile * pkg_get_control_file(struct pkg *pkg, const char *pkg_name) { - if (!pkg || !pkg_name) - return NULL; - - if (pkg->pkg_get_control_file) + if (pkg != NULL && pkg_name != NULL && pkg->pkg_get_control_file != NULL) return pkg->pkg_get_control_file(pkg, pkg_name); return NULL; @@ -348,7 +341,7 @@ struct pkg ** pkg_get_dependencies(struct pkg *pkg) { - if (!pkg) + if (pkg == NULL) return NULL; assert(pkg->pkg_get_deps == NULL || @@ -374,7 +367,7 @@ struct pkg ** pkg_get_reverse_dependencies(struct pkg *pkg) { - if (!pkg) + if (pkg == NULL) return NULL; assert(pkg->pkg_get_rdeps == NULL || @@ -412,7 +405,7 @@ const char * pkg_get_name(struct pkg *pkg) { - if (!pkg) + if (pkg == NULL) return NULL; return pkg->pkg_name; } @@ -428,10 +421,10 @@ struct pkgfile * pkg_get_next_file(struct pkg *pkg) { - if (!pkg) + if (pkg == NULL) return NULL; - if (!pkg->pkg_get_next_file) + if (pkg->pkg_get_next_file == NULL) return NULL; return pkg->pkg_get_next_file(pkg); @@ -448,10 +441,7 @@ const char * pkg_get_origin(struct pkg *pkg) { - if (pkg == NULL) - return NULL; - - if (pkg->pkg_get_origin != NULL) + if (pkg != NULL && pkg->pkg_get_origin != NULL) return pkg->pkg_get_origin(pkg); return NULL; @@ -471,10 +461,7 @@ int pkg_set_origin(struct pkg *pkg, const char *origin) { - if (pkg == NULL || origin == NULL) - return -1; - - if (pkg->pkg_set_origin) + if (pkg != NULL && origin != NULL && pkg->pkg_set_origin != NULL) return pkg->pkg_set_origin(pkg, origin); return -1; @@ -491,10 +478,7 @@ const char * pkg_get_version(struct pkg *pkg) { - if (pkg == NULL) - return NULL; - - if (pkg->pkg_get_version != NULL) + if (pkg != NULL && pkg->pkg_get_version != NULL) return pkg->pkg_get_version(pkg); return NULL; @@ -510,13 +494,9 @@ int pkg_run_script(struct pkg *pkg, const char *prefix, pkg_script script) { - if (pkg == NULL) - return -1; - - if (pkg->pkg_run_script == NULL) - return -1; - - return pkg->pkg_run_script(pkg, prefix, script); + if (pkg != NULL && pkg->pkg_run_script != NULL) + return pkg->pkg_run_script(pkg, prefix, script); + return -1; } /** @@ -528,12 +508,8 @@ int pkg_add_dependency(struct pkg *pkg, struct pkg *depend) { - if (!pkg || !depend) - return -1; - - if (pkg->pkg_add_depend) + if (pkg != NULL && depend != NULL && pkg->pkg_add_depend != NULL) return pkg->pkg_add_depend(pkg, depend); - return -1; } @@ -546,12 +522,8 @@ int pkg_add_file(struct pkg *pkg, struct pkgfile *file) { - if (!pkg || !file) - return -1; - - if (pkg->pkg_add_file) + if (pkg != NULL && file != NULL && pkg->pkg_add_file != NULL) return pkg->pkg_add_file(pkg, file); - return -1; } @@ -642,7 +614,7 @@ { unsigned int cur; - if (!pkgs) + if (pkgs == NULL) return -1; for (cur = 0; pkgs[cur] != NULL; cur++) @@ -660,7 +632,7 @@ int pkg_free(struct pkg *pkg) { - if (pkg != NULL) + if (pkg == NULL) return -1; if (pkg->pkg_name != NULL)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200711291918.lATJI3qZ096842>