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
This commit is contained in:
Dominik Riebeling 2012-01-17 22:03:11 +01:00
parent 633749ea61
commit b18bbabc91

View file

@ -76,19 +76,17 @@
#if defined(Q_OS_WIN32) #if defined(Q_OS_WIN32)
enum System::userlevel System::userPermissions(void) enum System::userlevel System::userPermissions(void)
{ {
LPUSER_INFO_1 buf; LPUSER_INFO_1 buf = NULL;
NET_API_STATUS napistatus;
wchar_t userbuf[UNLEN]; wchar_t userbuf[UNLEN];
DWORD usersize = UNLEN; DWORD usersize = UNLEN;
BOOL status; BOOL status;
enum userlevel result; enum userlevel result = ERR;
status = GetUserNameW(userbuf, &usersize); status = GetUserNameW(userbuf, &usersize);
if(!status) if(!status)
return ERR; return ERR;
napistatus = NetUserGetInfo(NULL, userbuf, (DWORD)1, (LPBYTE*)&buf); if(NetUserGetInfo(NULL, userbuf, (DWORD)1, (LPBYTE*)&buf) == NERR_Success) {
switch(buf->usri1_priv) { switch(buf->usri1_priv) {
case USER_PRIV_GUEST: case USER_PRIV_GUEST:
result = GUEST; result = GUEST;
@ -103,6 +101,8 @@ enum System::userlevel System::userPermissions(void)
result = ERR; result = ERR;
break; break;
} }
}
if(buf != NULL)
NetApiBufferFree(buf); NetApiBufferFree(buf);
return result; return result;
@ -142,9 +142,9 @@ QString System::userName(void)
#if defined(Q_OS_WIN32) #if defined(Q_OS_WIN32)
wchar_t userbuf[UNLEN]; wchar_t userbuf[UNLEN];
DWORD usersize = UNLEN; DWORD usersize = UNLEN;
BOOL status;
status = GetUserNameW(userbuf, &usersize); if(GetUserNameW(userbuf, &usersize) == 0)
return QString();
return QString::fromWCharArray(userbuf); return QString::fromWCharArray(userbuf);
#endif #endif
@ -246,11 +246,15 @@ QMap<uint32_t, QString> System::listUsbDevices(void)
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)
#if defined(LIBUSB1) #if defined(LIBUSB1)
libusb_device **devs; libusb_device **devs;
int res; if(libusb_init(NULL) != 0) {
ssize_t count; qDebug() << "[System] Initializing libusb-1 failed.";
res = libusb_init(NULL); 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; libusb_device *dev;
int i = 0; int i = 0;
while((dev = devs[i++]) != NULL) { while((dev = devs[i++]) != NULL) {