summaryrefslogtreecommitdiff
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
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
-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 @@
76#if defined(Q_OS_WIN32) 76#if defined(Q_OS_WIN32)
77enum System::userlevel System::userPermissions(void) 77enum System::userlevel System::userPermissions(void)
78{ 78{
79 LPUSER_INFO_1 buf; 79 LPUSER_INFO_1 buf = NULL;
80 NET_API_STATUS napistatus;
81 wchar_t userbuf[UNLEN]; 80 wchar_t userbuf[UNLEN];
82 DWORD usersize = UNLEN; 81 DWORD usersize = UNLEN;
83 BOOL status; 82 BOOL status;
84 enum userlevel result; 83 enum userlevel result = ERR;
85 84
86 status = GetUserNameW(userbuf, &usersize); 85 status = GetUserNameW(userbuf, &usersize);
87 if(!status) 86 if(!status)
88 return ERR; 87 return ERR;
89 88
90 napistatus = NetUserGetInfo(NULL, userbuf, (DWORD)1, (LPBYTE*)&buf); 89 if(NetUserGetInfo(NULL, userbuf, (DWORD)1, (LPBYTE*)&buf) == NERR_Success) {
91 90 switch(buf->usri1_priv) {
92 switch(buf->usri1_priv) { 91 case USER_PRIV_GUEST:
93 case USER_PRIV_GUEST: 92 result = GUEST;
94 result = GUEST; 93 break;
95 break; 94 case USER_PRIV_USER:
96 case USER_PRIV_USER: 95 result = USER;
97 result = USER; 96 break;
98 break; 97 case USER_PRIV_ADMIN:
99 case USER_PRIV_ADMIN: 98 result = ADMIN;
100 result = ADMIN; 99 break;
101 break; 100 default:
102 default: 101 result = ERR;
103 result = ERR; 102 break;
104 break; 103 }
105 } 104 }
106 NetApiBufferFree(buf); 105 if(buf != NULL)
106 NetApiBufferFree(buf);
107 107
108 return result; 108 return result;
109} 109}
@@ -142,9 +142,9 @@ QString System::userName(void)
142#if defined(Q_OS_WIN32) 142#if defined(Q_OS_WIN32)
143 wchar_t userbuf[UNLEN]; 143 wchar_t userbuf[UNLEN];
144 DWORD usersize = UNLEN; 144 DWORD usersize = UNLEN;
145 BOOL status;
146 145
147 status = GetUserNameW(userbuf, &usersize); 146 if(GetUserNameW(userbuf, &usersize) == 0)
147 return QString();
148 148
149 return QString::fromWCharArray(userbuf); 149 return QString::fromWCharArray(userbuf);
150#endif 150#endif
@@ -246,11 +246,15 @@ QMap<uint32_t, QString> System::listUsbDevices(void)
246#if defined(Q_OS_LINUX) 246#if defined(Q_OS_LINUX)
247#if defined(LIBUSB1) 247#if defined(LIBUSB1)
248 libusb_device **devs; 248 libusb_device **devs;
249 int res; 249 if(libusb_init(NULL) != 0) {
250 ssize_t count; 250 qDebug() << "[System] Initializing libusb-1 failed.";
251 res = libusb_init(NULL); 251 return usbids;
252 }
252 253
253 count = libusb_get_device_list(NULL, &devs); 254 if(libusb_get_device_list(NULL, &devs) < 1) {
255 qDebug() << "[System] Error getting device list.";
256 return usbids;
257 }
254 libusb_device *dev; 258 libusb_device *dev;
255 int i = 0; 259 int i = 0;
256 while((dev = devs[i++]) != NULL) { 260 while((dev = devs[i++]) != NULL) {