From 01eaae672435844b872765eef7ea93901753bb8c Mon Sep 17 00:00:00 2001 From: siemargl Date: Thu, 11 Apr 2019 07:12:30 +0000 Subject: [PATCH] c-- cppchecked git-svn-id: svn://kolibrios.org@7626 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/develop/cmm/disasm.cpp | 2 +- programs/develop/cmm/main.cpp | 3 ++- programs/develop/cmm/new_type.cpp | 2 +- programs/develop/cmm/outpe.cpp | 2 +- programs/develop/cmm/port.cpp | 4 ++-- programs/develop/cmm/toka.cpp | 4 ++-- programs/develop/cmm/tokb.cpp | 6 +++--- programs/develop/cmm/tokc.cpp | 4 ++-- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/programs/develop/cmm/disasm.cpp b/programs/develop/cmm/disasm.cpp index 0caf293d90..88d08810f8 100644 --- a/programs/develop/cmm/disasm.cpp +++ b/programs/develop/cmm/disasm.cpp @@ -1152,7 +1152,7 @@ void addr_to_hex(long addr, unsigned char splitup) { -static char buffer[11]; +static char buffer[12]; // fix by cppcheck WORD32 adr; diff --git a/programs/develop/cmm/main.cpp b/programs/develop/cmm/main.cpp index 0c0f4f29fc..ed0e8d6569 100644 --- a/programs/develop/cmm/main.cpp +++ b/programs/develop/cmm/main.cpp @@ -915,7 +915,7 @@ nexpardll: AlignCycle=(unsigned char)1^neg; if(ptr!=NULL){ aligncycle=getnumber((unsigned char *)ptr); - if(aligncycle<1&&aligncycle>4096)aligncycle=8; + if(aligncycle<1 || aligncycle>4096)aligncycle=8; // fix by cppcheck } break; case c_ws: //dos-stub for windows programs @@ -1664,6 +1664,7 @@ unsigned char typev; if(am32==FALSE&&((itok.flag&f_far)==0))ssize=2; else ssize=4; } + else printf("unexpected condition\n"); // fix by cppcheck datasize+=initglobalvar(type,ptr->recsize/ssize,ssize,typev); } free(input); diff --git a/programs/develop/cmm/new_type.cpp b/programs/develop/cmm/new_type.cpp index 515a8a7b72..b3dd730772 100644 --- a/programs/develop/cmm/new_type.cpp +++ b/programs/develop/cmm/new_type.cpp @@ -33,7 +33,7 @@ int usebracket=FALSE; if(usebracket){ while(tok==tk_mult){ nexttok(); - *pointr++; + (*pointr)++; // fix by cppcheck } if(tok!=tk_closebracket)expected(')'); else getoperand(reg); diff --git a/programs/develop/cmm/outpe.cpp b/programs/develop/cmm/outpe.cpp index f1a8e4704d..49260b3572 100644 --- a/programs/develop/cmm/outpe.cpp +++ b/programs/develop/cmm/outpe.cpp @@ -147,7 +147,7 @@ unsigned short numobj=1; char *importblock=NULL; char *relocblock=NULL; char *exportblock=NULL; -unsigned long psize,vsize=0,sizereloc=0,sizeReloc=0,sizeImport=0,sizeExport=0, +unsigned long psize = 0,vsize=0,sizereloc=0,sizeReloc=0,sizeImport=0,sizeExport=0, sizebss=0,sizeRes=0; unsigned long startsec=0,startsecr=0,startsece=0,startsecres=0; unsigned int posrel=0,sizeimport=0,startimportname=0,sizeexport=0,sizeres=0, diff --git a/programs/develop/cmm/port.cpp b/programs/develop/cmm/port.cpp index 5fe4bab8fa..3d39d808f4 100644 --- a/programs/develop/cmm/port.cpp +++ b/programs/develop/cmm/port.cpp @@ -99,7 +99,7 @@ int MultiByteToWideChar( int cchWideChar // size of buffer ) { - int i; + int i = 0; // fix by cppcheck while ((lpMultiByteStr[i*2]!=0) && (lpMultiByteStr[i*2+1]!=0)) i++; return i/2; } @@ -147,7 +147,7 @@ int stat (const char* path, struct _stat* buf) char * getcwd (char *buffer, int size) { - int len=0; + volatile int len=0; // fix by cppcheck if (size==0){ if (buffer!=0) return 0; diff --git a/programs/develop/cmm/toka.cpp b/programs/develop/cmm/toka.cpp index 271c84e2fe..ea4946bfec 100644 --- a/programs/develop/cmm/toka.cpp +++ b/programs/develop/cmm/toka.cpp @@ -675,7 +675,7 @@ void CheckReg(int idx,int base,int *reg1,int *reg2,int razr) } if(lreg[*reg1]==0)lreg[*reg1]=1; else{ - for(i=8;i!=0;i--){ + for(i=7;i>=0;i--){ // fix by cppcheck, side effect - enable EAX if(lreg[i]==0){ lreg[i]=1; *reg1=i; @@ -685,7 +685,7 @@ void CheckReg(int idx,int base,int *reg1,int *reg2,int razr) } // printf("\nreg1=%d",*reg1); if(lreg[*reg2]!=0){ - for(i=8;i!=0;i--){ + for(i=7;i>=0;i--){ // fix by cppcheck, side effect - enable EAX if(lreg[i]==0){ *reg2=i; break; diff --git a/programs/develop/cmm/tokb.cpp b/programs/develop/cmm/tokb.cpp index 9eadb3ecd8..513d84a04b 100644 --- a/programs/develop/cmm/tokb.cpp +++ b/programs/develop/cmm/tokb.cpp @@ -691,7 +691,7 @@ ITOK posttok; if(val==0&&rflag==0&&posttok.post==0)next|=8; switch(next){ case 5: // idx=-1 zoom=-1 Rb+N - if(reg==EAX&&(val>127||val<0xffffff80))goto retfalse; + if(reg==EAX&&(val>127||val<0xffffff80)) { //cppcheck - condition val>127||val<0xffffff80 always true, add diagnostic printf("suspicious instruction compilation\n"); goto retfalse; } if(val<3||val>0xfffffffd)goto retfalse; if(base==ESP)goto retfalse; break; @@ -4154,8 +4154,8 @@ beg1: break; case tk_seg: op66(r16); - op(0x8C); op(0xC0+gstok->number*8); break; - ClearReg(AL); + op(0x8C); op(0xC0+gstok->number*8); + ClearReg(AL); break; // fix by cppcheck default: bytevalexpected(0); break; } } diff --git a/programs/develop/cmm/tokc.cpp b/programs/develop/cmm/tokc.cpp index 18c79f9b08..ec5b9354ea 100644 --- a/programs/develop/cmm/tokc.cpp +++ b/programs/develop/cmm/tokc.cpp @@ -8183,7 +8183,7 @@ COM_MOD *ocur_mod; sprintf(itok.name,"%e",itok.dnumber); break; case tk_qword: - sprintf(itok.name,"0x%X%08X",itok.lnumber>>16,itok.number); + sprintf(itok.name,"0x%X%08X",itok.lnumber>>16,itok.number); break; default: sprintf(itok.name,"0x%X",itok.number); @@ -9976,7 +9976,7 @@ void unpackteg(structteg *tteg) int i; elementteg *bazael; structteg *newteg; -int ssize,count; +int ssize=4,count; // fix by cppcheck idrec *newrec,*ptr; if(alignword){ //выровнять на четный адрес if(am32==0){