The variable ‘dummy’ set but not used being treated as errors in Fedora.

Review URL: http://webrtc-codereview.appspot.com/122004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@425 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
wu@webrtc.org 2011-08-23 18:56:56 +00:00
parent ceb148ce59
commit ae53bf87d7

View File

@ -65,7 +65,8 @@ WebRtc_Word32 CpuLinux::CpuUsageMultiCore(WebRtc_UWord32& numCores,
numCores = m_numCores; numCores = m_numCores;
long long busy = 0; long long busy = 0;
long long idle = 0; long long idle = 0;
GetData(busy, idle, m_busyArray, m_idleArray); if (GetData(busy, idle, m_busyArray, m_idleArray) != 0)
return -1;
long long deltaBusy = busy - m_oldBusyTime; long long deltaBusy = busy - m_oldBusyTime;
long long deltaIdle = idle - m_oldIdleTime; long long deltaIdle = idle - m_oldIdleTime;
@ -116,18 +117,28 @@ int CpuLinux::GetData(long long& busy, long long& idle, long long*& busyArray,
} }
char line[100]; char line[100];
char* dummy = fgets(line, 100, fp); if (fgets(line, 100, fp) == NULL) {
fclose(fp);
return -1;
}
char firstWord[100]; char firstWord[100];
sscanf(line, "%s ", firstWord); if (sscanf(line, "%s ", firstWord) != 1) {
if(strncmp(firstWord, "cpu", 3)!=0) fclose(fp);
{ return -1;
}
if (strncmp(firstWord, "cpu", 3) != 0) {
fclose(fp);
return -1; return -1;
} }
char sUser[100]; char sUser[100];
char sNice[100]; char sNice[100];
char sSystem[100]; char sSystem[100];
char sIdle[100]; char sIdle[100];
sscanf(line, "%s %s %s %s %s ", firstWord, sUser, sNice, sSystem, sIdle); if (sscanf(line, "%s %s %s %s %s ",
firstWord, sUser, sNice, sSystem, sIdle) != 5) {
fclose(fp);
return -1;
}
long long luser = atoll(sUser); long long luser = atoll(sUser);
long long lnice = atoll(sNice); long long lnice = atoll(sNice);
long long lsystem = atoll(sSystem); long long lsystem = atoll(sSystem);
@ -137,9 +148,15 @@ int CpuLinux::GetData(long long& busy, long long& idle, long long*& busyArray,
idle = lidle; idle = lidle;
for (WebRtc_UWord32 i = 0; i < m_numCores; i++) for (WebRtc_UWord32 i = 0; i < m_numCores; i++)
{ {
dummy = fgets(line, 100, fp); if (fgets(line, 100, fp) == NULL) {
sscanf(line, "%s %s %s %s %s ", firstWord, sUser, sNice, sSystem, fclose(fp);
sIdle); return -1;
}
if (sscanf(line, "%s %s %s %s %s ", firstWord, sUser, sNice, sSystem,
sIdle) != 5) {
fclose(fp);
return -1;
}
luser = atoll(sUser); luser = atoll(sUser);
lnice = atoll(sNice); lnice = atoll(sNice);
lsystem = atoll(sSystem); lsystem = atoll(sSystem);
@ -171,7 +188,9 @@ int CpuLinux::GetNumCores()
numCores++; numCores++;
if (fgets(line, 100, fp)) if (fgets(line, 100, fp))
{ {
sscanf(line, "%s ", firstWord); if (sscanf(line, "%s ", firstWord) != 1) {
firstWord[0] = '\0';
}
} else { } else {
break; break;
} }