[Top][All Lists]

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

[Gnash-dev] [patch] Get rid of warning in findmicrophones.cpp

From: Petter Reinholdtsen
Subject: [Gnash-dev] [patch] Get rid of warning in findmicrophones.cpp
Date: Sat, 20 Nov 2010 18:57:49 +0100
User-agent: Mutt/

Here is another patch to get rid of this warning from the compiler:

  findmicrophones.cpp:152: warning: comparison between signed and
    unsigned integer expressions

The cause is the integer fromrc being compared to the unsigned integer
returned from size(), which stay unsigned even after subtracting 1.

The else block in question is used when fromrc != -1, which I believe
also mean that it is a index into the audioVector array, ie values
from 0 and above.

Based on this assumtion, I believe the correct fix is to cast fromrc
to unsigned before comparing to ensure a correct result.

diff --git a/utilities/findmicrophones.cpp b/utilities/findmicrophones.cpp
index e368b5c..435295c 100644
--- a/utilities/findmicrophones.cpp
+++ b/utilities/findmicrophones.cpp
@@ -149,7 +149,7 @@ int main () {
         g_print("set microphoneDevice %d\n", dev_select);
     } else {
         numdevs = findAudioDevs(audioVector);
-        if (fromrc <= (audioVector.size() - 1)) {
+        if ((unsigned int)fromrc <= (audioVector.size() - 1)) {
             g_print("\nThe gnashrc file reports default microphone is set 
             g_print("%s (%s)\n", audioVector[fromrc]->deviceName,

Happy hacking,
Petter Reinholdtsen

reply via email to

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