Nux

Merge lp:~steve-stevebaker/nux/coverity-fixes into lp:nux

Proposed by Steve Baker
Status: Merged
Approved by: Tim Penhey
Approved revision: 625
Merged at revision: 621
Proposed branch: lp:~steve-stevebaker/nux/coverity-fixes
Merge into: lp:nux
Diff against target: 99 lines (+11/-11)
4 files modified
Nux/AnimatedTextureArea.cpp (+2/-2)
NuxGraphics/FontTexture.cpp (+7/-7)
NuxGraphics/GLTextureResourceManager.cpp (+1/-1)
tools/unity_support_test.c (+1/-1)
To merge this branch: bzr merge lp:~steve-stevebaker/nux/coverity-fixes
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Steve Baker (community) Needs Resubmitting
Jay Taoko Pending
Review via email: mp+108523@code.launchpad.net

Commit message

Cleaning up some coverity warnings.

Description of the change

Some janitorial work going through some Coverity bugs, just to get familiar with the codebase.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Single letter variables are fine if and only if they are used very close to their declaration.

The change in Nux/AnimatedTextureArea.cpp is acceptable because there is only one use, and it is effectively the next line.

However the change in NuxGraphics/FontTexture.cpp is not so acceptable. Oh dear, just read the source. Just renaming this to "stream" for now would be fine, although the entire function needs refactoring.

For the snprintf, please use sizeof(resultfilename) not the hard coded value of 27.

review: Needs Fixing
Revision history for this message
Steve Baker (steve-stevebaker) wrote :

Hi Tim

Thanks for the feedback, I'll resubmit when it is ready.

cheers

On Thu, Jun 7, 2012 at 11:56 AM, Tim Penhey <email address hidden> wrote:
> Review: Needs Fixing
>
> Single letter variables are fine if and only if they are used very close to their declaration.
>
> The change in Nux/AnimatedTextureArea.cpp is acceptable because there is only one use, and it is effectively the next line.
>
> However the change in NuxGraphics/FontTexture.cpp is not so acceptable.  Oh dear, just read the source.  Just renaming this to "stream" for now would be fine, although the entire function needs refactoring.
>
> For the snprintf, please use sizeof(resultfilename) not the hard coded value of 27.
> --
> https://code.launchpad.net/~steve-stevebaker/nux/coverity-fixes/+merge/108523
> You are the owner of lp:~steve-stevebaker/nux/coverity-fixes.

623. By Steve Baker

rename s to stream

624. By Steve Baker

use sizeof(resultfilename)

625. By Steve Baker

Merge from main branch

Revision history for this message
Steve Baker (steve-stevebaker) wrote :

Ready for review

review: Needs Resubmitting
Revision history for this message
Tim Penhey (thumper) wrote :

The code is nicer now. Thanks.

review: Approve
Revision history for this message
Tim Penhey (thumper) wrote :

Steve, can I get you to sign the contributors agreement? http://www.canonical.com/contributors

Revision history for this message
Steve Baker (steve-stevebaker) wrote :

On Mon, Jun 11, 2012 at 3:31 PM, Tim Penhey <email address hidden> wrote:
> Steve, can I get you to sign the contributors agreement? http://www.canonical.com/contributors

I have just signed it.

Revision history for this message
Tim Penhey (thumper) wrote :

Thanks... just waiting now for confirmation to flow through the system.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/AnimatedTextureArea.cpp'
2--- Nux/AnimatedTextureArea.cpp 2011-10-17 20:57:35 +0000
3+++ Nux/AnimatedTextureArea.cpp 2012-06-09 05:28:20 +0000
4@@ -71,9 +71,9 @@
5
6 }
7
8- void AnimatedTextureArea::SetTexture(TextureFrameAnimation *Texture)
9+ void AnimatedTextureArea::SetTexture(TextureFrameAnimation *t)
10 {
11- m_UserTexture = Texture;
12+ m_UserTexture = t;
13
14 if (m_UserTexture)
15 {
16
17=== modified file 'NuxGraphics/FontTexture.cpp'
18--- NuxGraphics/FontTexture.cpp 2011-10-19 20:32:38 +0000
19+++ NuxGraphics/FontTexture.cpp 2012-06-09 05:28:20 +0000
20@@ -147,11 +147,11 @@
21
22 unsigned int line_size = (unsigned int) Line.length();
23 char *tc = new char[line_size+1];
24- const char *Stream = tc;
25+ const char *stream = tc;
26 Memcpy(tc, Line.c_str(), line_size + 1);
27 tc[line_size] = 0;
28
29- if ( ParseCommand(&Stream, "common") /*Read == "common"*/)
30+ if ( ParseCommand(&stream, "common") /*Read == "common"*/)
31 {
32 Parse_bool(tc, "Bold=", m_Charset.bold);
33 Parse_bool(tc, "Italic=", m_Charset.italic);
34@@ -169,7 +169,7 @@
35 // Constant for now... Should be read from the font file
36 m_Charset.NumChar = 256;
37 }
38- else if (ParseCommand(&Stream, "char"))
39+ else if (ParseCommand(&stream, "char"))
40 {
41
42 unsigned short CharID = 0;
43@@ -187,14 +187,14 @@
44 Parse_s16(tc, "abcC=", m_Charset.Chars[CharID].abcC);
45 Parse_u16(tc, "page=", m_Charset.Chars[CharID].page);
46 }
47- else if ( ParseCommand(&Stream, "Kerning"))
48+ else if ( ParseCommand(&stream, "Kerning"))
49 {
50 Parse_u16(tc, "count=", m_Charset.NumKerningPairs);
51
52 if (m_Charset.NumKerningPairs > 0)
53 m_Charset.Kerning = new KerningPair[m_Charset.NumKerningPairs];
54 }
55- else if ( ParseCommand(&Stream, "KerningPair"))
56+ else if ( ParseCommand(&stream, "KerningPair"))
57 {
58 if (KerningIndex < m_Charset.NumKerningPairs)
59 {
60@@ -204,11 +204,11 @@
61 KerningIndex++;
62 }
63 }
64- else if ( ParseCommand(&Stream, "Texture"))
65+ else if ( ParseCommand(&stream, "Texture"))
66 {
67 char texture[256];
68
69- if (ParseLine(&Stream, texture, 256))
70+ if (ParseLine(&stream, texture, 256))
71 {
72 // FilePath FontPath;
73 // FontPath.AddSearchPath(""); // for case where fully qualified path is given
74
75=== modified file 'NuxGraphics/GLTextureResourceManager.cpp'
76--- NuxGraphics/GLTextureResourceManager.cpp 2012-02-18 21:32:06 +0000
77+++ NuxGraphics/GLTextureResourceManager.cpp 2012-06-09 05:28:20 +0000
78@@ -828,7 +828,7 @@
79 return ret;
80 }
81
82- void TextureVolume::GetData(void* Buffer, int MipIndex, int StrideY, int slice)
83+ void TextureVolume::GetData(void* Buffer, int MipIndex, int StrideY, int face)
84 {
85 BYTE *Dest = (BYTE *) Buffer;
86 // const BYTE* Src = _image.GetSurface(MipIndex, slice).GetPtrRawData();
87
88=== modified file 'tools/unity_support_test.c'
89--- tools/unity_support_test.c 2012-01-05 16:56:56 +0000
90+++ tools/unity_support_test.c 2012-06-09 05:28:20 +0000
91@@ -845,7 +845,7 @@
92
93 // drop result file
94 if (results.result != 5) {
95- sprintf(resultfilename, "/tmp/unity_support_test.%i", results.result);
96+ snprintf(resultfilename, sizeof(resultfilename), "/tmp/unity_support_test.%i", results.result);
97 resultfile = open(resultfilename, O_CREAT|O_WRONLY|O_EXCL, 0666);
98 if (resultfile > 0)
99 close(resultfile);

Subscribers

People subscribed via source and target branches