[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-dev] [patch] Get rid of warnings in findwebcams.cpp
From: |
Petter Reinholdtsen |
Subject: |
[Gnash-dev] [patch] Get rid of warnings in findwebcams.cpp |
Date: |
Mon, 22 Nov 2010 22:30:03 +0100 |
User-agent: |
Mutt/1.4.2.2i |
I had a look at the following warnings from the current build on
squeeze-kfreebsd.
findwebcams.cpp:132: warning: comparison between signed and unsigned integer
expressions
findwebcams.cpp:161: warning: comparison between signed and unsigned integer
expressions
findwebcams.cpp:170: warning: comparison between signed and unsigned integer
expressions
findwebcams.cpp:173: warning: format '%d' expects type 'int', but argument 2
has type 'size_t'
findwebcams.cpp:208: warning: comparison between signed and unsigned integer
expressions
I believe this patch solve the issues, bu using size_t for
non-negative values and casting the size_t argument to %d to (int).
diff --git a/utilities/findwebcams.cpp b/utilities/findwebcams.cpp
index 96e360c..4d3ceab 100644
--- a/utilities/findwebcams.cpp
+++ b/utilities/findwebcams.cpp
@@ -50,7 +50,7 @@ data::data() {
gint numDuplicates = 0;
-gint findVidDevs(std::vector<data*>& vidVect) {
+size_t findVidDevs(std::vector<data*>& vidVect) {
gint numdevs = 0;
//vid test source
@@ -105,7 +105,6 @@ gint findVidDevs(std::vector<data*>& vidVect) {
probe = NULL;
element = NULL;
devarr = NULL;
- gint g;
element = gst_element_factory_make ("v4l2src", "v4l2vidsrc");
probe = GST_PROPERTY_PROBE (element);
@@ -129,7 +128,7 @@ gint findVidDevs(std::vector<data*>& vidVect) {
vidVect[numdevs]->deviceNumber = numdevs;
//mark duplicates (we like v4l2 sources more than v4l, so if
//they're both detected, mark the v4l source as a duplicate)
- for (g=1; g < (vidVect.size()-1); g++) {
+ for (size_t g=1; g < (vidVect.size()-1); g++) {
if (strcmp(vidVect[numdevs]->deviceName,
vidVect[g]->deviceName) == 0) {
vidVect[g]->duplicate = true;
@@ -148,7 +147,7 @@ gint findVidDevs(std::vector<data*>& vidVect) {
int main () {
//initialize gstreamer to probe for devs
gst_init(NULL, NULL);
- gint numdevs = 0;
+ size_t numdevs = 0;
std::vector<data*> vidVector;
int fromrc = rcfile.getWebcamDevice();
@@ -170,7 +169,7 @@ int main () {
for (size_t i = 0; i < numdevs; ++i)
{
if (i == 0 && (vidVector[i] != 0)) {
- g_print(" %d. Video Test Source (videotestsrc)\n", i);
+ g_print(" %d. Video Test Source (videotestsrc)\n", (int)i);
counter++;
} else if (i == 0 && (vidVector[i] == 0)) {
g_print("no test video device available");
@@ -197,15 +196,15 @@ int main () {
} else {
dev_select = atoi(fromCin.c_str());
}
- if ((dev_select < 0) || (dev_select > (numdevs - numDuplicates -
1))) {
+ if ((dev_select < 0) || (dev_select > ((int)numdevs -
numDuplicates - 1))) {
g_print("You must make a valid device selection\n");
}
- } while ((dev_select < 0) || (dev_select > (numdevs - numDuplicates -
1)));
+ } while ((dev_select < 0) || (dev_select > ((int)numdevs -
numDuplicates - 1)));
g_print("\nTo select this camera, add this line to your gnashrc
file:\n");
g_print("set webcamDevice %d\n", vidVector[dev_select +
numDuplicates]->deviceNumber);
} else {
numdevs = findVidDevs(vidVector);
- if (fromrc <= (vidVector.size() - 1)) {
+ if ((size_t)fromrc < vidVector.size()) {
g_print("\nThe gnashrc file reports default webcam is set to:\n");
g_print("%s (%s)\n", vidVector[fromrc]->deviceName,
vidVector[fromrc]->deviceType);
Does this patch make sense to you?
Happy hacking,
--
Petter Reinholdtsen
- [Gnash-dev] [patch] Get rid of warnings in findwebcams.cpp,
Petter Reinholdtsen <=