From 894c4ebd5203ad21cfa15832664b4bbade47b196 Mon Sep 17 00:00:00 2001 From: sukanka Date: Mon, 29 Apr 2024 21:06:12 +0800 Subject: [PATCH] fix build failure with -Werror=format-security --- src/jaspObject.cpp | 4 ++-- src/jaspResults.cpp | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/jaspObject.cpp b/src/jaspObject.cpp index eef3f9e..34f28cb 100644 --- a/src/jaspObject.cpp +++ b/src/jaspObject.cpp @@ -492,7 +492,7 @@ void jaspObject::dependOnNestedOptions(Rcpp::CharacterVector nestedOptionName) std::vector nestedKey = Rcpp::as>(nestedOptionName); Json::Value obj = getObjectFromNestedOption(nestedKey); if (obj.isNull()) - Rf_error(("nested key \"" + nestedKeyToString(nestedKey, "$") + "\"does not exist in the options!").c_str()); + Rf_error("nested key `%s` does not exist in the options!", nestedKeyToString(nestedKey, "$").c_str()); _nestedOptionMustBe[nestedKey] = obj; } @@ -505,7 +505,7 @@ void jaspObject::setNestedOptionMustContainDependency(Rcpp::CharacterVector nest std::vector nestedKey = Rcpp::as>(nestedOptionName); Json::Value obj = getObjectFromNestedOption(nestedKey); if (obj.isNull()) - Rf_error(("nested key \"" + nestedKeyToString(nestedKey, "$") + "\"does not exist in the options!").c_str()); + Rf_error("nested key `%s` does not exist in the options!", nestedKeyToString(nestedKey, "$").c_str()); _nestedOptionMustContain[nestedKey] = RObject_to_JsonValue(mustContainThis); } diff --git a/src/jaspResults.cpp b/src/jaspResults.cpp index a6766d5..63b4ae9 100644 --- a/src/jaspResults.cpp +++ b/src/jaspResults.cpp @@ -49,7 +49,7 @@ void jaspResults::setResponseData(int analysisID, int revision) _response["id"] = analysisID; _response["revision"] = revision; - + Json::Value progress; progress["value"] = -1; progress["label"] = ""; @@ -203,9 +203,7 @@ void jaspResults::saveResults() if(!saveHere.good()) { - static std::string error; - error = "Could not open file for saving jaspResults! File: '" + _saveResultsRoot + _saveResultsHere + "'"; - Rf_error(error.c_str());; + Rf_error("Could not open file for saving jaspResults! File: '%s%s'", _saveResultsRoot.c_str(), _saveResultsHere.c_str());; } Json::Value json = convertToJSON(); @@ -254,9 +252,7 @@ void jaspResults::loadResults() if(!val.isObject()) { - static std::string error; - error = "loading jaspResults had a problem, '" + _saveResultsRoot + _saveResultsHere + "' wasn't a JSON object!"; - Rf_error(error.c_str());; + Rf_error("loading jaspResults had a problem, '%s%s' wasn't a JSON object!", _saveResultsRoot.c_str(), _saveResultsHere.c_str());; } convertFromJSON_SetFields(val);