Two hours of fixing details based on Klocwork source review. Useful report,
although it has a lot of noise. Not to mention our bad string code gives a load of warnings. I've reviewed specifically: - file reading/write - dna and library code - node system - entire render module Done a couple of files in src/ too, seemed to be nice errors.
This commit is contained in:
@@ -763,7 +763,7 @@ int new_id(ListBase *lb, ID *id, const char *tname)
|
||||
{
|
||||
ID *idtest;
|
||||
int nr= 0, nrtest, maxtest=32, a;
|
||||
char aname[32], *name, left[24], leftest[24], in_use[32];
|
||||
char aname[32], *name, left[32], leftest[32], in_use[32];
|
||||
|
||||
/* - split name
|
||||
* - search
|
||||
@@ -800,7 +800,7 @@ int new_id(ListBase *lb, ID *id, const char *tname)
|
||||
|
||||
/* if there is no double return */
|
||||
if(idtest==0) {
|
||||
strcpy(id->name+2, name);
|
||||
strncpy(id->name+2, name, 21);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -835,7 +835,7 @@ int new_id(ListBase *lb, ID *id, const char *tname)
|
||||
}
|
||||
}
|
||||
|
||||
if(nr==0) sprintf(id->name+2, "%s", left);
|
||||
if(nr==0) strncpy(id->name+2, left, 21);
|
||||
else {
|
||||
if (nr >= 1000 && strlen(left) > 16) {
|
||||
// this would overflow name buffer
|
||||
|
||||
@@ -121,12 +121,12 @@ static CompBuf *alloc_compbuf(int sizex, int sizey, int type, int alloc)
|
||||
static CompBuf *dupalloc_compbuf(CompBuf *cbuf)
|
||||
{
|
||||
CompBuf *dupbuf= alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 1);
|
||||
if(dupbuf)
|
||||
if(dupbuf) {
|
||||
memcpy(dupbuf->rect, cbuf->rect, cbuf->type*sizeof(float)*cbuf->x*cbuf->y);
|
||||
|
||||
dupbuf->xof= cbuf->xof;
|
||||
dupbuf->yof= cbuf->yof;
|
||||
|
||||
dupbuf->xof= cbuf->xof;
|
||||
dupbuf->yof= cbuf->yof;
|
||||
}
|
||||
return dupbuf;
|
||||
}
|
||||
|
||||
@@ -136,18 +136,19 @@ static CompBuf *pass_on_compbuf(CompBuf *cbuf)
|
||||
CompBuf *dupbuf= alloc_compbuf(cbuf->x, cbuf->y, cbuf->type, 0);
|
||||
CompBuf *lastbuf;
|
||||
|
||||
dupbuf->rect= cbuf->rect;
|
||||
dupbuf->xof= cbuf->xof;
|
||||
dupbuf->yof= cbuf->yof;
|
||||
dupbuf->malloc= 0;
|
||||
|
||||
/* get last buffer in list, and append dupbuf */
|
||||
for(lastbuf= dupbuf; lastbuf; lastbuf= lastbuf->next)
|
||||
if(lastbuf->next==NULL)
|
||||
break;
|
||||
lastbuf->next= dupbuf;
|
||||
dupbuf->prev= lastbuf;
|
||||
|
||||
if(dupbuf) {
|
||||
dupbuf->rect= cbuf->rect;
|
||||
dupbuf->xof= cbuf->xof;
|
||||
dupbuf->yof= cbuf->yof;
|
||||
dupbuf->malloc= 0;
|
||||
|
||||
/* get last buffer in list, and append dupbuf */
|
||||
for(lastbuf= dupbuf; lastbuf; lastbuf= lastbuf->next)
|
||||
if(lastbuf->next==NULL)
|
||||
break;
|
||||
lastbuf->next= dupbuf;
|
||||
dupbuf->prev= lastbuf;
|
||||
}
|
||||
return dupbuf;
|
||||
}
|
||||
|
||||
@@ -1189,11 +1190,10 @@ static void texture_procedural(CompBuf *cbuf, float *col, float xco, float yco)
|
||||
{
|
||||
bNode *node= cbuf->node;
|
||||
bNodeSocket *sock= node->inputs.first;
|
||||
TexResult texres;
|
||||
TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
|
||||
float vec[3], *size, nor[3]={0.0f, 0.0f, 0.0f};
|
||||
int retval, type= cbuf->type;
|
||||
|
||||
texres.nor= NULL;
|
||||
size= sock->next->ns.vec;
|
||||
|
||||
vec[0]= size[0]*(xco + sock->ns.vec[0]);
|
||||
|
||||
@@ -892,15 +892,15 @@ int BLI_convertstringcode(char *path, const char *basepath, int framenum)
|
||||
return wasrelative;
|
||||
}
|
||||
|
||||
void BLI_splitdirstring(char *di,char *fi)
|
||||
void BLI_splitdirstring(char *di, char *fi)
|
||||
{
|
||||
char *lslash= BLI_last_slash(di);
|
||||
|
||||
if (lslash) {
|
||||
strcpy(fi, lslash+1);
|
||||
BLI_strncpy(fi, lslash+1, FILE_MAXFILE);
|
||||
*(lslash+1)=0;
|
||||
} else {
|
||||
strcpy(fi, di);
|
||||
BLI_strncpy(fi, di, FILE_MAXFILE);
|
||||
di[0]= 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,7 +479,7 @@ static Main *blo_find_main(ListBase *mainlist, const char *name, const char *rel
|
||||
Library *lib;
|
||||
char name1[FILE_MAXDIR+FILE_MAXFILE];
|
||||
|
||||
strcpy(name1, name);
|
||||
strncpy(name1, name, sizeof(name1)-1);
|
||||
cleanup_path(relabase, name1);
|
||||
// printf("blo_find_main: original in %s\n", name);
|
||||
// printf("blo_find_main: converted to %s\n", name1);
|
||||
@@ -497,8 +497,8 @@ static Main *blo_find_main(ListBase *mainlist, const char *name, const char *rel
|
||||
BLI_addtail(mainlist, m);
|
||||
|
||||
lib= alloc_libblock(&m->library, ID_LI, "lib");
|
||||
strcpy(lib->name, name);
|
||||
strcpy(lib->filename, name1);
|
||||
strncpy(lib->name, name, sizeof(lib->name)-1);
|
||||
BLI_strncpy(lib->filename, name1, sizeof(lib->filename));
|
||||
|
||||
m->curlib= lib;
|
||||
|
||||
@@ -611,6 +611,7 @@ static BHeadN *get_bhead(FileData *fd)
|
||||
}
|
||||
} else {
|
||||
fd->eof = 1;
|
||||
bhead.len= 0;
|
||||
}
|
||||
} else {
|
||||
bhead8.code = DATA;
|
||||
@@ -628,6 +629,7 @@ static BHeadN *get_bhead(FileData *fd)
|
||||
}
|
||||
} else {
|
||||
fd->eof = 1;
|
||||
bhead.len= 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2703,8 +2705,10 @@ static void lib_link_object(FileData *fd, Main *main)
|
||||
if(eoa==NULL) {
|
||||
init_actuator(act);
|
||||
}
|
||||
eoa->ob= newlibadr(fd, ob->id.lib, eoa->ob);
|
||||
eoa->me= newlibadr(fd, ob->id.lib, eoa->me);
|
||||
else {
|
||||
eoa->ob= newlibadr(fd, ob->id.lib, eoa->ob);
|
||||
eoa->me= newlibadr(fd, ob->id.lib, eoa->me);
|
||||
}
|
||||
}
|
||||
else if(act->type==ACT_SCENE) {
|
||||
bSceneActuator *sa= act->data;
|
||||
@@ -6278,7 +6282,8 @@ BlendFileData *blo_read_file_internal(FileData *fd, BlendReadError *error_r)
|
||||
lib_link_all(fd, bfd->main);
|
||||
lib_verify_nodetree(bfd->main);
|
||||
|
||||
link_global(fd, bfd, fg); /* as last */
|
||||
if(fg)
|
||||
link_global(fd, bfd, fg); /* as last */
|
||||
|
||||
/* removed here: check for existance of curscreen/scene, moved to kernel setup_app */
|
||||
MEM_freeN(fg);
|
||||
|
||||
@@ -486,7 +486,8 @@ static void write_renderinfo(WriteData *wd) /* for renderdeamon */
|
||||
data[0]= sce->r.sfra;
|
||||
data[1]= sce->r.efra;
|
||||
|
||||
strncpy((char *)(data+2), sce->id.name+2, 23);
|
||||
memset(data+2, 0, sizeof(int)*6);
|
||||
strncpy((char *)(data+2), sce->id.name+2, 21);
|
||||
|
||||
writedata(wd, REND, 32, data);
|
||||
}
|
||||
@@ -1856,7 +1857,7 @@ static int write_file_handle(int handle, MemFile *compare, MemFile *current, int
|
||||
{
|
||||
BHead bhead;
|
||||
ListBase mainlist;
|
||||
char buf[13];
|
||||
char buf[16];
|
||||
WriteData *wd;
|
||||
|
||||
blo_split_main(&mainlist, G.main);
|
||||
|
||||
@@ -383,7 +383,7 @@ static void calc_edge_stress(Render *re, Mesh *me, int startvert, int startvlak)
|
||||
accum= MEM_callocN(2*sizeof(float)*(re->totvert-startvert), "temp accum for stress");
|
||||
|
||||
/* de-normalize orco */
|
||||
for(a=startvert; a<re->totvert; a++, acc+=2) {
|
||||
for(a=startvert; a<re->totvert; a++) {
|
||||
VertRen *ver= RE_findOrAddVert(re, a);
|
||||
if(ver->orco) {
|
||||
ver->orco[0]= ver->orco[0]*size[0] +loc[0];
|
||||
|
||||
@@ -1164,7 +1164,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
|
||||
switch(tex->type) {
|
||||
|
||||
case 0:
|
||||
texres->tin= 0.0;
|
||||
texres->tin= 0.0f;
|
||||
return 0;
|
||||
case TEX_CLOUDS:
|
||||
retval= clouds(tex, texvec, texres);
|
||||
@@ -1259,7 +1259,10 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex,
|
||||
int multitex_ext(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres)
|
||||
{
|
||||
|
||||
if(tex==NULL) return 0;
|
||||
if(tex==NULL) {
|
||||
memset(texres, 0, sizeof(TexResult));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Image requires 2d mapping conversion */
|
||||
if(tex->type==TEX_IMAGE) {
|
||||
@@ -1438,7 +1441,7 @@ void do_material_tex(ShadeInput *shi)
|
||||
{
|
||||
MTex *mtex;
|
||||
Tex *tex;
|
||||
TexResult texres;
|
||||
TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
|
||||
float *co = NULL, *dx = NULL, *dy = NULL;
|
||||
float fact, facm, factt, facmm, stencilTin=1.0;
|
||||
float texvec[3], dxt[3], dyt[3], tempvec[3], norvec[3], warpvec[3], Tnor=1.0;
|
||||
@@ -1926,7 +1929,7 @@ void do_material_tex(ShadeInput *shi)
|
||||
void do_halo_tex(HaloRen *har, float xn, float yn, float *colf)
|
||||
{
|
||||
MTex *mtex;
|
||||
TexResult texres;
|
||||
TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
|
||||
float texvec[3], dxt[3], dyt[3], fact, facm, dx;
|
||||
int rgb, osatex;
|
||||
|
||||
@@ -2052,7 +2055,7 @@ void do_halo_tex(HaloRen *har, float xn, float yn, float *colf)
|
||||
void do_sky_tex(float *rco, float *lo, float *dxyview, float *hor, float *zen, float *blend, int skyflag)
|
||||
{
|
||||
MTex *mtex;
|
||||
TexResult texres;
|
||||
TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
|
||||
float *co, fact, stencilTin=1.0;
|
||||
float tempvec[3], texvec[3], dxt[3], dyt[3];
|
||||
int tex_nr, rgb= 0, ok;
|
||||
@@ -2236,7 +2239,7 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf)
|
||||
Object *ob;
|
||||
MTex *mtex;
|
||||
Tex *tex;
|
||||
TexResult texres;
|
||||
TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
|
||||
float *co = NULL, *dx = NULL, *dy = NULL, fact, stencilTin=1.0;
|
||||
float texvec[3], dxt[3], dyt[3], tempvec[3];
|
||||
int tex_nr, rgb= 0;
|
||||
@@ -2451,7 +2454,7 @@ void render_realtime_texture(ShadeInput *shi)
|
||||
static Tex tex1, tex2; // threadsafe
|
||||
static int firsttime= 1;
|
||||
Tex *tex;
|
||||
float texvec[2], dx[2], dy[2];
|
||||
float texvec[3], dx[2], dy[2];
|
||||
|
||||
if(firsttime) {
|
||||
firsttime= 0;
|
||||
|
||||
@@ -1215,7 +1215,7 @@ static int node_composit_buts_file_output(uiBlock *block, bNodeTree *ntree, bNod
|
||||
&nif->imtype, 0.0f, 1.0f, 0, 0, "");
|
||||
|
||||
if(nif->imtype==R_OPENEXR) {
|
||||
uiDefButBitS(block, TOG, R_OPENEXR_HALF, B_NOP, "Half",
|
||||
uiDefButBitS(block, TOG, R_OPENEXR_HALF, B_REDR, "Half",
|
||||
x, y+20, w/2, 20,
|
||||
&nif->subimtype, 0, 0, 0, 0, "");
|
||||
|
||||
@@ -1985,10 +1985,12 @@ static void node_draw_basis(ScrArea *sa, SpaceNode *snode, bNode *node)
|
||||
|
||||
/* buttons */
|
||||
if(node->flag & NODE_OPTIONS) {
|
||||
if(node->typeinfo->butfunc) {
|
||||
node->typeinfo->butfunc(block, snode->nodetree, node, &node->butr);
|
||||
if(block) {
|
||||
if(node->typeinfo->butfunc) {
|
||||
node->typeinfo->butfunc(block, snode->nodetree, node, &node->butr);
|
||||
}
|
||||
uiDrawBlock(block);
|
||||
}
|
||||
uiDrawBlock(block);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -346,6 +346,7 @@ void remove_vert_def_nr (Object *ob, int def_nr, int vertnum)
|
||||
else {
|
||||
MEM_freeN (dvert->dw);
|
||||
dvert->dw = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -639,6 +640,7 @@ void remove_verts_defgroup (int allverts)
|
||||
else{
|
||||
MEM_freeN (dvert->dw);
|
||||
dvert->dw=NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1466,7 +1466,7 @@ static void node_insert_convertor(SpaceNode *snode, bNodeLink *link)
|
||||
static int node_add_link_drag(SpaceNode *snode, bNode *node, bNodeSocket *sock, int in_out)
|
||||
{
|
||||
bNode *tnode;
|
||||
bNodeSocket *tsock;
|
||||
bNodeSocket *tsock= NULL;
|
||||
bNodeLink *link= NULL;
|
||||
short mval[2], mvalo[2], firsttime=1; /* firsttime reconnects a link broken by caller */
|
||||
|
||||
@@ -1539,7 +1539,7 @@ static int node_add_link_drag(SpaceNode *snode, bNode *node, bNodeSocket *sock,
|
||||
|
||||
/* we might need to remove a link */
|
||||
if(in_out==SOCK_OUT) {
|
||||
if(nodeCountSocketLinks(snode->edittree, link->tosock) > tsock->limit) {
|
||||
if(tsock && nodeCountSocketLinks(snode->edittree, link->tosock) > tsock->limit) {
|
||||
|
||||
for(tlink= snode->edittree->links.first; tlink; tlink= tlink->next) {
|
||||
if(link!=tlink && tlink->tosock==link->tosock)
|
||||
|
||||
@@ -858,7 +858,7 @@ void objects_bake_render(void)
|
||||
ScrArea *area= biggest_image_area();
|
||||
ListBase threads;
|
||||
BakeRender bkr;
|
||||
int timer, tot;
|
||||
int timer=0, tot;
|
||||
|
||||
if(event==1) event= RE_BAKE_ALL;
|
||||
else if(event==2) event= RE_BAKE_AO;
|
||||
|
||||
Reference in New Issue
Block a user