[pacman-dev] Codingstyle

James Rosten seinfeld90 at gmail.com
Sun Jan 21 15:50:50 EST 2007


> Broke it:
> package.c: In function '_alpm_pkg_load':
> package.c:354: error: 'descfile' undeclared (first use in this function)
> package.c:354: error: (Each undeclared identifier is reported only once
> package.c:354: error: for each function it appears in.)
> package.c:356: error: 'fd' undeclared (first use in this function)
>

I made a patch to fix that (which is below).  And while fiddling with the
resulting pacman.static it segfaulted during a ./pacman.static -Ss test
This is the gdb output (I usually don't use gdb so I have minimal information to
give):

Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) run -Ss test
Starting program: /home/james/test/usr/local/bin/pacman.static -Ss test
Failed to read a valid object file image from memory.

Program received signal SIGSEGV, Segmentation fault.
alpm_list_getdata (entry=0x8146c00) at alpm_list.c:371
371 {
(gdb) bt
#0  alpm_list_getdata (entry=0x8146c00) at alpm_list.c:371
#1  0x080512db in main (argc=3, argv=0xbf9d3d44) at pacman.c:535
(gdb) 

sudo ./pacman.static -Syu worked just fine though.  But, any attempt at
pacman.static -S <package> hung at "resolving dependencies..."

As I said before, below is the patch for compile errors on package.c.

~ Jamie / yankees26

Signed-off-by: James Rosten <seinfeld90 at gmail.com>
-------------- next part --------------
Index: package.c
===================================================================
RCS file: /home/cvs-pacman/pacman-lib/lib/libalpm/package.c,v
retrieving revision 1.47
diff -u -p -r1.47 package.c
--- package.c	19 Jan 2007 18:06:37 -0000	1.47
+++ package.c	21 Jan 2007 18:37:42 -0000
@@ -271,14 +271,23 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile)
 			/* parse the info file */
 			if(parse_descfile(descfile, info, 0) == -1) {
 				_alpm_log(PM_LOG_ERROR, _("could not parse the package description file"));
+				unlink(descfile);
+				FREE(descfile);
+				close(fd);
 				goto pkg_invalid;
 			}
 			if(!strlen(info->name)) {
 				_alpm_log(PM_LOG_ERROR, _("missing package name in %s"), pkgfile);
+				unlink(descfile);
+				FREE(descfile);
+				close(fd);
 				goto pkg_invalid;
 			}
 			if(!strlen(info->version)) {
 				_alpm_log(PM_LOG_ERROR, _("missing package version in %s"), pkgfile);
+				unlink(descfile);
+				FREE(descfile);
+				close(fd);
 				goto pkg_invalid;
 			}
 			config = 1;
@@ -351,9 +360,6 @@ pmpkg_t *_alpm_pkg_load(char *pkgfile)
 
 pkg_invalid:
 	pm_errno = PM_ERR_PKG_INVALID;
-	unlink(descfile);
-	FREE(descfile);
-	close(fd);
 error:
 	FREEPKG(info);
 	archive_read_finish (archive);


More information about the pacman-dev mailing list