PERFORCE change 130697 for review
Garrett Cooper
gcooper at FreeBSD.org
Wed Dec 12 03:55:26 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=130697
Change 130697 by gcooper at shiina-ibook on 2007/12/12 11:54:24
-Replace archive_read_support_compression_bzip2(..) and archive_read_support_compression_gzip(..) with archive_read_support_compression_all(..).
-Missing semicolon.
-Replace more redundant code with goto's / label's for consistency / error proofing sake.
Affected files ...
.. //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/libpkg/pkg_freebsd.c#5 edit
Differences ...
==== //depot/projects/soc2007/revised_fbsd_pkgtools/pkg_revised/v2/contrib/libpkg/pkg_freebsd.c#5 (text+ko) ====
@@ -139,8 +139,7 @@
fpkg->fd = fd;
fpkg->pkg_type = fpkg_from_file;
fpkg->archive = archive_read_new();
- archive_read_support_compression_bzip2(fpkg->archive);
- archive_read_support_compression_gzip(fpkg->archive);
+ archive_read_support_compression_all(fpkg->archive);
archive_read_support_format_tar(fpkg->archive);
archive_read_open_stream(fpkg->archive, fd, 10240);
@@ -177,7 +176,7 @@
/*
* Set the prefix to the first @cwd line.
- * This should be line 3 otherwise we have a bad package
+ * This should be line 3; otherwise we have a bad package
*/
pkg->pkg_prefix = strdup(fpkg->contents->lines[3].data);
@@ -215,7 +214,7 @@
freebsd_get_rdeps, pkg_freebsd_free);
if (pkg == NULL)
- return NULL;
+ goto pkg_new_freebsd_installed_fail;
pkg_add_callbacks_data(pkg, freebsd_get_version, freebsd_get_origin,
freebsd_set_origin);
@@ -223,20 +222,25 @@
freebsd_get_next_file, freebsd_run_script);
fpkg = freebsd_package_new();
- if (fpkg == NULL) {
- pkg_free(pkg);
- return NULL;
- }
+
+ if (fpkg == NULL)
+ goto pkg_new_freebsd_installed_fail;
+
pkg->data = fpkg;
fpkg->pkg_type = fpkg_from_installed;
fpkg->db_dir = strdup(pkg_db_dir);
- if (fpkg->db_dir == NULL) {
- pkg_free(pkg);
- return NULL;
- }
+
+ if (fpkg->db_dir == NULL)
+ goto pkg_new_freebsd_installed_fail;
+
return pkg;
+
+pkg_new_freebsd_installed_fail:
+ pkg_free(pkg);
+ return NULL;
+
}
/**
@@ -411,8 +415,20 @@
static int
freebsd_add_depend(struct pkg *pkg, struct pkg *depend)
{
- assert(0);
+
+ /*
+ * Foreach pkg, look to see if the package
+ * is an existing dependency..
+ *
+ * Using queue(3) would be excellent here,
+ * methinks, in particular LIST..
+ */
+
+
+ pkg->pkg_get_deps(pkg);
+
return -1;
+
}
/**
@@ -421,7 +437,7 @@
* @return -1
*/
static int
-freebsd_add_file(struct pkg *pkg __unused, struct pkgfile *file __unused)
+freebsd_add_file(struct pkg *pkg, struct pkgfile *file)
{
assert(0);
return -1;
@@ -741,24 +757,21 @@
/* Get the control files from the package */
control = pkg_get_control_files(pkg);
assert(control != NULL);
- if (control == NULL) {
+ if (control == NULL)
return -1;
- }
/* Find the +CONTENTS file in the control files */
contents_file = pkg_get_control_file(pkg, "+CONTENTS");
assert(contents_file != NULL);
- if (contents_file == NULL) {
+ if (contents_file == NULL)
return -1;
- }
file_data = pkgfile_get_data(contents_file);
contents = pkg_freebsd_contents_new(file_data,
pkgfile_get_size(contents_file));
assert(contents != NULL);
- if (contents == NULL) {
+ if (contents == NULL)
return -1;
- }
for (pos = 0; pos < contents->line_count; pos++) {
switch (contents->lines[pos].line_type) {
@@ -987,7 +1000,7 @@
}
/*
- * @Todo: what the heck does this do
+ * @todo: what the heck does this do
* (in the big picture, that is..)?
*/
size = pkgfile_get_size(control[pos]);
@@ -1266,18 +1279,18 @@
int
freebsd_open_control_files(struct freebsd_package *fpkg)
{
- unsigned int control_size, control_count;
+ size_t control_size;
+
+ unsigned int control_count;
struct pkgfile *pkgfile;
#define addFile(pkgfile) \
control_size += sizeof(struct pkgfile **); \
- size_t pkg_control_size = sizeof(fpkg->control); \
fpkg->control = realloc(fpkg->control, control_size); \
if (fpkg->control == NULL || \
- pkg_control_size == sizeof(fpkg->control)) \
+ control_size != sizeof(fpkg->control)) \
return -1; \
- fpkg->control[control_count] = pkgfile; \
- control_count++; \
+ fpkg->control[control_count++] = pkgfile; \
fpkg->control[control_count] = NULL;
assert(fpkg != NULL);
@@ -1337,7 +1350,7 @@
return -1;
}
- pkg_remove_extra_slashes(file)
+ pkg_remove_extra_slashes(file);
pkgfile = pkgfile_new_from_disk(file, 1);
addFile(pkgfile);
free(file);
More information about the p4-projects
mailing list