Make the codebase consistent, we already have a lot of implicit pointer comparisons.
Exception: Stay explicit on return's, example:
return _db != nullptr;
Signed-off-by: Michael Schuster <michael@schuster.ms>
HRESULT hr = CLASS_E_NOAGGREGATION;
// pUnkOuter is used for aggregation. We do not support it in the sample.
- if (pUnkOuter == nullptr) {
+ if (!pUnkOuter) {
hr = E_OUTOFMEMORY;
// Create the COM component.
if (SUCCEEDED(hr))
{
- if (pszData != nullptr)
+ if (pszData)
{
// Set the specified value of the key.
DWORD cbData = lstrlen(pszData) * sizeof(*pszData);
HRESULT OCContextMenuRegHandler::RegisterInprocServer(PCWSTR pszModule, const CLSID& clsid, PCWSTR pszFriendlyName, PCWSTR pszThreadModel)
{
- if (pszModule == nullptr || pszThreadModel == nullptr)
+ if (!pszModule || !pszThreadModel)
{
return E_INVALIDARG;
}
HRESULT OCContextMenuRegHandler::RegisterShellExtContextMenuHandler(
PCWSTR pszFileType, const CLSID& clsid, PCWSTR pszFriendlyName)
{
- if (pszFileType == nullptr)
+ if (!pszFileType)
{
return E_INVALIDARG;
}
HRESULT OCContextMenuRegHandler::UnregisterShellExtContextMenuHandler(
PCWSTR pszFileType, PCWSTR pszFriendlyName)
{
- if (pszFileType == nullptr)
+ if (!pszFileType)
{
return E_INVALIDARG;
}
{
HRESULT hResult = CLASS_E_NOAGGREGATION;
- if (pUnkOuter != nullptr) { return hResult; }
+ if (pUnkOuter) { return hResult; }
hResult = E_OUTOFMEMORY;
OCOverlay *lrOverlay = new (std::nothrow) OCOverlay(_state);
HRESULT OCOverlayRegistrationHandler::RegisterCOMObject(PCWSTR modulePath, PCWSTR friendlyName, const CLSID& clsid)
{
- if (modulePath == nullptr) {
+ if (!modulePath) {
return E_FAIL;
}
CFStringRef darkInterfaceStyle = CFSTR("Dark");
interfaceStyle = (CFStringRef)CFPreferencesCopyAppValue(interfaceStyleKey,
kCFPreferencesCurrentApplication);
- if (interfaceStyle != nullptr) {
+ if (interfaceStyle) {
returnValue = (kCFCompareEqualTo == CFStringCompare(interfaceStyle, darkInterfaceStyle, 0));
CFRelease(interfaceStyle);
}
int csync_update(CSYNC *ctx) {
int rc = -1;
- if (ctx == nullptr) {
+ if (!ctx) {
errno = EBADF;
return -1;
}
}
void *csync_get_userdata(CSYNC *ctx) {
- if (ctx == nullptr) {
+ if (!ctx) {
return nullptr;
}
return ctx->callbacks.userdata;
}
int csync_set_userdata(CSYNC *ctx, void *userdata) {
- if (ctx == nullptr) {
+ if (!ctx) {
return -1;
}
}
csync_auth_callback csync_get_auth_callback(CSYNC *ctx) {
- if (ctx == nullptr) {
+ if (!ctx) {
return nullptr;
}
}
int csync_set_status(CSYNC *ctx, int status) {
- if (ctx == nullptr || status < 0) {
+ if (!ctx || status < 0) {
return -1;
}
}
CSYNC_STATUS csync_get_status(CSYNC *ctx) {
- if (ctx == nullptr) {
+ if (!ctx) {
return CSYNC_STATUS_ERROR;
}
void csync_request_abort(CSYNC *ctx)
{
- if (ctx != nullptr) {
+ if (ctx) {
ctx->abort = true;
}
}
void csync_resume(CSYNC *ctx)
{
- if (ctx != nullptr) {
+ if (ctx) {
ctx->abort = false;
}
}
int csync_abort_requested(CSYNC *ctx)
{
- if (ctx != nullptr) {
+ if (ctx) {
return ctx->abort;
} else {
return (1 == 0);
// if the etag of this dir is still the same, its content is restored from the
// database.
if( do_read_from_db ) {
- if( ! fill_tree_from_db(ctx, db_uri) ) {
+ if(!fill_tree_from_db(ctx, db_uri)) {
errno = ENOENT;
ctx->status_code = CSYNC_STATUS_OPENDIR_ERROR;
goto error;
return 0;
}
- if ((dh = csync_vio_opendir(ctx, uri)) == nullptr) {
+ if (!(dh = csync_vio_opendir(ctx, uri))) {
if (ctx->abort) {
qCDebug(lcUpdate, "Aborted!");
ctx->status_code = CSYNC_STATUS_ABORTED;
error:
ctx->remote.read_from_db = read_from_db;
- if (dh != nullptr) {
+ if (dh) {
csync_vio_closedir(ctx, dh);
}
return -1;
{
int idx = 0;
- while (_instr[idx].instr_str != nullptr) {
+ while (_instr[idx].instr_str) {
if (_instr[idx].instr_code == instr) {
return _instr[idx].instr_str;
}
/* get process memory stats */
fp = fopen("/proc/self/statm","r");
- if (fp == nullptr) {
+ if (!fp) {
return;
}
s = fscanf(fp, "%d%d%d%d%d%d%d", &m.size, &m.resident, &m.shared, &m.trs,
/* Convert a locale String to UTF8 */
QByteArray c_utf8_from_locale(const mbchar_t *wstr)
{
- if (wstr == nullptr) {
+ if (!wstr) {
return QByteArray();
}
/* Convert a an UTF8 string to locale */
mbchar_t* c_utf8_string_to_locale(const char *str)
{
- if (str == nullptr ) {
+ if (!str) {
return nullptr;
}
#ifdef _WIN32
mbchar_t* c_utf8_path_to_locale(const char *str)
{
- if( str == nullptr ) {
+ if(!str) {
return nullptr;
} else {
#ifdef _WIN32
int csync_vio_closedir(CSYNC *ctx, csync_vio_handle_t *dhandle) {
int rc = -1;
- if (dhandle == nullptr) {
+ if (!dhandle) {
errno = EBADF;
return -1;
}
dirname = c_utf8_path_to_locale(name);
handle->dh = _topendir( dirname );
- if (handle->dh == nullptr) {
+ if (!handle->dh) {
c_free_locale_string(dirname);
SAFE_FREE(handle);
return nullptr;
dhandle_t *handle = nullptr;
int rc = -1;
- if (dhandle == nullptr) {
+ if (!dhandle) {
errno = EBADF;
return -1;
}
do {
dirent = _treaddir(handle->dh);
- if (dirent == nullptr)
+ if (!dirent)
return {};
} while (qstrcmp(dirent->d_name, ".") == 0 || qstrcmp(dirent->d_name, "..") == 0);
dhandle_t *handle = nullptr;
int rc = -1;
- if (dhandle == nullptr) {
+ if (!dhandle) {
errno = EBADF;
return -1;
}
void AccountSettings::slotEditCurrentIgnoredFiles()
{
Folder *f = FolderMan::instance()->folder(selectedFolderAlias());
- if (f == nullptr)
+ if (!f)
return;
openIgnoredFilesDialog(f->path());
}
//qCDebug(lcFolderMan) << "No more remote ETag check jobs to schedule.";
/* now it might be a good time to check for restarting... */
- if (_currentSyncFolder == nullptr && _appRestartRequired) {
+ if (!_currentSyncFolder && _appRestartRequired) {
restartApplication();
}
} else {
QStringList re;
foreach (Folder *folder, this->map().values()) {
- if (acc != nullptr && folder->accountState()->account() != acc) {
+ if (acc && folder->accountState()->account() != acc) {
continue;
}
QString path = folder->cleanPath();
while (i + sizeof(struct inotify_event) < static_cast<unsigned int>(len)) {
// cast an inotify_event
event = (struct inotify_event *)&buffer[i];
- if (event == nullptr) {
+ if (!event) {
qCDebug(lcFolderWatcher) << "NULL event";
i += sizeof(struct inotify_event);
continue;
void ownCloudGui::raiseDialog(QWidget *raiseWidget)
{
- if (raiseWidget && raiseWidget->parentWidget() == nullptr) {
+ if (raiseWidget && !raiseWidget->parentWidget()) {
// Qt has a bug which causes parent-less dialogs to pop-under.
raiseWidget->showNormal();
raiseWidget->raise();
Systray *Systray::instance()
{
- if (_instance == nullptr) {
+ if (!_instance) {
_instance = new Systray();
}
return _instance;
{
const auto folder = getFolder();
- if (folder != nullptr) {
+ if (folder) {
QDesktopServices::openUrl(QUrl::fromLocalFile(folder->path()));
}
}
UserModel *UserModel::instance()
{
- if (_instance == nullptr) {
+ if (!_instance) {
_instance = new UserModel();
}
return _instance;
UserAppsModel *UserAppsModel::instance()
{
- if (_instance == nullptr) {
+ if (!_instance) {
_instance = new UserAppsModel();
}
return _instance;
_relativeUploadDelayTimer.start();
return;
}
- if (_relativeLimitCurrentMeasuredDevice == nullptr) {
+ if (!_relativeLimitCurrentMeasuredDevice) {
qCDebug(lcBandwidthManager) << "No device set, just waiting 1 sec";
_relativeUploadDelayTimer.setInterval(1000);
_relativeUploadDelayTimer.start();
_relativeDownloadDelayTimer.start();
return;
}
- if (_relativeLimitCurrentMeasuredJob == nullptr) {
+ if (!_relativeLimitCurrentMeasuredJob) {
qCDebug(lcBandwidthManager) << "No job set, just waiting 1 sec";
_relativeDownloadDelayTimer.setInterval(1000);
_relativeDownloadDelayTimer.start();
{
int rc = -1;
- mbchar_t *mb_string = c_utf8_path_to_locale( TESTSTRING );
- mbchar_t *mb_null = c_utf8_path_to_locale( nullptr );
+ mbchar_t *mb_string = c_utf8_path_to_locale(TESTSTRING);
+ mbchar_t *mb_null = c_utf8_path_to_locale(nullptr);
(void) state;
#ifdef _WIN32
- assert_int_equal( wcscmp( LTESTSTRING, mb_string), 0 );
+ assert_int_equal(wcscmp(LTESTSTRING, mb_string), 0);
#else
assert_string_equal(mb_string, TESTSTRING);
#endif
- assert_true( mb_null == nullptr );
+ assert_false(mb_null);
assert_int_equal(rc, -1);
c_free_locale_string(mb_string);
"olonglonglonglong\\file.txt";
QByteArray new_long = OCC::FileSystem::pathtoUNC(QByteArray::fromRawData(longPath, strlen(longPath)));
- // printf( "XXXXXXXXXXXX %s %d\n", new_long, mem_reserved);
+ // printf("XXXXXXXXXXXX %s %d\n", new_long, mem_reserved);
assert_string_equal(new_long, longPathConv);
- // printf( "YYYYYYYYYYYY %ld\n", strlen(new_long));
- assert_int_equal( strlen(new_long), 286);
+ // printf("YYYYYYYYYYYY %ld\n", strlen(new_long));
+ assert_int_equal(strlen(new_long), 286);
}
int torture_run_tests(void)