Commit d2f320d7 authored by Bernhard Link's avatar Bernhard Link

some more changes to make splint less noisy

parent 0803e5be
......@@ -98,7 +98,7 @@ bool config_nextline(struct configiterator *iter) {
iter->eol = false;
return true;
}
ungetc(c, iter->f);
(void)ungetc(c, iter->f);
return false;
}
......@@ -277,7 +277,7 @@ retvalue configfile_parse(const char *confdir, const char *filename, bool ignore
c = fgetc(iter.f);
iter.column++;
} while( c == ' ' || c == '\t' );
ungetc(c, iter.f);
(void)ungetc(c, iter.f);
iter.eol = false;
if( i < fieldcount ) {
......
......@@ -61,18 +61,18 @@ retvalue contentsoptions_parse(struct distribution *distribution, struct configi
r = config_getflags(iter, "Contents", contentsflags, flags,
IGNORABLE(unknownfield), "");
if( r == RET_ERROR_UNKNOWNFIELD )
fputs(
(void)fputs(
"Note that the format of the Contents field has changed with reprepro 3.0.0.\n"
"There is no longer a number needed (nor possible) there.\n", stderr);
if( RET_WAS_ERROR(r) )
return r;
if( flags[cf_dummy] ) {
fputs(
(void)fputs(
"Warning: Contents-headers in conf/distribution no longer need an\n"
"rate argument. Ignoring the number there, this might cause a error\n"
"future versions.\n", stderr);
} else if( flags[cf_disable] ) {
fputs(
(void)fputs(
"Warning: Contents-headers in conf/distribution no longer need an\n"
"rate argument. Treating the '0' as sign to not activate Contents-\n"
"-generation, but it will cause an error in future version.\n", stderr);
......
......@@ -89,9 +89,11 @@ static retvalue database_lock(struct database *db, size_t waitforlock) {
int e = errno;
if( e == EEXIST ) {
if( tries < waitforlock && ! interrupted() ) {
unsigned int timetosleep = 10;
if( verbose >= 0 )
printf("Could not aquire lock: %s already exists!\nWaiting 10 seconds before trying again.\n", lockfile);
sleep(10);
while( timetosleep > 0 )
timetosleep = sleep(timetosleep);
tries++;
fd = open(lockfile,O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW|O_NOCTTY,S_IRUSR|S_IWUSR);
continue;
......@@ -804,7 +806,7 @@ retvalue database_create(struct database **result, const char *dbdir, struct dis
r = preparepackages(n, fast, readonly, allowunused, alldistributions);
if( RET_WAS_ERROR(r) ) {
database_close(n);
(void)database_close(n);
return r;
}
......
......@@ -769,7 +769,7 @@ static retvalue export(struct distribution *distribution, const char *distdir, s
workleft |= target->saved_wasmodified;
}
if( workleft ) {
fputs(
(void)fputs(
"This means that from outside your repository will still look like before (and\n"
"should still work if this old state worked), but the things you changed in this\n"
"call will not be visible until you call export directly (via reprepro export)\n"
......
......@@ -54,7 +54,7 @@ static const char *exportdescription(const struct exportmode *mode,char *buffer,
assert( buffersize > 50 );
*buffer++ = ' '; buffersize--;
*buffer++ = '('; buffersize--;
for( ic = 0 ; ic < ic_count ; ic++ ) {
for( ic = ic_first ; ic < ic_count ; ic++ ) {
if( (mode->compressions & IC_FLAG(ic)) != 0 ) {
size_t l = strlen(compression_names[ic]);
assert( buffersize > l+3 );
......
......@@ -364,9 +364,12 @@ retvalue files_printmissing(struct database *database, const struct strlist *fil
}
if( r == RET_NOTHING ) {
/* File missing */
fputs(origfile, stdout); putchar(' ');
fputs(database->mirrordir, stdout); putchar('/');
fputs(filekey, stdout); putchar('\n');
(void)fputs(origfile, stdout);
(void)putchar(' ');
(void)fputs(database->mirrordir, stdout);
(void)putchar('/');
(void)fputs(filekey, stdout);
(void)putchar('\n');
RET_UPDATE(ret,RET_OK);
} else
RET_UPDATE(ret,r);
......@@ -388,7 +391,8 @@ retvalue files_printmd5sums(struct database *database) {
while( cursor_nexttemp(database->checksums, cursor,
&filekey, &checksum) ) {
result = RET_OK;
fputs(filekey, stdout);putchar(' ');
(void)fputs(filekey, stdout);
(void)putchar(' ');
while( *checksum == ':' ) {
while( *checksum != ' ' &&
*checksum != '\0' )
......@@ -396,7 +400,8 @@ retvalue files_printmd5sums(struct database *database) {
if( *checksum == ' ' )
checksum++;
}
fputs(checksum, stdout);putchar('\n');
(void)fputs(checksum, stdout);
(void)putchar('\n');
}
r = cursor_close(database->checksums, cursor);
RET_ENDUPDATE(result, r);
......@@ -409,8 +414,10 @@ retvalue files_printmd5sums(struct database *database) {
while( cursor_nexttemp(database->oldmd5sums, cursor,
&filekey, &checksum) ) {
result = RET_OK;
fputs(filekey, stdout);putchar(' ');
fputs(checksum, stdout);putchar('\n');
(void)fputs(filekey, stdout);
(void)putchar(' ');
(void)fputs(checksum, stdout);
(void)putchar('\n');
}
r = cursor_close(database->oldmd5sums, cursor);
RET_ENDUPDATE(result, r);
......@@ -431,8 +438,10 @@ retvalue files_printchecksums(struct database *database) {
while( cursor_nexttemp(database->checksums, cursor,
&filekey, &checksum) ) {
result = RET_OK;
fputs(filekey, stdout);putchar(' ');
fputs(checksum, stdout);putchar('\n');
(void)fputs(filekey, stdout);
(void)putchar(' ');
(void)fputs(checksum, stdout);
(void)putchar('\n');
}
r = cursor_close(database->checksums, cursor);
RET_ENDUPDATE(result, r);
......@@ -445,17 +454,18 @@ retvalue files_printchecksums(struct database *database) {
while( cursor_nexttempdata(database->oldmd5sums, cursor,
&filekey, &md5sum, &md5sumlen) ) {
result = RET_OK;
fputs(filekey, stdout);putchar(' ');
(void)fputs(filekey, stdout);
(void)putchar(' ');
r = table_gettemprecord(database->checksums, filekey,
&checksum, &checksumlen);
if( r == RET_NOTHING || checksumlen <= md5sumlen ||
strcmp(checksum + checksumlen - md5sumlen,
md5sum) != 0 )
fputs(md5sum, stdout);
(void)fputs(md5sum, stdout);
else if( RET_IS_OK(r) )
fputs(checksum, stdout);
(void)fputs(checksum, stdout);
RET_UPDATE(result, r);
putchar('\n');
(void)putchar('\n');
}
r = cursor_close(database->oldmd5sums, cursor);
RET_ENDUPDATE(result, r);
......@@ -726,7 +736,7 @@ static retvalue collectnewchecksums(struct database *database, const char *filek
printf(
"Warning: pool file '%s' got outdated extended hashes.\n", filekey);
if( ! havewarned ) {
puts(
(void)puts(
"This can happen if you used pre-3.3 versions of reprepro in between.\n"
"This is anticipated and should cause no problems, as long as you rerun\n"
"collectnewchecksums before you switch to a future version no longer\n"
......@@ -868,12 +878,12 @@ static retvalue regenerate_filelist(void *data, const char *filekey) {
free(debfilename);
if( RET_IS_OK(r) ) {
if( verbose > 0 )
puts(filekey);
(void)puts(filekey);
if( verbose > 6 ) {
const char *p = filelist;
while( *p != '\0' ) {
putchar(' ');
puts(p);
(void)putchar(' ');
(void)puts(p);
p += strlen(p)+1;
}
}
......
......@@ -451,7 +451,7 @@ static void candidate_file_free(/*@only@*/struct candidate_file *f) {
if( f->type == fe_DSC )
sources_done(&f->dsc);
if( f->tempfilename != NULL ) {
unlink(f->tempfilename);
(void)unlink(f->tempfilename);
free(f->tempfilename);
f->tempfilename = NULL;
}
......@@ -711,7 +711,7 @@ static retvalue candidate_usefile(const struct incoming *i,const struct candidat
free(tempfilename);
return RET_ERROR_OOM;
}
unlink(tempfilename);
(void)unlink(tempfilename);
r = checksums_copyfile(tempfilename, origfile, &readchecksums);
free(origfile);
if( RET_WAS_ERROR(r) ) {
......@@ -1240,7 +1240,8 @@ static retvalue candidate_addfiles(struct database *database,struct candidate *c
/* when we did not add it, do not remove it: */
p->files[j] = NULL;
if( RET_WAS_ERROR(r) ) {
candidate_removefiles(database, c, d, p, j);
(void)candidate_removefiles(database,
c, d, p, j);
return r;
}
}
......@@ -1330,7 +1331,7 @@ static retvalue candidate_add_into(struct database *database,struct strlist *der
r = trackingdata_summon(tracks, c->source, c->sourceversion,
&trackingdata);
if( RET_WAS_ERROR(r) ) {
tracking_done(tracks);
(void)tracking_done(tracks);
return r;
}
if( into->trackingoptions.needsources ) {
......@@ -1601,7 +1602,7 @@ static retvalue candidate_add(const char *confdir, const char *overridedir,struc
if( RET_WAS_ERROR(r) )
return r;
if( interrupted() ) {
candidate_removefiles(database,c,NULL,NULL,0);
(void)candidate_removefiles(database,c,NULL,NULL,0);
return RET_ERROR_INTERRUPTED;
}
r = RET_OK;
......
......@@ -125,7 +125,7 @@ O(fast), O(mirrordir), O(distdir), O(dbdir), O(listdir), O(confdir), O(logdir),
free(variable); \
variable = strdup(value); \
if( variable == NULL ) { \
fputs("Out of Memory!",stderr); \
(void)fputs("Out of Memory!",stderr); \
exit(EXIT_FAILURE); \
} }
......@@ -311,17 +311,17 @@ ACTION_N(n, n, extractfilelist) {
p++;
}
len += *(p++);
putchar('/');
(void)putchar('/');
for( i = 0 ; i < depth ; i++ ) {
const unsigned char *n = dirs[i];
j = lengths[i];
while( j-- > 0 )
putchar(*(n++));
putchar('/');
(void)putchar(*(n++));
(void)putchar('/');
}
while( len-- > 0 )
putchar(*(p++));
putchar('\n');
(void)putchar(*(p++));
(void)putchar('\n');
}
}
free(filelist);
......@@ -1937,7 +1937,7 @@ ACTION_C(n, n, createsymlinks) {
buffer = calloc(1,bufsize);
if( linkname == NULL || buffer == NULL ) {
free(linkname);free(buffer);
fputs("Out of Memory!\n",stderr);
(void)fputs("Out of Memory!\n",stderr);
return RET_ERROR_OOM;
}
......@@ -2230,7 +2230,7 @@ ACTION_B(y, n, y, rerunnotifiers) {
static const struct action {
const char *name;
retvalue (*start)(
/*@null@*//*@only@*/struct distribution *,
/*@null@*/struct distribution *,
/*@null@*/struct database*,
/*@null@*/struct strlist *dereferencedfilekeys,
/*@null@*/const char *priority,
......@@ -3055,9 +3055,9 @@ int main(int argc,char *argv[]) {
free(x_priority);
if( RET_WAS_ERROR(r) ) {
if( r == RET_ERROR_OOM )
fputs("Out of Memory!\n",stderr);
(void)fputs("Out of Memory!\n",stderr);
else if( verbose >= 0 )
fputs("There have been errors!\n",stderr);
(void)fputs("There have been errors!\n",stderr);
}
exit(EXIT_RET(r));
} else
......
......@@ -36,7 +36,7 @@ void optionsfile_parse(const char *confdir,const struct option *longopts,
filename = mprintf("%s/options",confdir);
if( filename == NULL ) {
fputs("Out of memory!\n",stderr);
(void)fputs("Out of memory!\n",stderr);
exit(EXIT_FAILURE);
}
......
......@@ -389,7 +389,7 @@ void release_abortfile(struct filetorelease *file) {
for( i = ic_uncompressed ; i < ic_count ; i++ ) {
if( file->f[i].fd >= 0 ) {
close(file->f[i].fd);
(void)close(file->f[i].fd);
if( file->f[i].fulltemporaryfilename != NULL )
(void)unlink(file->f[i].fulltemporaryfilename);
}
......@@ -400,12 +400,12 @@ void release_abortfile(struct filetorelease *file) {
free(file->buffer);
free(file->gzoutputbuffer);
if( file->gzstream.next_out != NULL ) {
deflateEnd(&file->gzstream);
(void)deflateEnd(&file->gzstream);
}
#ifdef HAVE_LIBBZ2
free(file->bzoutputbuffer);
if( file->bzstream.next_out != NULL ) {
BZ2_bzCompressEnd(&file->bzstream);
(void)BZ2_bzCompressEnd(&file->bzstream);
}
#endif
}
......
......@@ -14,6 +14,7 @@
struct release;
#define ic_first ic_uncompressed
enum indexcompression {ic_uncompressed=0, ic_gzip,
#ifdef HAVE_LIBBZ2
ic_bzip2,
......
......@@ -172,19 +172,19 @@ retvalue signature_check(const char *options, const char *releasegpg, const char
fd = open(release, O_RDONLY|O_NOCTTY);
if( fd < 0 ) {
int e = errno;
close(gpgfd);
(void)close(gpgfd);
fprintf(stderr, "Error opening '%s': %s\n", release, strerror(e));
return RET_ERRNO(e);
}
err = gpgme_data_new_from_fd(&dh_gpg, gpgfd);
if( err != 0 ) {
close(gpgfd);close(fd);
(void)close(gpgfd); (void)close(fd);
return gpgerror(err);
}
err = gpgme_data_new_from_fd(&dh, fd);
if( err != 0 ) {
gpgme_data_release(dh_gpg);
close(gpgfd);close(fd);
(void)close(gpgfd); (void)close(fd);
return gpgerror(err);
}
......@@ -907,9 +907,9 @@ static retvalue newpossiblysignedfile(const char *directory, const char *basenam
return RET_OK;
}
retvalue signedfile_free(struct signedfile *f) {
void signedfile_free(struct signedfile *f) {
if( f == NULL )
return RET_NOTHING;
return;
assert( f->fd < 0 );
if( f->newplainfilename != NULL ) {
(void)unlink(f->newplainfilename);
......@@ -922,7 +922,7 @@ retvalue signedfile_free(struct signedfile *f) {
}
free(f->signfilename);
free(f);
return RET_OK;
return;
}
retvalue signature_startsignedfile(const char *directory, const char *basename, UNUSED(const char *options), struct signedfile **out) {
......
......@@ -26,7 +26,7 @@ retvalue signedfile_prepare(struct signedfile *, const char *options);
/* move temporary files to final places */
retvalue signedfile_finalize(struct signedfile *, bool *toolate);
/* may only be called after signedfile_prepare */
retvalue signedfile_free(struct signedfile *);
void signedfile_free(/*@only@*/struct signedfile *);
void signatures_done(void);
......
......@@ -721,7 +721,7 @@ retvalue target_reoverride(UNUSED(void *dummy), struct target *target, struct di
RET_UPDATE(result, r);
if( RET_WAS_ERROR(r) ) {
if( verbose > 0 )
fputs("target_reoverride: Stopping procession of further packages due to previous errors\n", stderr);
(void)fputs("target_reoverride: Stopping procession of further packages due to previous errors\n", stderr);
break;
}
if( RET_IS_OK(r) ) {
......
......@@ -610,7 +610,7 @@ static void print(const char *codename,const struct trackedpackage *pkg){
printf(" %s %c %d\n",filekey,
pkg->filetypes[i],pkg->refcounts[i]);
}
fputs("\n",stdout);
(void)fputs("\n",stdout);
}
retvalue tracking_printall(trackingdb t) {
......
......@@ -371,7 +371,7 @@ retvalue updates_getpatterns(const char *confdir, struct update_pattern **patter
r = RET_OK;
} else {
if( r == RET_ERROR_UNKNOWNFIELD )
fputs("To ignore unknown fields use --ignore=unknownfield\n", stderr);
(void)fputs("To ignore unknown fields use --ignore=unknownfield\n", stderr);
updates_freepatterns(update);
}
return r;
......@@ -925,7 +925,8 @@ retvalue updates_clearlists(const char *listdir,struct update_distribution *dist
dir = opendir(listdir);
if( dir == NULL ) {
int e = errno;
fprintf(stderr,"Error opening directory '%s' (error %d=%m)!\n",listdir,e);
fprintf(stderr,"Error %d opening directory '%s': %s!\n",
e, listdir, strerror(e));
free(pattern);
return RET_ERRNO(e);
}
......@@ -933,7 +934,12 @@ retvalue updates_clearlists(const char *listdir,struct update_distribution *dist
d->origins,
d->targets);
free(pattern);
closedir(dir);
if( closedir(dir) != 0 ) {
int e = errno;
fprintf(stderr, "Error %d closing directory '%s': %s!\n",
e, listdir, strerror(e));
return RET_ERRNO(e);
}
if( RET_WAS_ERROR(r) ) {
return r;
}
......
......@@ -152,7 +152,7 @@ retvalue upgradelist_initialize(struct upgradelist **ul,struct target *t,struct
r = target_initpackagesdb(t, database, READONLY);
if( RET_WAS_ERROR(r) ) {
(void)upgradelist_free(upgrade);
upgradelist_free(upgrade);
return r;
}
......@@ -163,7 +163,7 @@ retvalue upgradelist_initialize(struct upgradelist **ul,struct target *t,struct
if( RET_WAS_ERROR(r) ) {
r2 = target_closepackagesdb(t);
RET_UPDATE(r,r2);
(void)upgradelist_free(upgrade);
upgradelist_free(upgrade);
return r;
}
while( cursor_nexttemp(t->packages, cursor,
......@@ -179,7 +179,7 @@ retvalue upgradelist_initialize(struct upgradelist **ul,struct target *t,struct
RET_UPDATE(r,r2);
if( RET_WAS_ERROR(r) ) {
(void)upgradelist_free(upgrade);
upgradelist_free(upgrade);
return r;
}
......@@ -189,11 +189,11 @@ retvalue upgradelist_initialize(struct upgradelist **ul,struct target *t,struct
return RET_OK;
}
retvalue upgradelist_free(struct upgradelist *upgrade) {
void upgradelist_free(struct upgradelist *upgrade) {
struct package_data *l;
if( upgrade == NULL )
return RET_NOTHING;
return;
l = upgrade->list;
while( l != NULL ) {
......@@ -203,7 +203,7 @@ retvalue upgradelist_free(struct upgradelist *upgrade) {
}
free(upgrade);
return RET_OK;
return;
}
static retvalue upgradelist_trypackage(void *data,const char *chunk){
......
......@@ -23,7 +23,7 @@ struct logger;
struct upgradelist;
retvalue upgradelist_initialize(struct upgradelist **ul,/*@dependent@*/struct target *target,struct database *);
retvalue upgradelist_free(/*@only@*/struct upgradelist *upgrade);
void upgradelist_free(/*@only@*/struct upgradelist *upgrade);
void upgradelist_dump(struct upgradelist *upgrade);
retvalue upgradelist_listmissing(struct upgradelist *upgrade,struct database *);
......
......@@ -323,7 +323,7 @@ static retvalue uploaders_load(/*@out@*/struct uploaders **list, const char *con
}
u = calloc(1,sizeof(struct uploaders));
if( u == NULL ) {
fclose(f);
(void)fclose(f);
free(fullfilename);
return RET_ERROR_OOM;
}
......@@ -332,7 +332,7 @@ static retvalue uploaders_load(/*@out@*/struct uploaders **list, const char *con
lineno++;
r = parseuploaderline(buffer,filename,lineno,u);
if( RET_WAS_ERROR(r) ) {
fclose(f);
(void)fclose(f);
free(fullfilename);
uploaders_free(u);
return r;
......
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