Project Name | CID | Checker | Category | Developer Description |
---|---|---|---|---|
kortemik/OpenTechBFG | 35766 | COPY_PASTE_ERROR | Incorrect expression | Our code base contains a lot of copy paste mistakes, we are glad that there is a tool like coverity that can help to detect them. For a human it would be nearly impossible. |
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
*/ void idImage::SubImageUpload( int mipLevel, int x, int y, int z, int width, int height, const void* pic, int pixelPitch ) const { assert( x >= 0 && y >= 0 && mipLevel >= 0 && width >= 0 && height >= 0 && mipLevel < opts.numLevels ); int compressedSize = 0; if( IsCompressed() ) { assert( !( x & 3 ) && !( y & 3 ) ); // compressed size may be larger than the dimensions due to padding to quads int quadW = ( width + 3 ) & ~3; int quadH = ( height + 3 ) & ~3; compressedSize = quadW * quadH * BitsForFormat( opts.format ) / 8; int padW = ( opts.width + 3 ) & ~3; int padH = ( opts.height + 3 ) & ~3; assert( x + width <= padW && y + height <= padH ); // upload the non-aligned value, OpenGL understands that there // will be padding if( x + width > opts.width ) { |
<< "this->opts.width - x" looks like the original copy.
81 82 83 84 |
width = opts.width - x;
}
if( y + height > opts.height )
{ |
<<< CID 35766: Incorrect expression COPY_PASTE_ERROR <<< "x" in "this->opts.height - x" looks like a copy-paste error.
< Should it say "y" instead?
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
height = opts.height - x; } } else { assert( x + width <= opts.width && y + height <= opts.height ); } int target; int uploadTarget; if( opts.textureType == TT_2D ) { target = GL_TEXTURE_2D; uploadTarget = GL_TEXTURE_2D; } else if( opts.textureType == TT_CUBIC ) { target = GL_TEXTURE_CUBE_MAP; uploadTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + z; } else { assert( !"invalid opts.textureType" ); target = GL_TEXTURE_2D; uploadTarget = GL_TEXTURE_2D; } |
original | gl_Image.cpp:81 | |
remediation | gl_Image.cpp:85 | |
copy_paste_error | gl_Image.cpp:85 |