#1190 closed Defect (wontfix)
checkSize returns always 1
| Reported by: | serval2412 | Owned by: | davea | 
|---|---|---|---|
| Priority: | Undetermined | Milestone: | Undetermined | 
| Component: | BOINC - Graphics API | Version: | 7.0.25 | 
| Keywords: | Cc: | 
Description (last modified by )
Hello,
Here is the function checkSize
//      =============
//      checkSize
//      Make sure its a power of 2.
//      =============
int checkSize (int x){
        return 1;
        if (x == 2       || x == 4   ||
        x == 8   || x == 16  ||
        x == 32  || x == 64  ||
        x == 128 || x == 256 || x == 512)
                return 1;
    else
                return 0;
}
Either, we can remove checkSize function completety or "return 1" should be removed. In the last case, this function could be simply replaced by :
int checkSize (int x){
   return ((x mod 2) == 0);
}
If x can't be not more than 512, we could obviously change the function above like this :
int checkSize (int x){
   if (x > 512) return 0;
   return ((x mod 2) == 0);
}
then it could be interesting to comment why x can't be > 512
Julien.
Change History (5)
comment:1 Changed 13 years ago by
| Description: | modified (diff) | 
|---|
comment:2 Changed 13 years ago by
| Component: | Undetermined → BOINC - Graphics API | 
|---|---|
| Owner: | set to davea | 
comment:3 Changed 13 years ago by
This function is located in boinc/api/texture.cpp (line 227) and referenced twice in the same file (line 337) in function read_tga_texture()
comment:4 Changed 13 years ago by
| Resolution: | → wontfix | 
|---|---|
| Status: | new → closed | 
"x is a multiple of 2" isn't the same as "x is a power of 2".
In any case: I don't know this code; I assume the return 1 is there for a reason (like maybe the power-of-2 requirement doesn't exist any more). Also, no one uses .tga files AFAIK.
comment:5 Changed 13 years ago by
Shame on me ! :-( You're right of course ! I don't know why I thought about modulo 2 for this... Sorry for the noise

Fixed bug formatting.