Commit 3d999c05 authored by Bernhard Link's avatar Bernhard Link

make splint happier

parent f799bfa8
......@@ -104,7 +104,7 @@ struct changes {
const char *firstcomponent;
};
static void freeentries(struct fileentry *entry) {
static void freeentries(/*@only@*/struct fileentry *entry) {
struct fileentry *h;
while( entry ) {
......@@ -122,7 +122,7 @@ static void freeentries(struct fileentry *entry) {
}
}
static void changes_free(struct changes *changes) {
static void changes_free(/*@only@*/struct changes *changes) {
if( changes != NULL ) {
free(changes->source);
free(changes->version);
......@@ -149,37 +149,37 @@ static retvalue newentry(struct fileentry **entry,const char *fileline,const cha
filetype type;
p = fileline;
while( *p && isspace(*p) )
while( *p !='\0' && isspace(*p) )
p++;
md5start = p;
while( *p && !isspace(*p) )
while( *p !='\0' && !isspace(*p) )
p++;
md5end = p;
while( *p && isspace(*p) )
while( *p !='\0' && isspace(*p) )
p++;
sizestart = p;
while( *p && !isspace(*p) )
while( *p !='\0' && !isspace(*p) )
p++;
sizeend = p;
while( *p && isspace(*p) )
while( *p !='\0' && isspace(*p) )
p++;
sectionstart = p;
while( *p && !isspace(*p) )
while( *p !='\0' && !isspace(*p) )
p++;
sectionend = p;
while( *p && isspace(*p) )
while( *p !='\0' && isspace(*p) )
p++;
priostart = p;
while( *p && !isspace(*p) )
while( *p !='\0' && !isspace(*p) )
p++;
prioend = p;
while( *p && isspace(*p) )
while( *p !='\0' && isspace(*p) )
p++;
filestart = p;
while( *p && !isspace(*p) )
while( *p !='\0' && !isspace(*p) )
p++;
fileend = p;
while( *p && isspace(*p) )
while( *p !='\0' && isspace(*p) )
p++;
if( *p != '\0' ) {
fprintf(stderr,"Unexpected sixth argument in '%s'!\n",fileline);
......@@ -217,7 +217,7 @@ static retvalue newentry(struct fileentry **entry,const char *fileline,const cha
* and be either .deb or .udeb */
p++;
archstart = p;
while( *p && *p != '.' )
while( *p !='\0' && *p != '.' )
p++;
if( *p != '.' ) {
fprintf(stderr,"Expect something of the form name_version_arch.[u]deb but got '%s'!\n",filestart);
......@@ -226,7 +226,7 @@ static retvalue newentry(struct fileentry **entry,const char *fileline,const cha
archend = p;
p++;
typestart = p;
while( *p && !isspace(*p) )
while( *p !='\0' && !isspace(*p) )
p++;
if( p-typestart == 3 && strncmp(typestart,"deb",3) == 0 )
type = fe_DEB;
......@@ -243,7 +243,7 @@ static retvalue newentry(struct fileentry **entry,const char *fileline,const cha
} else {
/* this looks like some source-package, we will have
* to look for the packagetype ourself... */
while( *p && !isspace(*p) ) {
while( *p !='\0' && !isspace(*p) ) {
p++;
}
if( p-versionstart > 12 && strncmp(p-12,".orig.tar.gz",12) == 0 )
......@@ -346,7 +346,7 @@ static retvalue check(const char *filename,struct changes *changes,const char *f
return r;
}
static retvalue changes_read(const char *filename,struct changes **changes,const char *packagetypeonly,const char *forcearchitecture,int force, bool_t onlysigned) {
static retvalue changes_read(const char *filename,/*@out@*/struct changes **changes,/*@null@*/const char *packagetypeonly,/*@null@*/const char *forcearchitecture,int force, bool_t onlysigned) {
retvalue r;
struct changes *c;
struct strlist filelines;
......@@ -424,7 +424,7 @@ static retvalue changes_read(const char *filename,struct changes **changes,const
#undef R
}
static retvalue changes_fixfields(const struct distribution *distribution,const char *filename,struct changes *changes,const char *forcecomponent,const char *forcesection,const char *forcepriority,const struct overrideinfo *srcoverride,const struct overrideinfo *override) {
static retvalue changes_fixfields(const struct distribution *distribution,const char *filename,struct changes *changes,/*@null@*/const char *forcecomponent,/*@null@*/const char *forcesection,/*@null@*/const char *forcepriority,/*@null@*/const struct overrideinfo *srcoverride,/*@null@*/const struct overrideinfo *override) {
struct fileentry *e;
retvalue r;
......@@ -542,7 +542,7 @@ static retvalue changes_fixfields(const struct distribution *distribution,const
}
static inline retvalue checkforarchitecture(const struct fileentry *e,const char *architecture ) {
while( e && strcmp(e->architecture,architecture) != 0 )
while( e !=NULL && strcmp(e->architecture,architecture) != 0 )
e = e->next;
if( e == NULL ) {
fprintf(stderr,"Architecture-header lists architecture '%s', but no files for this!\n",architecture);
......@@ -551,7 +551,7 @@ static inline retvalue checkforarchitecture(const struct fileentry *e,const char
return RET_OK;
}
static retvalue changes_check(const char *filename,struct changes *changes,const char *forcearchitecture) {
static retvalue changes_check(const char *filename,struct changes *changes,/*@null@*/const char *forcearchitecture) {
int i;
struct fileentry *e;
retvalue r = RET_OK;
......@@ -657,7 +657,7 @@ static retvalue changes_includefiles(filesdb filesdb,const char *filename,struct
e = changes->files;
while( e ) {
if( FE_SOURCE(e->type) ) {
assert(changes->srcdirectory);
assert(changes->srcdirectory!=NULL);
e->filekey = calc_dirconcat(changes->srcdirectory,e->basename);
} else {
char *directory;
......@@ -687,7 +687,7 @@ static retvalue changes_includefiles(filesdb filesdb,const char *filename,struct
return r;
}
static retvalue changes_includepkgs(const char *dbdir,references refs,filesdb filesdb,struct distribution *distribution,struct changes *changes,const struct overrideinfo *srcoverride,const struct overrideinfo *binoverride,int force,struct strlist *dereferencedfilekeys, bool_t onlysigned) {
static retvalue changes_includepkgs(const char *dbdir,references refs,filesdb filesdb,struct distribution *distribution,struct changes *changes,/*@null@*/const struct overrideinfo *srcoverride,/*@null@*/const struct overrideinfo *binoverride,int force,/*@null@*/struct strlist *dereferencedfilekeys, bool_t onlysigned) {
struct fileentry *e;
retvalue r;
bool_t somethingwasmissed = FALSE;
......@@ -727,8 +727,8 @@ static retvalue changes_includepkgs(const char *dbdir,references refs,filesdb fi
if( r == RET_NOTHING )
somethingwasmissed = TRUE;
} else if( e->type == fe_DSC ) {
assert(changes->srccomponent);
assert(changes->srcdirectory);
assert(changes->srccomponent!=NULL);
assert(changes->srcdirectory!=NULL);
r = dsc_add(dbdir,refs,filesdb,
changes->srccomponent,e->section,e->priority,
distribution,fullfilename,
......
......@@ -103,7 +103,7 @@ struct debpackage {
char *md5sum;
};
void deb_free(struct debpackage *pkg) {
static void deb_free(/*@only@*/struct debpackage *pkg) {
if( pkg ) {
free(pkg->package);free(pkg->version);
free(pkg->source);free(pkg->architecture);
......@@ -118,7 +118,7 @@ void deb_free(struct debpackage *pkg) {
}
/* read the data from a .deb, make some checks and extract some data */
retvalue deb_read(struct debpackage **pkg, const char *filename) {
static retvalue deb_read(/*@out@*/struct debpackage **pkg, const char *filename) {
retvalue r;
struct debpackage *deb;
......@@ -206,7 +206,7 @@ retvalue deb_read(struct debpackage **pkg, const char *filename) {
}
/* do overwrites, add Filename, Size and md5sum to the control-item */
retvalue deb_complete(struct debpackage *pkg,const struct overrideinfo *override) {
static retvalue deb_complete(struct debpackage *pkg,const struct overrideinfo *override) {
const char *size;
struct fieldtoadd *replace;
char *newchunk;
......@@ -250,7 +250,7 @@ retvalue deb_complete(struct debpackage *pkg,const struct overrideinfo *override
return RET_OK;
}
static retvalue deb_calclocations(struct debpackage *pkg,const char *givenfilekey,const char *packagetype) {
static retvalue deb_calclocations(struct debpackage *pkg,/*@null@*/const char *givenfilekey,const char *packagetype) {
retvalue r;
char *basename;
......@@ -259,13 +259,15 @@ static retvalue deb_calclocations(struct debpackage *pkg,const char *givenfileke
return RET_ERROR_OOM;
r = binaries_calcfilekeys(pkg->component,pkg->source,basename,&pkg->filekeys);
if( RET_WAS_ERROR(r) )
if( RET_WAS_ERROR(r) ) {
free(basename);
return r;
}
pkg->filekey = pkg->filekeys.values[0];
free(basename);
if( givenfilekey && strcmp(givenfilekey,pkg->filekey) != 0 ) {
if( givenfilekey!=NULL && strcmp(givenfilekey,pkg->filekey) != 0 ) {
fprintf(stderr,"Name mismatch, .changes indicates '%s', but the file itself says '%s'!\n",givenfilekey,pkg->filekey);
return RET_ERROR;
}
......@@ -301,7 +303,7 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
const struct strlist *components;
int i;
assert( (givenmd5sum && givenfilekey) ||
assert( (givenmd5sum!=NULL && givenfilekey!=NULL ) ||
(givenmd5sum==NULL && givenfilekey==NULL ) );
//TODO: add some check here to make sure it is really a .deb file...
......@@ -368,10 +370,10 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
/* some sanity checks: */
if( forcearchitecture && strcmp(forcearchitecture,"all") == 0 )
if( forcearchitecture != NULL && strcmp(forcearchitecture,"all") == 0 )
forcearchitecture = NULL;
if( forcearchitecture &&
if( forcearchitecture != NULL &&
strcmp(pkg->architecture,forcearchitecture) != 0 &&
strcmp(pkg->architecture,"all") != 0 ) {
fprintf(stderr,"Cannot checking in '%s' into architecture '%s', as it is '%s'!",
......@@ -387,10 +389,10 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
return RET_ERROR;
} else if( strcmp(pkg->architecture,"all") != 0 &&
!strlist_in( &distribution->architectures, pkg->architecture )) {
fprintf(stderr,"While checking in '%s': '%s' is not listed in '",
(void)fprintf(stderr,"While checking in '%s': '%s' is not listed in '",
debfilename,pkg->architecture);
strlist_fprint(stderr,&distribution->architectures);
fputs("'\n",stderr);
(void)strlist_fprint(stderr,&distribution->architectures);
(void)fputs("'\n",stderr);
if( force <= 0 ) {
deb_free(pkg);
return RET_ERROR;
......@@ -410,7 +412,7 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
/* then looking if we already have this, or copy it in */
if( givenfilekey && givenmd5sum ) {
if( givenfilekey != NULL && givenmd5sum != NULL ) {
assert( delete == D_INPLACE );
r = deb_checkfiles(pkg,givenmd5sum);
} else
......@@ -451,7 +453,7 @@ retvalue deb_add(const char *dbdir,references refs,filesdb filesdb,const char *f
}
RET_UPDATE(result,r);
} else for( i = 0 ; i < distribution->architectures.count ; i++ ) {
struct target *t;
/*@dependent@*/struct target *t;
if( strcmp(distribution->architectures.values[i],"source") == 0 )
continue;
t = distribution_getpart(distribution,pkg->component,distribution->architectures.values[i],packagetype);
......
......@@ -8,6 +8,6 @@
/* return error if those are not proper versions,
* otherwise RET_OK and result is <0, ==0 or >0, if first is smaller, equal or larger */
retvalue dpkgversions_cmp(const char *first,const char *second,int *result);
retvalue dpkgversions_cmp(const char *first,const char *second,/*@out@*/int *result);
#endif
......@@ -128,7 +128,7 @@ retvalue files_add(filesdb db,const char *filekey,const char *md5sum) {
}
}
static retvalue files_get(filesdb db,const char *filekey,char **md5sum) {
static retvalue files_get(filesdb db,const char *filekey,/*@out@*/char **md5sum) {
int dbret;
DBT key,data;
......@@ -195,7 +195,7 @@ retvalue files_deleteandremove(filesdb filesdb,const char *filekey) {
return r;
}
static retvalue files_calcmd5(char **md5sum,const char *filename) {
static retvalue files_calcmd5(/*@out@*/char **md5sum,const char *filename) {
retvalue ret;
*md5sum = NULL;
......@@ -367,9 +367,9 @@ retvalue files_foreach(filesdb db,per_file_action action,void *privdata) {
return result;
}
struct checkfiledata { filesdb filesdb ; bool_t fast ; };
struct checkfiledata { /*@temp@*/filesdb filesdb ; bool_t fast ; };
static retvalue getfilesize(off_t *s,const char *md5sum) {
static retvalue getfilesize(/*@out@*/off_t *s,const char *md5sum) {
const char *p;
p = md5sum;
......
......@@ -58,10 +58,10 @@ retvalue files_printmissing(filesdb filesdb,const struct strlist *filekeys,const
* (the original file is not deleted in that case, even if delete is positive)
* 4) add it to the database
*/
retvalue files_include(filesdb filesdb,const char *sourcefilename,const char *filekey, const char *md5sum, char **calculatedmd5sum, int delete);
retvalue files_include(filesdb filesdb,const char *sourcefilename,const char *filekey, /*@null@*/const char *md5sum, /*@null@*/char **calculatedmd5sum, int delete);
/* same as above, but use sourcedir/basename instead of sourcefilename */
retvalue files_includefile(filesdb filesdb,const char *sourcedir,const char *basename, const char *filekey, const char *md5sum, char **calculatedmd5sum, int delete);
retvalue files_includefile(filesdb filesdb,const char *sourcedir,const char *basename, const char *filekey, const char *md5sum, /*@null@*/char **calculatedmd5sum, int delete);
/* the same, but with multiple files */
retvalue files_includefiles(filesdb filesdb,const char *sourcedir,const struct strlist *basenames, const struct strlist *filekeys, const struct strlist *md5sums, int delete);
......
......@@ -33,7 +33,7 @@
extern int verbose;
static void filterlistitems_free(struct filterlistitem *list) {
static void filterlistitems_free(/*@null@*//*@only@*/struct filterlistitem *list) {
while( list ) {
struct filterlistitem *next = list->next;
free(list->packagename);
......@@ -101,7 +101,7 @@ retvalue filterlist_load(struct filterlist *list, const char *confdir,const char
if( lineend == NULL ) {
fprintf(stderr,"Overlong line in '%s'!\n",filename);
free(fullfilename);
fclose(f);
(void)fclose(f);
filterlistitems_free(root);
return RET_ERROR;
}
......@@ -122,7 +122,7 @@ retvalue filterlist_load(struct filterlist *list, const char *confdir,const char
if( *what == '\0' ) {
fprintf(stderr,"Malformed line in '%s': %d!\n",filename,lineno);
free(fullfilename);
fclose(f);
(void)fclose(f);
filterlistitems_free(root);
return RET_ERROR;
}
......@@ -139,7 +139,7 @@ retvalue filterlist_load(struct filterlist *list, const char *confdir,const char
} else {
fprintf(stderr,"Unknown status in '%s':%d: '%s'!\n",filename,lineno,what);
free(fullfilename);
fclose(f);
(void)fclose(f);
filterlistitems_free(root);
return RET_ERROR;
}
......@@ -151,23 +151,30 @@ retvalue filterlist_load(struct filterlist *list, const char *confdir,const char
if( cmp == 0 ) {
fprintf(stderr,"Two lines describing '%s' in '%s'!\n",namestart,filename);
free(fullfilename);
fclose(f);
(void)fclose(f);
filterlistitems_free(root);
return RET_ERROR;
}
h = calloc(1,sizeof(*h));
if( h == NULL ) {
free(fullfilename);
(void)fclose(f);
filterlistitems_free(root);
return RET_ERROR_OOM;
}
h->next = *last;
*last = h;
h->what = type;
h->packagename = strdup(namestart);
if( h->packagename == NULL ) {
free(fullfilename);
fclose(f);
(void)fclose(f);
filterlistitems_free(root);
return RET_ERROR_OOM;
}
}
free(fullfilename);
// Can this be an error? was read-only..
fclose(f);
list->root = root;
list->last = root;
......@@ -181,9 +188,9 @@ void filterlist_empty(struct filterlist *list, enum filterlisttype defaulttype)
list->defaulttype = defaulttype;
}
static inline bool_t find(const char *name,struct filterlist *list) {
static inline bool_t find(const char *name,/*@null@*/struct filterlist *list) {
int cmp;
const struct filterlistitem *last = list->last;
/*@dependent@*/const struct filterlistitem *last = list->last;
assert( last != NULL );
......@@ -226,7 +233,7 @@ static inline bool_t find(const char *name,struct filterlist *list) {
}
enum filterlisttype filterlist_find(const char *name,struct filterlist *list) {
if( list->root && find(name,list) ) {
if( list->root != NULL && find(name,list) ) {
return list->last->what;
} else {
return list->defaulttype;
......
......@@ -10,21 +10,24 @@ enum filterlisttype {
};
struct filterlistitem {
/*@owned@*//*@null@*/
struct filterlistitem *next;
char *packagename;
enum filterlisttype what;
};
struct filterlist {
/*@owned@*//*@null@*/
struct filterlistitem *root;
/*@dependent@*//*@null@*/
const struct filterlistitem *last;
/* to be used when not found */
enum filterlisttype defaulttype;
};
retvalue filterlist_load(struct filterlist *list, const char *confdir, const char *filename);
void filterlist_empty(struct filterlist *list, enum filterlisttype defaulttype);
retvalue filterlist_load(/*@out@*/struct filterlist *list, const char *confdir, const char *filename);
void filterlist_empty(/*@out@*/struct filterlist *list, enum filterlisttype defaulttype);
void filterlist_release(struct filterlist *list);
......
......@@ -53,10 +53,10 @@ retvalue guess_component(const char *codename,const struct strlist *components,
if( givencomponent ) {
if( givencomponent && !strlist_in(components,givencomponent) ) {
fprintf(stderr,"Could not find '%s' in components of '%s': ",
(void)fprintf(stderr,"Could not find '%s' in components of '%s': ",
givencomponent,codename);
strlist_fprint(stderr,components);
fputs("'\n",stderr);
(void)strlist_fprint(stderr,components);
(void)fputs("'\n",stderr);
return RET_ERROR;
}
......
......@@ -12,6 +12,6 @@
retvalue guess_component(const char *codename,const struct strlist *components,
const char *package,const char *section,
const char *givencomponent,char **component);
/*@null@*/const char *givencomponent,char **component);
#endif
......@@ -71,7 +71,7 @@ retvalue add_ignore(const char *given) {
g = given;
while( 1 ) {
while( TRUE ) {
p = g;
while( *p != '\0' && *p !=',' )
p++;
......
......@@ -23,6 +23,7 @@
#include <stdio.h>
#include <getopt.h>
#include <string.h>
#include <strings.h>
#include <malloc.h>
#include <fcntl.h>
#include "error.h"
......@@ -69,7 +70,7 @@ static char /*@only@*/ /*@notnull@*/ // *g*
*confdir = NULL,
*overridedir = NULL,
*methoddir = NULL;
static char /*@null@*/
static char /*@only@*/ /*@null@*/
*section = NULL,
*priority = NULL,
*component = NULL,
......@@ -1370,18 +1371,23 @@ int main(int argc,char *argv[]) {
}
break;
case 'C':
free(component);
component = strdup(optarg);
break;
case 'A':
free(architecture);
architecture = strdup(optarg);
break;
case 'T':
free(packagetype);
packagetype = strdup(optarg);
break;
case 'S':
free(section);
section = strdup(optarg);
break;
case 'P':
free(priority);
priority = strdup(optarg);
break;
case '?':
......
......@@ -54,7 +54,7 @@ static char tab[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','
return RET_OK;
}
static retvalue md5sum_calc(int infd,int outfd, char **result, size_t bufsize) {
static retvalue md5sum_calc(int infd,int outfd, /*@out@*/char **result, size_t bufsize) {
struct MD5Context context;
unsigned char *buffer;
off_t filesize;
......
......@@ -6,7 +6,7 @@
/* This is just a asprintf-wrapper to be more easily used
* and alwasy returns NULL on error */
char * mprintf(const char *fmt,...) __attribute__ ((format (printf, 1, 2)));
char * vmprintf(const char *fmt,va_list va);
/*@null@*/char * mprintf(const char *fmt,...) __attribute__ ((format (printf, 1, 2)));
/*@null@*/char * vmprintf(const char *fmt,va_list va);
#endif
......@@ -30,6 +30,8 @@
extern int verbose;
typedef unsigned char uchar;
/* check if the character starting where <character> points
* at is a overlong one */
static inline bool_t overlongUTF8(const char *character) {
......@@ -40,30 +42,34 @@ static inline bool_t overlongUTF8(const char *character) {
* this out if we knew it is utf8 we arec coping
* with. (Well, you should not use --ignore=validchars
* anyway). */
unsigned char c = *character;
uchar c = *character;
if( (c & 0xC2 /*11000010*/) == 0xC0 /*11000000*/ ) {
unsigned char nextc = *(character+1);
if( (c & (uchar)0xC2 /*11000010*/) == (uchar)0xC0 /*11000000*/ ) {
uchar nextc = *(character+1);
if( (nextc & 0xC0 /*11000000*/ ) != 0x80 /*10000000*/ )
if( (nextc & (uchar)0xC0 /*11000000*/ ) != (uchar)0x80 /*10000000*/ )
return FALSE;
if( (c & 0x3E /* 00111110 */ ) == 0 )
if( (c & (uchar)0x3E /* 00111110 */ ) == (uchar)0 )
return TRUE;
if( c == 0xE0 /*11100000*/ && (nextc & 0x20 /*00100000*/ ) == 0)
if( c == (uchar)0xE0 /*11100000*/ &&
(nextc & (uchar)0x20 /*00100000*/ ) == (uchar)0)
return TRUE;
if( c == 0xF0 /*11110000*/ && (nextc & 0x30 /*00110000*/ ) == 0)
if( c == (uchar)0xF0 /*11110000*/ &&
(nextc & (uchar)0x30 /*00110000*/ ) == (uchar)0)
return TRUE;
if( c == 0xF8 /*11111000*/ && (nextc & 0x38 /*00111000*/ ) == 0)
if( c == (uchar)0xF8 /*11111000*/ &&
(nextc & (uchar)0x38 /*00111000*/ ) == (uchar)0)
return TRUE;
if( c == 0xFC /*11111100*/ && (nextc & 0x3C /*00111100*/ ) == 0)
if( c == (uchar)0xFC /*11111100*/ &&
(nextc & (uchar)0x3C /*00111100*/ ) == (uchar)0)
return TRUE;
}
return FALSE;
}
#define REJECTLOWCHARS(s,str,descr) \
if( (unsigned char)*s < ' ' ) { \
if( (uchar)*s < (uchar)' ' ) { \
fprintf(stderr, \
"Character 0x%02hhx not allowed within %s '%s'!\n", \
*s,descr,str); \
......@@ -97,7 +103,7 @@ retvalue propersourcename(const char *string) {
return RET_ERROR;
}
s = string;
while( *s ) {
while( *s != '\0' ) {
if( (*s > 'z' || *s < 'a' ) &&
(*s > '9' || *s < '0' ) &&
(firstcharacter ||
......@@ -596,7 +602,6 @@ retvalue calc_dirconcats(const char *directory, const struct strlist *basefilena
}
r = strlist_add(files,file);
if( RET_WAS_ERROR(r) ) {
free(file);
strlist_done(files);
return r;
}
......
......@@ -23,10 +23,10 @@ char *calc_downloadedlistfile(const char *listdir,const char *codename,const cha
char *calc_downloadedlistpattern(const char *codename);
/* Create a strlist consisting out of calc_dirconcat'ed entries of the old */
retvalue calc_dirconcats(const char *directory, const struct strlist *basefilenames,struct strlist *files);
retvalue calc_dirconcats(const char *directory, const struct strlist *basefilenames,/*@out@*/struct strlist *files);
/* split a "<md5> <size> <filename>" into md5sum and filename */
retvalue calc_parsefileline(const char *fileline,char **filename,char **md5sum);
retvalue calc_parsefileline(const char *fileline,/*@out@*/char **filename,/*@out@*//*@null@*/char **md5sum);
/* move over a version number, if epochsuppresed is true, colons may happen even without epoch there */
void names_overversion(const char **version,bool_t epochsuppressed);
......
......@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <malloc.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include <time.h>
#include <zlib.h>
......@@ -60,6 +61,8 @@ static inline retvalue newoverrideinfo(const char *firstpart,const char *secondp
char *p;
last = calloc(1,sizeof(struct overrideinfo));
if( last == NULL )
return RET_ERROR_OOM;
last->packagename=strdup(firstpart);
r = strlist_init_n(6,&last->fields);
if( RET_WAS_ERROR(r) ) {
......@@ -116,7 +119,7 @@ retvalue override_read(const char *overridedir,const char *filename,struct overr
if( buffer[l-1] != '\n' ) {
if( l >= 999 ) {
fprintf(stderr,"Too long line in '%s'!\n",filename);
fclose(file);
(void)fclose(file);
return RET_ERROR;
}
fprintf(stderr,"Missing line-terminator in '%s'!\n",filename);
......@@ -131,20 +134,20 @@ retvalue override_read(const char *overridedir,const char *filename,struct overr
if( l== 0 )
continue;
p = buffer;
while( *p && isspace(*p) )
while( *p !='\0' && isspace(*p) )
*(p++)='\0';
firstpart = p;
while( *p && !isspace(*p) )
while( *p !='\0' && !isspace(*p) )
p++;
while( *p && isspace(*p) )
while( *p !='\0' && isspace(*p) )
*(p++)='\0';
secondpart = p;
while( *p && !isspace(*p) )
while( *p !='\0' && !isspace(*p) )
p++;
while( *p && isspace(*p) )
while( *p !='\0' && isspace(*p) )
*(p++)='\0';
thirdpart = p;
if( !last || ( strcmp(last->packagename,firstpart) > 0 &&
if( last == NULL || ( strcmp(last->packagename,firstpart) > 0 &&
strcmp(root->packagename,firstpart) > 0 )) {
/* adding in front of it */
r = newoverrideinfo(firstpart,secondpart,thirdpart,&root);
......@@ -156,7 +159,7 @@ retvalue override_read(const char *overridedir,const char *filename,struct overr
if( strcmp(last->packagename,firstpart) > 0 )
last = root;
if( strcmp(last->packagename,firstpart) < 0 ) {
while( last->next &&
while( last->next != NULL &&
strcmp(last->next->packagename,firstpart) < 0) {
last = last->next;
}
......
......@@ -27,13 +27,13 @@ void override_free(/*@only@*//*@null@*/struct overrideinfo *info);
* otherwise from filename directly.. */
retvalue override_read(const char *overridedir,const char *filename,/*@out@*/struct overrideinfo **info);
const struct overrideinfo *override_search(const struct overrideinfo *overrides,const char *package);
const char *override_get(const struct overrideinfo *override,const char *field);
/*@null@*//*@dependent@*/const struct overrideinfo *override_search(/*@null@*/const struct overrideinfo *overrides,const char *package);
/*@null@*//*@dependent@*/const char *override_get(/*@null@*/const struct overrideinfo *override,const char *field);
/* add new fields to otherreplaces, but not "Section", or "Priority".
* incorporates otherreplaces, or frees them on error */
struct fieldtoadd *override_addreplacefields(const struct overrideinfo *override,
struct fieldtoadd *otherreplaces);
/*@null@*/struct fieldtoadd *override_addreplacefields(const struct overrideinfo *override,
/*@only@*/struct fieldtoadd *otherreplaces);
#endif
......@@ -42,12 +42,13 @@ retvalue packages_get(packagesdb db,const char *package,/*@out@*/char **chunk);
/* insert a chunk in the packages database, adding and deleting
* references and insert files while that.
* free oldfiles, if != NULL, add filekeys losing reference to derferencedfilekeys*/
* unreference oldfiles, if != NULL, and strlist_done it!
* if != NULL, add filekeys losing reference to derferencedfilekeys*/
retvalue packages_insert(references refs, packagesdb packagesdb,
const char *packagename, const char *controlchunk,
const struct strlist *files,
struct strlist *oldfiles,
struct strlist *dereferencedfilekeys);
/*@null@*/struct strlist *oldfiles,
/*@null@*/struct strlist *dereferencedfilekeys);
/* action to be called by packages_forall */
typedef retvalue per_package_action(void *data,const char *package,/*@temp@*/const char *chunk);
......
......@@ -30,8 +30,8 @@ retvalue references_insert(references ref,const char *identifer,
* if dereferencedfilekeys is != NULL, add those losing one reference,
* files will be freed (or moved to dereferencedfilekeys) */
retvalue references_delete(references ref,const char *identifer,
struct strlist *files,const struct strlist *exclude,
struct strlist *dereferencedfilekeys);
struct strlist *files,/*@null@*/const struct strlist *exclude,
/*@null@*/struct strlist *dereferencedfilekeys);
/* add an reference to a file for an identifier. multiple calls
* will add multiple references to allow source packages to share
......
......@@ -63,8 +63,6 @@ retvalue release_getchecksums(const char *releasefile,struct strlist *info) {
}
r = chunk_read(fi,&chunk);
i = gzclose(fi);
if( i < 0)
return RET_ZERRNO(i);
if( !RET_IS_OK(r) ) {
fprintf(stderr,"Error reading %s.\n",releasefile);
if( r == RET_NOTHING )
......@@ -72,6 +70,11 @@ retvalue release_getchecksums(const char *releasefile,struct strlist *info) {
else
return r;
}
if( i < 0) {