tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] possible minor changes to code


From: Thomas Preud'homme
Subject: Re: [Tinycc-devel] possible minor changes to code
Date: Sat, 08 Mar 2014 18:32:54 +0800
User-agent: KMail/4.11.5 (Linux/2.6.38-ac2-ac100; KDE/4.11.5; armv7l; ; )

Le mardi 4 mars 2014, 06:27:37 Carlos Montiers a écrit :
> Hello. I check the tiny c project with cppcheck, and i found this next:
> 
> tiny_impdef.c line 228
> p = tcc_realloc(p, n0 = n0 ? n0 * 2 : 256);
> maybe should be:
> p = tcc_realloc(p, n0 ? n0 * 2 : 256);

If you check the source you'll see that it's probably made on purpose since 
this is part of a loop and thus n0 will be used again later. Agreed, the n0 = 
n0 ? n0 * 2 : 256 could be done outside realloc but there is no problem here.

> 
> x86_64-gen.c line 504
> assert((v >= TREG_XMM0) || (v <= TREG_XMM7));
> maybe should be:
> assert((v >= TREG_XMM0) && (v <= TREG_XMM7));

Looks weird indeed. It seems the problem was introduced in 1caee8ab. Fixed.

> 
> tccgen.c line 2272
> if (t & (VT_DEFSIGN | VT_UNSIGNED))
> maybe should be:
> if (t & VT_UNSIGNED)

No problem here, I don't see why it complains.

> 
> tccgen.c line 165
> s = *ps;
> maybe should be:
> //s = *ps; because is assigned in next line

Oups, my fault. I guess it's some leftover from statement I added to do a 
patch. Fixed.

> 
> tccpp.c line 2917
> assign address of local variable to a function parameter (i not understand
> this), but for case

We change the value of a function parameter and the tool complains because 
function parameters are passed by value and this assignment will be lost. 
However here the parameter is reused later so the value is not lost. False 
warning.

> 
> tccpp.c line 279
> sprintf(p, "%Lu", cv->ull);
> maybe should be: //the mask is unsigned long but the value is unsigned long
> long
> sprintf(p, "%llu", cv->ull);
> or
> sprintf(p, "%Lu", (unsigned long)cv->ull);

Fixed.

> 
> c67-gen.c lines 1904 and 1905 are unncesseary because are the same
> condition that lines 1902 and 1903

Fixed. Strange, because it seems it was written directly like this.

> 
> tcc.c line 82
> int ret = spawnvp(P_NOWAIT, prog, (char *const*)argv);
> maybe should be: //because spawnvp spect (const char * const *)
> int ret = spawnvp(P_NOWAIT, prog, (const char * const *)argv);

I prefer to leave it untouched as I don't see where it finds this signature for 
spawnvp. I found the prototype in win32/include/process.h but it's only char * 
const [] (the const seems redundant since an array cannot be modified).

Thanks for your report.

Cheers

Thomas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]