qa: fix a few issues detected by coverity

This commit is contained in:
Giacomo Tesio 2017-01-14 17:58:33 +01:00
parent d4157c7e24
commit c4fb99ec38
6 changed files with 18 additions and 12 deletions

View File

@ -25,7 +25,7 @@ uartpci(int ctlrno, Pcidev* p, int barno, int n, int freq, char* name)
return nil;
}
head = uart = malloc(sizeof(Uart)*n);
head = uart = mallocz(sizeof(Uart)*n, 1);
for(i = 0; i < n; i++){
ctlr = i8250alloc(io, p->intl, p->tbdf);

View File

@ -62,7 +62,7 @@ extern void savelogs(void);
/* libc equivalent */
extern int cache(int);
extern char* checkkey(Method*, char*, char*);
extern void fatal(char*);
extern void fatal(char*) __attribute__ ((noreturn));
extern void getpasswd(char*, int);
extern void key(int, Method*);
extern int outin(char*, char*, int);

View File

@ -39,6 +39,8 @@ configip(int bargc, char **bargv, int needfs)
memmove(arg, bargv, bargc * sizeof(char*));
arg[bargc] = 0;
buf[0] = 0; /* no default for outin */
print("ipconfig...");
argc = bargc;
argv = arg;

View File

@ -282,20 +282,21 @@ write_working_dir(Proc* p, void *va, long n, int64_t off)
}
static long
selfread(Chan *c, void *va, long n, int64_t off)
selfread(Chan *c, void *va, long n, int64_t offset)
{
int64_t offset;
ProcSegment *sg;
int i, j;
char statbuf[NSEG*STATSIZE];
if(offset < 0)
error("invalid offset");
offset = off;
switch(QID(c->qid)){
case Qdir:
return devdirread(c, va, n, selfdir, nelem(selfdir), selfgen);
case Qsegments:
rlock(&up->seglock);
j = 0;
rlock(&up->seglock);
for(i = 0; i < NSEG; i++) {
sg = up->seg[i];
if(sg == 0)
@ -317,7 +318,7 @@ selfread(Chan *c, void *va, long n, int64_t off)
memmove(va, &statbuf[offset], n);
return n;
case Qwdir:
return read_working_dir(up, va, n, off);
return read_working_dir(up, va, n, offset);
case Qpid:
return readnum(offset, va, n, up->pid, NUMSIZE);

View File

@ -65,7 +65,7 @@ void closeegrp(Egrp*);
void closefgrp(Fgrp*);
void closepgrp(Pgrp*);
void closergrp(Rgrp*);
void cmderror(Cmdbuf*, char*);
void cmderror(Cmdbuf*, char*) __attribute__ ((noreturn));
int cmount(Chan**, Chan*, int, char*);
#define commonerror() (up->errstr)
#define commonuser() (up->user)
@ -125,8 +125,8 @@ int eqchanddq(Chan*, int, uint32_t, Qid, int);
int eqqid(Qid, Qid);
void error(char*) __attribute__ ((noreturn));
void errorl(char*, long) __attribute__ ((noreturn));
void errorf(char*, ...);
void exhausted(char*);
void errorf(char*, ...) __attribute__ ((noreturn));
void exhausted(char*) __attribute__ ((noreturn));
void exit(int) __attribute__ ((noreturn));
uint64_t fastticks(uint64_t*);
uint64_t fastticks2us(uint64_t);

View File

@ -243,8 +243,11 @@ controlsetthread(void *v)
prevbut=mouse.buttons;
break;
case ACtl:
_ctlcontrol(cs, str);
free(str);
if(str != nil){
_ctlcontrol(cs, str);
free(str);
str = nil;
}
break;
case AExit:
threadexits(nil);