From 6ae16b87d0560ac06e882da122f43b0e9b913b34 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 18 Nov 2017 19:57:50 +0100 Subject: Constify strings in pref.h Make all char * pointers in pref.h const to make it clear that these strings are not mutable. This meant adding a number of (void *) casts in calls to free(). Apart from being the right thing to do, this commit makes the code more consistent, as many of the strings in pref.h were already const. While touching core/qthelper.cpp turn three instances of (void*) into (void *). Signed-off-by: Berthold Stoeger --- mobile-widgets/qmlmanager.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'mobile-widgets/qmlmanager.cpp') diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index b0e597f6f..2c28ccf83 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -383,7 +383,7 @@ void QMLManager::saveCloudCredentials() s.setValue("cloud_verification_status", credentialStatus()); s.sync(); if (!same_string(prefs.cloud_storage_email, qPrintable(cloudUser))) { - free(prefs.cloud_storage_email); + free((void *)prefs.cloud_storage_email); prefs.cloud_storage_email = strdup(qPrintable(cloudUser)); cloudCredentialsChanged = true; } @@ -396,7 +396,7 @@ void QMLManager::saveCloudCredentials() } if (!same_string(prefs.cloud_storage_password, qPrintable(cloudPwd))) { - free(prefs.cloud_storage_password); + free((void *)prefs.cloud_storage_password); prefs.cloud_storage_password = strdup(qPrintable(cloudPwd)); } if (cloudUser.isEmpty() || cloudPwd.isEmpty()) { @@ -404,7 +404,7 @@ void QMLManager::saveCloudCredentials() } else if (cloudCredentialsChanged) { // let's make sure there are no unsaved changes saveChangesLocal(); - free(prefs.userid); + free((void *)prefs.userid); prefs.userid = NULL; syncLoadFromCloud(); QString url; @@ -550,7 +550,7 @@ void QMLManager::retrieveUserid() } if (!userid.isEmpty()) { // overwrite the existing userid - free(prefs.userid); + free((void *)prefs.userid); prefs.userid = strdup(qPrintable(userid)); QSettings s; s.setValue("subsurface_webservice_uid", prefs.userid); @@ -649,9 +649,9 @@ void QMLManager::revertToNoCloudIfNeeded() appendTextToLog(QStringLiteral("taking things back offline since sync with cloud failed")); prefs.git_local_only = syncToCloud(); } - free(prefs.cloud_storage_email); + free((void *)prefs.cloud_storage_email); prefs.cloud_storage_email = NULL; - free(prefs.cloud_storage_password); + free((void *)prefs.cloud_storage_password); prefs.cloud_storage_password = NULL; setCloudUserName(""); setCloudPassword(""); -- cgit v1.2.3-70-g09d2