Commit f3636318 authored by Bernhard Link's avatar Bernhard Link

make splint a bit happier and use some splint 3.1.2 annotations

parent 8e5ab48b
......@@ -36,7 +36,7 @@ strictbooleancheck:
SPLINT=splint
SPLITFLAGSFORVIM= -linelen 10000 -locindentspaces 0
SPLINTFLAGS= +posixlib $(SPLITFLAGSFORVIM)
SPLINTFLAGS= +posixlib -booltype bool -fixedformalarray +charint $(SPLITFLAGSFORVIM)
splint:
$(SPLINT) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) -D_GNU_SOURCE=1 $(SPLINTFLAGS) $(reprepro_SOURCES)
$(SPLINT) -DSPLINT=1 $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) -D_GNU_SOURCE=1 $(SPLINTFLAGS) $(foreach file,$(reprepro_SOURCES),$(srcdir)/$(file))
......@@ -7,8 +7,8 @@ typedef enum { fe_UNKNOWN=0,fe_DEB,fe_UDEB,fe_DSC,fe_DIFF,fe_ORIG,fe_TAR} filety
#define FE_BINARY(ft) ( (ft) == fe_DEB || (ft) == fe_UDEB )
#define FE_SOURCE(ft) ( (ft) == fe_DIFF || (ft) == fe_ORIG || (ft) == fe_TAR || (ft) == fe_DSC || (ft) == fe_UNKNOWN)
retvalue changes_parsefileline(const char *fileline, filetype *result_type,
char **result_basename, char **result_md5sum,
char **result_section, char **result_priority,
char **result_architecture, char **result_name);
retvalue changes_parsefileline(const char *fileline, /*@out@*/filetype *result_type,
/*@out@*/char **result_basename, /*@out@*/char **result_md5sum,
/*@out@*/char **result_section, /*@out@*/char **result_priority,
/*@out@*/char **result_architecture, /*@out@*/char **result_name);
#endif
This diff is collapsed.
......@@ -16,7 +16,7 @@ struct checksums;
void checksums_free(/*@only@*//*@null@*/struct checksums *);
/* duplicate a checksum record, NULL means OOM */
struct checksums *checksums_dup(const struct checksums *);
/*@null@*/struct checksums *checksums_dup(const struct checksums *);
/* create a checksum record from an md5sum: */
retvalue checksums_set(/*@out@*/struct checksums **, /*@only@*/char *);
......@@ -69,12 +69,13 @@ void checksums_printdifferences(FILE *,const struct checksums *expected, const s
retvalue checksums_combine(struct checksums **checksums, const struct checksums *by);
typedef /*@only@*/ struct checksums *ownedchecksums;
struct checksumsarray {
struct strlist names;
/*@null@*/struct checksums **checksums;
/*@null@*/ownedchecksums *checksums;
};
void checksumsarray_move(/*@out@*/struct checksumsarray *, struct checksumsarray *);
void checksumsarray_done(struct checksumsarray *);
void checksumsarray_move(/*@out@*/struct checksumsarray *, /*@special@*/struct checksumsarray *array)/*@requires maxSet(array->names.values) >= array->names.count /\ maxSet(array->checksums) >= array->names.count @*/ /*@releases array->checksums, array->names.values @*/;
void checksumsarray_done(/*@special@*/struct checksumsarray *array) /*@requires maxSet(array->names.values) >= array->names.count /\ maxSet(array->checksums) >= array->names.count @*/ /*@releases array->checksums, array->names.values @*/;
retvalue checksumsarray_parse(/*@out@*/struct checksumsarray *, const struct strlist *, const char *filenametoshow);
retvalue checksumsarray_include(struct checksumsarray *, /*@only@*/char *, const struct checksums *);
......
......@@ -298,7 +298,7 @@ retvalue configfile_parse(const char *confdir, const char *filename, bool ignore
!RET_WAS_ERROR(result));
RET_UPDATE(result, r);
}
if( ferror(iter.f) ) {
if( ferror(iter.f) != 0) {
int e = errno;
fprintf(stderr, "Error reading config file '%s': %s(%d)\n",
iter.filename, strerror(e), e);
......@@ -501,6 +501,7 @@ retvalue config_getuniqwords(struct configiterator *iter, const char *header, ch
"Malformed %s-header element '%s': %s\n", header, value, errormessage);
checkerror_free(errormessage);
free(value);
strlist_done(&data);
return RET_ERROR;
} else {
r = strlist_add(&data, value);
......@@ -614,7 +615,7 @@ retvalue config_getconstant(struct configiterator *iter, const struct constant *
}
retvalue config_getflags(struct configiterator *iter, const char *header, const struct constant *constants, bool *flags, bool ignoreunknown, const char *msg) {
retvalue r, result = RET_NOTHING;;
retvalue r, result = RET_NOTHING;
int option = -1;
while( (r = config_getconstant(iter, constants, &option)) != RET_NOTHING ) {
......@@ -794,7 +795,7 @@ retvalue config_getnumber(struct configiterator *iter, const char *name, long lo
return RET_OK;
}
static retvalue config_getline(struct configiterator *iter, char **result_p) {
static retvalue config_getline(struct configiterator *iter, /*@out@*/char **result_p) {
size_t size = 0, len = 0;
char *value = NULL, *nv;
int c;
......
......@@ -32,7 +32,7 @@ struct constant {
#define CFr(name, sname, field) {name, sizeof(name)-1, configparser_ ## sname ## _set_ ## field, true}
#define CF(name, sname, field) {name, sizeof(name)-1, configparser_ ## sname ## _set_ ## field, false}
const char *config_filename(const struct configiterator *) __attribute__((pure));
/*@observer@*/const char *config_filename(const struct configiterator *) __attribute__((pure));
unsigned int config_line(const struct configiterator *) __attribute__((pure));
unsigned int config_column(const struct configiterator *) __attribute__((pure));
unsigned int config_firstline(const struct configiterator *) __attribute__((pure));
......@@ -42,17 +42,17 @@ retvalue config_getflags(struct configiterator *, const char *, const struct con
int config_nextnonspaceinline(struct configiterator *iter);
retvalue config_getlines(struct configiterator *,struct strlist *);
retvalue config_getwords(struct configiterator *,struct strlist *);
retvalue config_getall(struct configiterator *iter, char **result_p);
retvalue config_getword(struct configiterator *, char **);
retvalue config_getwordinline(struct configiterator *, char **);
retvalue config_getonlyword(struct configiterator *, const char *, checkfunc, char **);
retvalue config_getall(struct configiterator *iter, /*@out@*/char **result_p);
retvalue config_getword(struct configiterator *, /*@out@*/char **);
retvalue config_getwordinline(struct configiterator *, /*@out@*/char **);
retvalue config_getonlyword(struct configiterator *, const char *, checkfunc, /*@out@*/char **);
retvalue config_getuniqwords(struct configiterator *, const char *, checkfunc, struct strlist *);
retvalue config_getsplitwords(struct configiterator *, const char *, struct strlist *, struct strlist *);
retvalue config_gettruth(struct configiterator *, const char *, bool *);
retvalue config_getnumber(struct configiterator *, const char *, long long *, long long minval, long long maxval);
retvalue config_getconstant(struct configiterator *, const struct constant *, int *);
#define config_getenum(iter,type,constants,result) ({int _val;retvalue _r = config_getconstant(iter, type ## _ ## constants, &_val);*(result) = (enum type)_val;_r;})
retvalue config_completeword(struct configiterator *, char, char **);
retvalue config_completeword(struct configiterator *, char, /*@out@*/char **);
void config_overline(struct configiterator *);
bool config_nextline(struct configiterator *);
retvalue configfile_parse(const char *confdir, const char *filename, bool ignoreunknown, configinitfunction, configfinishfunction, const struct configfield *, size_t, void *privdata);
......
......@@ -53,7 +53,7 @@ extern int verbose;
#define SETDBT(dbt, datastr) {const char *my = datastr; memset(&dbt, 0, sizeof(dbt)); dbt.data = (void *)my; dbt.size = strlen(my) + 1;}
#define SETDBTl(dbt, datastr, datasize) {const char *my = datastr; memset(&dbt, 0, sizeof(dbt)); dbt.data = (void *)my; dbt.size = datasize;}
static void database_free(struct database *db) {
static void database_free(/*@only@*/ struct database *db) {
if( db == NULL )
return;
free(db->directory);
......@@ -169,7 +169,7 @@ retvalue database_close(struct database *db) {
return result;
}
static retvalue database_hasdatabasefile(const struct database *database, const char *filename, bool *exists_p) {
static retvalue database_hasdatabasefile(const struct database *database, const char *filename, /*@out@*/bool *exists_p) {
char *fullfilename;
fullfilename = calc_dirconcat(database->directory, filename);
......@@ -200,7 +200,7 @@ const uint32_t types[dbt_COUNT] = {
static int paireddatacompare(UNUSED(DB *db), const DBT *a, const DBT *b);
static retvalue database_opentable(struct database *database, const char *filename, const char *subtable, enum database_type type, uint32_t flags, /*@out@*/DB **result) {
static retvalue database_opentable(struct database *database, const char *filename, /*@null@*/const char *subtable, enum database_type type, uint32_t flags, /*@out@*/DB **result) {
char *fullfilename;
DB *table;
int dbret;
......@@ -394,20 +394,20 @@ static retvalue warnidentifers(struct database *db, const struct strlist *identi
fprintf(stderr,
"Error: packages database contains unused '%s' database.\n", identifier);
if( ignored[IGN_undefinedtarget] == 0 ) {
fputs(
(void)fputs(
"This either means you removed a distribution, component or architecture from\n"
"the distributions config file without calling clearvanished, or your config\n"
"does not belong to this database.\n",
stderr);
}
if( IGNORABLE(undefinedtarget) ) {
fputs("Ignoring as --ignore=undefinedtarget given.\n",
(void)fputs("Ignoring as --ignore=undefinedtarget given.\n",
stderr);
ignored[IGN_undefinedtarget]++;
continue;
}
fputs("To ignore use --ignore=undefinedtarget.\n", stderr);
(void)fputs("To ignore use --ignore=undefinedtarget.\n", stderr);
return RET_ERROR;
}
for( d = distributions ; d != NULL ; d = d->next ) {
......@@ -449,32 +449,32 @@ static retvalue warnunusedtracking(const struct strlist *codenames, const struct
"Error: tracking database contains unused '%s' database.\n", codename);
if( ignored[IGN_undefinedtracking] == 0 ) {
if( d == NULL )
fputs(
(void)fputs(
"This either means you removed a distribution from the distributions config\n"
"file without calling clearvanished (or at least removealltracks), you were\n"
"bitten by a bug in retrack in versions < 3.0.0, you found a new bug or your\n"
"config does not belong to this database.\n",
stderr);
else
fputs(
(void)fputs(
"This either means you removed the Tracking: options from this distribution without\n"
"calling removealltracks for it, or your config does not belong to this database.\n",
stderr);
}
if( IGNORABLE(undefinedtracking) ) {
fputs("Ignoring as --ignore=undefinedtracking given.\n",
(void)fputs("Ignoring as --ignore=undefinedtracking given.\n",
stderr);
ignored[IGN_undefinedtracking]++;
continue;
}
fputs("To ignore use --ignore=undefinedtracking.\n", stderr);
(void)fputs("To ignore use --ignore=undefinedtracking.\n", stderr);
return RET_ERROR;
}
return RET_OK;
}
static retvalue readline(char **result, FILE *f, const char *versionfilename) {
static retvalue readline(/*@out@*/char **result, FILE *f, const char *versionfilename) {
char buffer[21];
size_t l;
......@@ -626,36 +626,35 @@ static retvalue writeversionfile(struct database *db) {
return RET_ERROR_OOM;
f = fopen(versionfilename, "w");
if( f == NULL ) {
int e = errno;
e = errno;
fprintf(stderr, "Error creating '%s': %s(errno is %d)\n",
versionfilename, strerror(e), e);
free(versionfilename);
return RET_ERRNO(e);
}
if( db->version == NULL )
fputs("0\n", f);
(void)fputs("0\n", f);
else {
fputs(db->version, f);
fputc('\n', f);
(void)fputs(db->version, f);
(void)fputc('\n', f);
}
if( db->lastsupportedversion == NULL )
fputs("0\n", f);
(void)fputs("0\n", f);
else {
fputs(db->lastsupportedversion, f);
fputc('\n', f);
(void)fputs(db->lastsupportedversion, f);
(void)fputc('\n', f);
}
if( db->dbversion == NULL )
fprintf(f, "bdb%d.%d.%d\n", DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH);
else {
fputs(db->dbversion, f);
fputc('\n', f);
(void)fputs(db->dbversion, f);
(void)fputc('\n', f);
}
if( db->lastsupporteddbversion == NULL )
fprintf(f, "bdb%d.%d.0\n", DB_VERSION_MAJOR, DB_VERSION_MINOR);
else {
fputs(db->lastsupporteddbversion, f);
fputc('\n', f);
(void)fputs(db->lastsupporteddbversion, f);
(void)fputc('\n', f);
}
e = ferror(f);
......@@ -1206,9 +1205,9 @@ retvalue table_newglobalcursor(struct table *table, struct cursor **cursor_p) {
}
static inline retvalue parse_pair(struct table *table, DBT Key, DBT Data, /*@null@*//*@out@*/const char **key_p, /*@out@*/const char **value_p, /*@out@*/const char **data_p, /*@out@*/size_t *datalen_p) {
const char *separator;
/*@dependant@*/ const char *separator;
if( Key.size <= 0 || Data.size <= 0 ||
if( Key.size == 0 || Data.size == 0 ||
((const char*)Key.data)[Key.size-1] != '\0' ||
((const char*)Data.data)[Data.size-1] != '\0' ) {
if( table->subname != NULL )
......@@ -1344,6 +1343,8 @@ retvalue table_newpairedcursor(struct table *table, const char *key, const char
fprintf(stderr,
"Database %s returned corrupted (not paired) data!",
table->name);
(void)cursor->cursor->c_close(cursor->cursor);
free(cursor);
return RET_ERROR;
}
if( data_p != NULL )
......@@ -1642,11 +1643,11 @@ retvalue database_opentracking(struct database *database, const char *codename,
retvalue r;
if( database->nopackages ) {
fputs("Internal Error: Accessing packages databse while that was not prepared!\n", stderr);
(void)fputs("Internal Error: Accessing packages databse while that was not prepared!\n", stderr);
return RET_ERROR;
}
if( database->trackingdatabaseopen ) {
fputs("Internal Error: Trying to open multiple tracking databases at the same time.\nThis should normaly not happen (to avoid triggering bugs in the underlying BerkleyDB)\n", stderr);
(void)fputs("Internal Error: Trying to open multiple tracking databases at the same time.\nThis should normaly not happen (to avoid triggering bugs in the underlying BerkleyDB)\n", stderr);
return RET_ERROR;
}
......@@ -1666,11 +1667,11 @@ retvalue database_openpackages(struct database *database, const char *identifier
retvalue r;
if( database->nopackages ) {
fputs("Internal Error: Accessing packages databse while that was not prepared!\n", stderr);
(void)fputs("Internal Error: Accessing packages databse while that was not prepared!\n", stderr);
return RET_ERROR;
}
if( database->packagesdatabaseopen ) {
fputs("Internal Error: Trying to open multiple packages databases at the same time.\nThis should normaly not happen (to avoid triggering bugs in the underlying BerkleyDB)\n", stderr);
(void)fputs("Internal Error: Trying to open multiple packages databases at the same time.\nThis should normaly not happen (to avoid triggering bugs in the underlying BerkleyDB)\n", stderr);
return RET_ERROR;
}
......@@ -1878,6 +1879,8 @@ retvalue database_translate_filelists(struct database *database) {
int e = errno;
fprintf(stderr, "Could not rename '%s' into '%s': %s(%d)\n",
dbname, tmpdbname, strerror(e), e);
free(dbname);
free(tmpdbname);
return RET_ERRNO(e);
}
newtable = NULL;
......@@ -1919,7 +1922,7 @@ retvalue database_translate_filelists(struct database *database) {
r2 = table_close(newtable);
RET_ENDUPDATE(r, r2);
if( RET_IS_OK(r) )
unlink(tmpdbname);
(void)unlink(tmpdbname);
if( RET_WAS_ERROR(r) ) {
ret = rename(tmpdbname, dbname);
......
......@@ -16,10 +16,10 @@ struct distribution;
struct table;
struct cursor;
retvalue database_create(struct database **, const char *dbdir, struct distribution *, bool fast, bool nopackages, bool allowunused, bool readonly, size_t waitforlock, bool verbosedb);
retvalue database_close(struct database *);
retvalue database_create(/*@out@*/struct database **, const char *dbdir, struct distribution *, bool fast, bool nopackages, bool allowunused, bool readonly, size_t waitforlock, bool verbosedb);
retvalue database_close(/*@only@*/struct database *);
const char *database_directory(struct database *);
/*@observer@*/ const char *database_directory(struct database *);
retvalue database_openfiles(struct database *, const char *mirrordir);
retvalue database_openreferences(struct database *);
......@@ -37,7 +37,7 @@ bool table_isempty(struct table *);
bool table_recordexists(struct table *, const char *);
/* retrieve a record from the database, return RET_NOTHING if there is none: */
retvalue table_getrecord(struct table *, const char *, /*@out@*/char **);
retvalue table_gettemprecord(struct table *, const char *, /*@out@*/const char **, /*@out@*/ size_t *);
retvalue table_gettemprecord(struct table *, const char *, /*@out@*//*@null@*/const char **, /*@out@*//*@null@*/size_t *);
retvalue table_getpair(struct table *, const char *, const char *, /*@out@*/const char **, /*@out@*/size_t *);
retvalue table_adduniqsizedrecord(struct table *, const char *key, const char *data, size_t data_size, bool allowoverwrote, bool nooverwrite);
......
......@@ -12,15 +12,15 @@ struct database {
char *directory;
/* for the files database: */
char *mirrordir;
struct table *checksums, *oldmd5sums, *contents;
/*@null@*/ struct table *checksums, *oldmd5sums, *contents;
/* for the references database: */
struct table *references;
/*@null@*/ struct table *references;
/* internal stuff: */
bool locked, verbose;
int dircreationdepth;
bool nopackages, readonly,
packagesdatabaseopen, trackingdatabaseopen;
char *version, *lastsupportedversion,
/*@null@*/ char *version, *lastsupportedversion,
*dbversion, *lastsupporteddbversion;
struct {
bool createnewtables;
......
......@@ -93,7 +93,6 @@ struct distribution {
};
retvalue distribution_get(struct distribution *all, const char *name, bool lookedat, /*@out@*/struct distribution **);
// retvalue distribution_free(/*@only@*/struct distribution *distribution);
/* set lookedat, start logger, ... */
retvalue distribution_prepareforwriting(struct distribution *distribution);
......
......@@ -33,7 +33,7 @@ void closefrom(int lowfd) {
if( maxopen < 0 )
maxopen = 1024;
for( fd = lowfd ; fd <= maxopen ; fd++ )
close(fd);
(void)close(fd);
}
#endif
......@@ -41,7 +41,7 @@ void markcloseonexec(int fd) {
long l;
l = fcntl(fd, F_GETFD, 0);
if( l >= 0 ) {
fcntl(fd, F_SETFD, l|FD_CLOEXEC);
(void)fcntl(fd, F_SETFD, l|FD_CLOEXEC);
}
}
......
......@@ -27,8 +27,8 @@ typedef int _Bool;
#define READONLY true
#define READWRITE false
#define ISSET(a,b) (a&b)!=0
#define NOTSET(a,b) (a&b)==0
#define ISSET(a,b) ((a&b)!=0)
#define NOTSET(a,b) ((a&b)==0)
#ifdef STUPIDCC
#define IFSTUPIDCC(a) a
......
......@@ -137,7 +137,7 @@ static retvalue incoming_prepare(struct incoming *i) {
continue;
r = strlist_add_dup(&i->files, ent->d_name) ;
if( RET_WAS_ERROR(r) ) {
closedir(dir);
(void)closedir(dir);
return r;
}
}
......
......@@ -42,10 +42,10 @@
extern int verbose;
/*@null@*/ static struct logfile {
struct logfile *next;
/*@null@*/ static /*@refcounted@*/ struct logfile {
/*@null@*/struct logfile *next;
char *filename;
size_t refcount;
/*@refs@*/size_t refcount;
int fd;
} *logfile_root = NULL;
......@@ -206,7 +206,7 @@ struct notificator {
bool withcontrol, changesacceptrule;
};
static void notificator_done(struct notificator *n) {
static void notificator_done(/*@special@*/struct notificator *n) /*@releases n->scriptname,n->packagename,n->component,n->architecture@*/{
free(n->scriptname);
free(n->packagetype);
free(n->component);
......@@ -393,11 +393,11 @@ static retvalue notificator_parse(struct notificator *n, const char *confdir, st
}
/*@null@*/ static struct notification_process {
struct notification_process *next;
/*@null@*/struct notification_process *next;
char **arguments;
/* data to send to the process */
size_t datalen, datasent;
char *data;
/*@null@*/char *data;
/* process */
pid_t child;
int fd;
......@@ -504,7 +504,7 @@ static void feedchildren(bool wait) {
"Error '%s' while sending data to '%s', sending SIGABRT to it!\n",
strerror(e),
p->arguments[0]);
kill(p->child, SIGABRT);
(void)kill(p->child, SIGABRT);
}
p->datasent += sent;
if( p->datasent >= p->datalen ) {
......@@ -557,7 +557,7 @@ static retvalue startchild(void) {
(void)close(filedes[0]);
}
/* Try to close all open fd but 0,1,2 */
close(filedes[1]);
(void)close(filedes[1]);
closefrom(3);
(void)execv(p->arguments[0], p->arguments);
fprintf(stderr, "Error executing '%s': %s\n", p->arguments[0],
......@@ -565,7 +565,7 @@ static retvalue startchild(void) {
_exit(255);
}
if( p->datalen > 0 ) {
close(filedes[0]);
(void)close(filedes[0]);
markcloseonexec(p->fd);
}
if( child < 0 ) {
......@@ -590,7 +590,7 @@ static retvalue startchild(void) {
return RET_ERROR;
}
if( (polldata.revents & POLLHUP) != 0 ) {
close(p->fd);
(void)close(p->fd);
p->fd = -1;
return RET_OK;
}
......@@ -607,12 +607,11 @@ static retvalue startchild(void) {
"Error '%s' while sending data to '%s', sending SIGABRT to it!\n",
strerror(e),
p->arguments[0]);
kill(p->child, SIGABRT);
(void)kill(p->child, SIGABRT);
return RET_ERRNO(e);
}
p->datasent += written;
if( p->datasent >= p->datalen ) {
int ret;
free(p->data);
p->data = NULL;
ret = close(p->fd);
......@@ -840,7 +839,7 @@ void logger_warn_waiting(void) {
struct notification_process *p;
if( processes != NULL ) {
fputs(
(void)fputs(
"WARNING: some notificator hooks were not run!\n"
"(most likely due to receiving an interruption request)\n"
"You will either have to run them by hand or run rerunnotifiers if\n"
......@@ -851,20 +850,20 @@ void logger_warn_waiting(void) {
if( c == NULL )
continue;
while( *c != NULL ) {
fputc('"', stderr);
fputs(*c, stderr);
fputc('"', stderr);
(void)fputc('"', stderr);
(void)fputs(*c, stderr);
(void)fputc('"', stderr);
c++;
if( *c != NULL )
fputc(' ', stderr);
(void)fputc(' ', stderr);
}
fputc('\n', stderr);
(void)fputc('\n', stderr);
}
}
}
struct logger {
/*@dependent@*/struct logfile *logfile;
/*@dependent@*//*@null@*/struct logfile *logfile;
size_t notificator_count;
struct notificator *notificators;
};
......
......@@ -2939,7 +2939,7 @@ int main(int argc,char *argv[]) {
sa.sa_flags = SA_ONESHOT;
#elif defined(SA_RESETHAND)
sa.sa_flags = SA_RESETHAND;
#else
#elif !defined(SPLINT)
# error "missing argument to sigaction!"
#endif
sa.sa_handler = interrupt_signaled;
......
......@@ -32,9 +32,8 @@ struct MD5Context {
UWORD32 in[16];
};
void MD5Init(struct MD5Context *context);
void MD5Init(/*@out@*/struct MD5Context *context);
void MD5Update(struct MD5Context *context, md5byte const *buf, unsigned int len);
void MD5Final(unsigned char digest[16], struct MD5Context *context);
//void MD5Transform(UWORD32 buf[4], UWORD32 const in[16]);
void MD5Final(/*@out@*/unsigned char digest[16], struct MD5Context *context);
#endif /* !MD5_H */
......@@ -37,7 +37,7 @@ static bool isbinarydata(const char *buffer, size_t len, const char *source) {
unsigned char c;
for( i = 0 ; i < len ; i++ ) {
c = buffer[i];
c = (unsigned char)buffer[i];
if( c < ' ' && c != '\t' && c != '\n' && c != '\r' ) {
fprintf(stderr, "Unexpected binary character \\%03hho in %s\n",
c, source);
......@@ -61,7 +61,7 @@ retvalue readtextfilefd(int fd, const char *source, char **data, size_t *len) {
/* text files are normaly small, so it does not hurt to check
* the whole of them always */
if( isbinarydata(buffer + readdata, readbytes, source) ) {
if( isbinarydata(buffer + readdata, (size_t)readbytes, source) ) {
free(buffer);
return RET_ERROR;
}
......@@ -91,6 +91,9 @@ retvalue readtextfilefd(int fd, const char *source, char **data, size_t *len) {
}
h = realloc(buffer, readdata + 1);
if( h == NULL ) {
#ifdef SPLINT
h = NULL;
#endif
if( readdata >= buffersize ) {
free(buffer);
return RET_ERROR_OOM;
......
......@@ -10,6 +10,6 @@ struct SHA1_Context {
void SHA1Init(/*@out@*/struct SHA1_Context *context);
void SHA1Update(struct SHA1_Context *context, const uint8_t *data, const size_t len);
void SHA1Final(struct SHA1_Context *context, uint8_t digest[SHA1_DIGEST_SIZE]);
void SHA1Final(struct SHA1_Context *context, /*@out@*/uint8_t digest[SHA1_DIGEST_SIZE]);
#endif
......@@ -18,7 +18,7 @@ struct strlist {
void strlist_init(/*@out@*/struct strlist *strlist);
retvalue strlist_init_n(int startsize,/*@out@*/struct strlist *strlist);
retvalue strlist_init_singleton(/*@only@*/char *value,/*@out@*/struct strlist *strlist);
void strlist_done(struct strlist *strlist);
void strlist_done(/*@special@*/struct strlist *strlist) /*@releases strlist->values @*/;
/* add a string, will get property of the strlist and free'd by it */
retvalue strlist_add(struct strlist *strlist,/*@only@*/char *element);
......@@ -35,9 +35,9 @@ retvalue strlist_fprint(FILE *file,const struct strlist *strlist);
/* duplicate with content */
retvalue strlist_dup(struct strlist *dest,const struct strlist *orig);
/* replace the contents of dest with those from orig, which get emptied */
void strlist_move(/*@out@*/struct strlist *dest,struct strlist *orig);
void strlist_move(/*@out@*/struct strlist *dest, /*@special@*/struct strlist *orig) /*@releases orig->values @*/;
/* empty orig and add everything to the end of dest, on error nothing is freed */
retvalue strlist_mvadd(struct strlist *dest,struct strlist *orig);
retvalue strlist_mvadd(struct strlist *dest, /*@special@*/struct strlist *orig) /*@releases orig->values @*/;
bool strlist_in(const struct strlist *strlist, const char *element);
int strlist_ofs(const struct strlist *strlist,const char *element);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment