summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-01-17 22:03:11 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2012-01-17 22:03:42 +0100
commitb18bbabc91324f48b918f699a6c84ed83fbda49e (patch)
tree3b1e68fe45076c8eaaad70223b6cdeddaf3c1230 /rbutil/rbutilqt
parent633749ea61585940f8a003aab9c9db9afb96a030 (diff)
downloadrockbox-b18bbabc91324f48b918f699a6c84ed83fbda49e.tar.gz
rockbox-b18bbabc91324f48b918f699a6c84ed83fbda49e.zip
Fix unused-but-set warnings in helper functions.
Instead of storing the return value and ignoring it use it directly to check if an error occured. Addresses FS#12542. Change-Id: I447afa006366acfd1851d5b13cae5f1561050283
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/base/system.cpp54
1 files changed, 29 insertions, 25 deletions
diff --git a/rbutil/rbutilqt/base/system.cpp b/rbutil/rbutilqt/base/system.cpp
index 02e6ac9a91..7726e5738a 100644
--- a/rbutil/rbutilqt/base/system.cpp
+++ b/rbutil/rbutilqt/base/system.cpp
@@ -76,34 +76,34 @@
#if defined(Q_OS_WIN32)
enum System::userlevel System::userPermissions(void)
{
- LPUSER_INFO_1 buf;
- NET_API_STATUS napistatus;
+ LPUSER_INFO_1 buf = NULL;
wchar_t userbuf[UNLEN];
DWORD usersize = UNLEN;
BOOL status;
- enum userlevel result;
+ enum userlevel result = ERR;
status = GetUserNameW(userbuf, &usersize);
if(!status)
return ERR;
- napistatus = NetUserGetInfo(NULL, userbuf, (DWORD)1, (LPBYTE*)&buf);
-
- switch(buf->usri1_priv) {
- case USER_PRIV_GUEST:
- result = GUEST;
- break;
- case USER_PRIV_USER:
- result = USER;
- break;
- case USER_PRIV_ADMIN:
- result = ADMIN;
- break;
- default:
- result = ERR;
- break;
+ if(NetUserGetInfo(NULL, userbuf, (DWORD)1, (LPBYTE*)&buf) == NERR_Success) {
+ switch(buf->usri1_priv) {
+ case USER_PRIV_GUEST:
+ result = GUEST;
+ break;
+ case USER_PRIV_USER:
+ result = USER;
+ break;
+ case USER_PRIV_ADMIN:
+ result = ADMIN;
+ break;
+ default:
+ result = ERR;
+ break;
+ }
}
- NetApiBufferFree(buf);
+ if(buf != NULL)
+ NetApiBufferFree(buf);
return result;
}
@@ -142,9 +142,9 @@ QString System::userName(void)
#if defined(Q_OS_WIN32)
wchar_t userbuf[UNLEN];
DWORD usersize = UNLEN;
- BOOL status;
- status = GetUserNameW(userbuf, &usersize);
+ if(GetUserNameW(userbuf, &usersize) == 0)
+ return QString();
return QString::fromWCharArray(userbuf);
#endif
@@ -246,11 +246,15 @@ QMap<uint32_t, QString> System::listUsbDevices(void)
#if defined(Q_OS_LINUX)
#if defined(LIBUSB1)
libusb_device **devs;
- int res;
- ssize_t count;
- res = libusb_init(NULL);
+ if(libusb_init(NULL) != 0) {
+ qDebug() << "[System] Initializing libusb-1 failed.";
+ return usbids;
+ }
- count = libusb_get_device_list(NULL, &devs);
+ if(libusb_get_device_list(NULL, &devs) < 1) {
+ qDebug() << "[System] Error getting device list.";
+ return usbids;
+ }
libusb_device *dev;
int i = 0;
while((dev = devs[i++]) != NULL) {