From 3b1577ab7eb2000a3477a0aa489b888fb1256434 Mon Sep 17 00:00:00 2001 From: lurumdare <8020186+lurumdare@users.noreply.github.com> Date: 周六, 07 9月 2019 20:40:25 +0800 Subject: [PATCH] const everywhere (#30) --- src/library/base/logger.c | 2 test/functional/date_test.cpp | 4 src/library/base/EventRegistry.cpp | 2 src/tools/license-generator/license-generator.cpp | 6 +- test/functional/generate-license.cpp | 8 +- src/library/ini/ConvertUTF.c | 8 +- test/library/LicenseReader_test.cpp | 10 +- test/functional/volid_test.cpp | 6 +- src/library/pc-identifiers.c | 2 src/library/os/os-win.c | 8 +- src/library/LicenseReader.cpp | 42 +++++++------- test/functional/standard-license_test.cpp | 4 test/license-generator/license-generator_test.cpp | 8 +- src/tools/base_lib/win/CryptoHelperWindows.cpp | 2 src/tools/bootstrap/bootstrap.cpp | 6 +- src/library/base/StringUtils.cpp | 6 +- 16 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/library/LicenseReader.cpp b/src/library/LicenseReader.cpp index 06a068c..5ec8623 100644 --- a/src/library/LicenseReader.cpp +++ b/src/library/LicenseReader.cpp @@ -51,16 +51,16 @@ EventRegistry FullLicenseInfo::validate(int sw_version) { EventRegistry er; os_initialize(); - FUNCTION_RETURN sigVer = verifySignature(printForSign().c_str(), + const FUNCTION_RETURN sigVer = verifySignature(printForSign().c_str(), license_signature.c_str()); - bool sigVerified = sigVer == FUNC_RET_OK; + const bool sigVerified = sigVer == FUNC_RET_OK; if (sigVerified) { er.addEvent(LICENSE_VERIFIED, SVRT_INFO); } else { er.addEvent(LICENSE_CORRUPTED, SVRT_ERROR); } if (has_expiry) { - time_t now = time(NULL); + const time_t now = time(NULL); if (expires_on() < now) { er.addEvent(PRODUCT_EXPIRED, SVRT_ERROR, ""); } @@ -71,7 +71,7 @@ if (has_client_sig) { PcSignature str_code; strncpy(str_code, client_signature.c_str(), sizeof(str_code)-1); - EVENT_TYPE event = validate_pc_signature(str_code); + const EVENT_TYPE event = validate_pc_signature(str_code); if (event != LICENSE_OK) { er.addEvent(event, SVRT_ERROR); } @@ -91,7 +91,7 @@ license->days_left = 999999; } else { strncpy(license->expiry_date, to_date.c_str(), 11); - double secs = difftime( + const double secs = difftime( seconds_from_epoch(to_date.c_str()), time(NULL)); license->days_left = round(secs / (60 * 60 * 24)); @@ -116,7 +116,7 @@ CSimpleIniA ini; for (auto it = diskFiles.begin(); it != diskFiles.end(); it++) { ini.Reset(); - SI_Error rc = ini.LoadFile((*it).c_str()); + const SI_Error rc = ini.LoadFile((*it).c_str()); if (rc < 0) { result.addEvent(FILE_FORMAT_NOT_RECOGNIZED, SVRT_WARN, *it); continue; @@ -124,7 +124,7 @@ loadAtLeastOneFile = true; } const char* productNamePtr = product.c_str(); - int sectionSize = ini.GetSectionSize(productNamePtr); + const int sectionSize = ini.GetSectionSize(productNamePtr); if (sectionSize <= 0) { result.addEvent(PRODUCT_NOT_LICENSED, SVRT_WARN, *it); continue; @@ -142,13 +142,13 @@ */ const char * license_signature = ini.GetValue(productNamePtr, "license_signature", NULL); - long license_version = ini.GetLongValue(productNamePtr, + const long license_version = ini.GetLongValue(productNamePtr, "license_version", -1); if (license_signature != NULL && license_version > 0) { - string from_date = trim_copy( + const string from_date = trim_copy( ini.GetValue(productNamePtr, "from_date", FullLicenseInfo::UNUSED_TIME)); - string to_date = trim_copy( + const string to_date = trim_copy( ini.GetValue(productNamePtr, "to_date", FullLicenseInfo::UNUSED_TIME)); string client_signature = trim_copy( @@ -156,10 +156,10 @@ /*client_signature.erase( std::remove(client_signature.begin(), client_signature.end(), '-'), client_signature.end());*/ - int from_sw_version = ini.GetLongValue(productNamePtr, + const int from_sw_version = ini.GetLongValue(productNamePtr, "from_sw_version", FullLicenseInfo::UNUSED_SOFTWARE_VERSION); - int to_sw_version = ini.GetLongValue(productNamePtr, + const int to_sw_version = ini.GetLongValue(productNamePtr, "to_sw_version", FullLicenseInfo::UNUSED_SOFTWARE_VERSION); string extra_data = trim_copy( ini.GetValue(productNamePtr, "extra_data", "")); @@ -191,8 +191,8 @@ if (licenseLocation.licenseFileLocation != NULL && licenseLocation.licenseFileLocation[0] != '\0') { //hasFileLocation = true; - string varName(licenseLocation.licenseFileLocation); - vector<string> declared_positions = splitLicensePositions(varName); + const string varName(licenseLocation.licenseFileLocation); + const vector<string> declared_positions = splitLicensePositions(varName); vector<string> existing_pos = filterExistingFiles(declared_positions); if (existing_pos.size() > 0) { if (existing_pos.size() > 0) { @@ -215,12 +215,12 @@ bool licenseFileFoundWithEnvVariable = false; if (licenseLocation.environmentVariableName != NULL && licenseLocation.environmentVariableName[0] != '\0') { - string varName(licenseLocation.environmentVariableName); + const string varName(licenseLocation.environmentVariableName); if (varName.length() > 0) { //var name is passed in by the calling application. char* env_var_value = getenv(varName.c_str()); if (env_var_value != NULL && env_var_value[0] != '\0') { - vector<string> declared_positions = splitLicensePositions( + const vector<string> declared_positions = splitLicensePositions( string(env_var_value)); vector<string> existing_pos = filterExistingFiles( declared_positions); @@ -249,14 +249,14 @@ EventRegistry LicenseReader::getLicenseDiskFiles(vector<string>& diskFiles) { EventRegistry eventRegistry; - bool licenseFoundWithExplicitLocation = findLicenseWithExplicitLocation( + const bool licenseFoundWithExplicitLocation = findLicenseWithExplicitLocation( diskFiles, eventRegistry); bool foundNearModule = false; if (licenseLocation.openFileNearModule) { char fname[MAX_PATH] = { 0 }; - FUNCTION_RETURN fret = getModuleName(fname); + const FUNCTION_RETURN fret = getModuleName(fname); if (fret == FUNC_RET_OK) { - string temptativeLicense = string(fname) + ".lic"; + const string temptativeLicense = string(fname) + ".lic"; ifstream f(temptativeLicense.c_str()); if (f.good()) { foundNearModule = true; @@ -272,7 +272,7 @@ LOG_WARN("Error determining module name."); } } - bool licenseFileFoundWithEnvVariable = findFileWithEnvironmentVariable( + const bool licenseFileFoundWithEnvVariable = findFileWithEnvironmentVariable( diskFiles, eventRegistry); if (!foundNearModule && !licenseFoundWithExplicitLocation @@ -339,7 +339,7 @@ void FullLicenseInfo::printAsIni(ostream & a_ostream) const { CSimpleIniA ini; string result; - string product = toupper_copy(trim_copy(this->product)); + const string product = toupper_copy(trim_copy(this->product)); CSimpleIniA::StreamWriter sw(a_ostream); ini.SetLongValue(product.c_str(), "license_version", PROJECT_INT_VERSION); diff --git a/src/library/base/EventRegistry.cpp b/src/library/base/EventRegistry.cpp index 3119afa..7c21d6f 100644 --- a/src/library/base/EventRegistry.cpp +++ b/src/library/base/EventRegistry.cpp @@ -113,7 +113,7 @@ } void EventRegistry::exportLastEvents(AuditEvent* auditEvents, int nlogs) { - int sizeToCopy = min(nlogs, (int) logs.size()); + const int sizeToCopy = min(nlogs, (int) logs.size()); std::copy(logs.begin(), logs.begin() + sizeToCopy, auditEvents); } } diff --git a/src/library/base/StringUtils.cpp b/src/library/base/StringUtils.cpp index 97675b7..a635b47 100644 --- a/src/library/base/StringUtils.cpp +++ b/src/library/base/StringUtils.cpp @@ -42,14 +42,14 @@ int year, month, day; tm tm; if (strlen(timeString) == 8) { - int nfield = sscanf(timeString, "%4d%2d%2d", &year, &month, &day); + const int nfield = sscanf(timeString, "%4d%2d%2d", &year, &month, &day); if (nfield != 3) { throw invalid_argument("Date not recognized"); } } else if (strlen(timeString) == 10) { - int nfield = sscanf(timeString, "%4d-%2d-%2d", &year, &month, &day); + const int nfield = sscanf(timeString, "%4d-%2d-%2d", &year, &month, &day); if (nfield != 3) { - int nfield = sscanf(timeString, "%4d/%2d/%2d", &year, &month, &day); + const int nfield = sscanf(timeString, "%4d/%2d/%2d", &year, &month, &day); if (nfield != 3) { throw invalid_argument("Date not recognized"); } diff --git a/src/library/base/logger.c b/src/library/base/logger.c index 089fc85..a6dc5f3 100644 --- a/src/library/base/logger.c +++ b/src/library/base/logger.c @@ -33,7 +33,7 @@ strncpy(logpath, folder, MAX_PATH); strncat(logpath, "/open-license.log", MAX_PATH - strlen(logpath)); #else - int plen = GetTempPath(MAX_PATH, logpath); + const int plen = GetTempPath(MAX_PATH, logpath); if(plen == 0) { fprintf(stderr, "Error getting temporary directory path"); } diff --git a/src/library/ini/ConvertUTF.c b/src/library/ini/ConvertUTF.c index 20b7edc..fbc1911 100644 --- a/src/library/ini/ConvertUTF.c +++ b/src/library/ini/ConvertUTF.c @@ -228,7 +228,7 @@ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) { /* If the 16 bits following the high surrogate are in the source buffer... */ if (source < sourceEnd) { - UTF32 ch2 = *source; + const UTF32 ch2 = *source; /* If it's a low surrogate, convert to UTF32. */ if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) { ch = ((ch - UNI_SUR_HIGH_START) << halfShift) @@ -324,7 +324,7 @@ * This is not used here; it's just exported. */ Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) { - int length = trailingBytesForUTF8[*source]+1; + const int length = trailingBytesForUTF8[*source]+1; if (source+length > sourceEnd) { return false; } @@ -341,7 +341,7 @@ UTF16* target = *targetStart; while (source < sourceEnd) { UTF32 ch = 0; - unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + const unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; if (source + extraBytesToRead >= sourceEnd) { result = sourceExhausted; break; } @@ -467,7 +467,7 @@ UTF32* target = *targetStart; while (source < sourceEnd) { UTF32 ch = 0; - unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; + const unsigned short extraBytesToRead = trailingBytesForUTF8[*source]; if (source + extraBytesToRead >= sourceEnd) { result = sourceExhausted; break; } diff --git a/src/library/os/os-win.c b/src/library/os/os-win.c index d847405..a5a3bde 100644 --- a/src/library/os/os-win.c +++ b/src/library/os/os-win.c @@ -16,7 +16,7 @@ FUNCTION_RETURN result = FUNC_RET_ERROR; char buffer[MAX_COMPUTERNAME_LENGTH + 1]; int bufsize = MAX_COMPUTERNAME_LENGTH + 1; - BOOL cmpName = GetComputerName(buffer, &bufsize); + const BOOL cmpName = GetComputerName(buffer, &bufsize); if (cmpName) { strncpy(identifier, buffer, 6); result = FUNC_RET_OK; @@ -44,12 +44,12 @@ DWORD volSerial = 0; BOOL success; UINT driveType; - DWORD dwSize = MAX_PATH; + const DWORD dwSize = MAX_PATH; char szLogicalDrives[MAX_PATH] = { 0 }; unsigned char buf[8] = ""; FUNCTION_RETURN return_value; - DWORD dwResult = GetLogicalDriveStrings(dwSize, szLogicalDrives); + const DWORD dwResult = GetLogicalDriveStrings(dwSize, szLogicalDrives); if (dwResult > 0 && dwResult <= MAX_PATH) { return_value = FUNC_RET_OK; @@ -184,7 +184,7 @@ FUNCTION_RETURN getModuleName(char buffer[MAX_PATH]) { FUNCTION_RETURN result = FUNC_RET_OK; - DWORD wres = GetModuleFileName(NULL, buffer, MAX_PATH); + const DWORD wres = GetModuleFileName(NULL, buffer, MAX_PATH); if (wres == 0) { result = FUNC_RET_ERROR; } diff --git a/src/library/pc-identifiers.c b/src/library/pc-identifiers.c index 762a2ac..59f3dd1 100644 --- a/src/library/pc-identifiers.c +++ b/src/library/pc-identifiers.c @@ -283,7 +283,7 @@ PcIdentifier concat_identifiers[2]; char* b64_data = NULL; int b64_size = 0; - size_t concatIdentifiersSize = sizeof(PcIdentifier) * 2; + const size_t concatIdentifiersSize = sizeof(PcIdentifier) * 2; //concat_identifiers = (PcIdentifier *) malloc(concatIdentifiersSize); memcpy(&concat_identifiers[0], identifier1, sizeof(PcIdentifier)); memcpy(&concat_identifiers[1], identifier2, sizeof(PcIdentifier)); diff --git a/src/tools/base_lib/win/CryptoHelperWindows.cpp b/src/tools/base_lib/win/CryptoHelperWindows.cpp index c21a89b..4cdb31d 100644 --- a/src/tools/base_lib/win/CryptoHelperWindows.cpp +++ b/src/tools/base_lib/win/CryptoHelperWindows.cpp @@ -201,7 +201,7 @@ const string CryptoHelperWindows::signString(const void* privateKey, size_t pklen, const string& license) const { BYTE *pbBuffer = (BYTE *) license.c_str(); - DWORD dwBufferLen = (DWORD)strlen((char *)pbBuffer); + const DWORD dwBufferLen = (DWORD)strlen((char *)pbBuffer); HCRYPTHASH hHash; HCRYPTKEY hKey; diff --git a/src/tools/bootstrap/bootstrap.cpp b/src/tools/bootstrap/bootstrap.cpp index 4af84e9..98ad6b0 100644 --- a/src/tools/bootstrap/bootstrap.cpp +++ b/src/tools/bootstrap/bootstrap.cpp @@ -18,7 +18,7 @@ fprintf(fp, "#define PUBLIC_KEY { \\\n"); fprintf(fp, "%s", pbPublicKey.c_str()); fprintf(fp, "}\n\n"); - int random = rand() % 1000; + const int random = rand() % 1000; fprintf(fp, "#define SHARED_RANDOM %d;\n", random); fprintf(fp, "#endif\n"); fclose(fp); @@ -91,8 +91,8 @@ printf("********************************************\n"); } - string private_fname = string(argv[1]); - string public_fname(argv[2]); + const string private_fname = string(argv[1]); + const string public_fname(argv[2]); if (file_exists(private_fname) || file_exists(public_fname)) { printf("Key files exist, skipping key generation. Do 'make clean' to generate new keys.\n"); diff --git a/src/tools/license-generator/license-generator.cpp b/src/tools/license-generator/license-generator.cpp index 689d84c..ab3b716 100644 --- a/src/tools/license-generator/license-generator.cpp +++ b/src/tools/license-generator/license-generator.cpp @@ -145,12 +145,12 @@ void LicenseGenerator::generateAndOutputLicenses(const po::variables_map& vm, ostream& outputFile) { vector<FullLicenseInfo> licenseInfo = parseLicenseInfo(vm); - unique_ptr<CryptoHelper> helper = CryptoHelper::getInstance(); + const unique_ptr<CryptoHelper> helper = CryptoHelper::getInstance(); const char pkey[] = PRIVATE_KEY; - size_t len = sizeof(pkey); + const size_t len = sizeof(pkey); for (auto it = licenseInfo.begin(); it != licenseInfo.end(); ++it) { const string license = it->printForSign(); - string signature = helper->signString((const void *)pkey,len,license); + const string signature = helper->signString((const void *)pkey,len,license); it->license_signature = signature; it->printAsIni(outputFile); } diff --git a/test/functional/date_test.cpp b/test/functional/date_test.cpp index e45f2d8..b9d9ddc 100644 --- a/test/functional/date_test.cpp +++ b/test/functional/date_test.cpp @@ -25,7 +25,7 @@ licenseLocation.openFileNearModule = false; licenseLocation.licenseFileLocation = licLocation.c_str(); licenseLocation.environmentVariableName = ""; - EVENT_TYPE result = acquire_license("TEST", licenseLocation, &license); + const EVENT_TYPE result = acquire_license("TEST", licenseLocation, &license); BOOST_CHECK_EQUAL(result, LICENSE_OK); BOOST_CHECK_EQUAL(license.has_expiry, true); BOOST_CHECK_EQUAL(license.linked_to_pc, false); @@ -43,7 +43,7 @@ licenseLocation.openFileNearModule = false; licenseLocation.licenseFileLocation = licLocation.c_str(); licenseLocation.environmentVariableName = ""; - EVENT_TYPE result = acquire_license("TEST", licenseLocation, &license); + const EVENT_TYPE result = acquire_license("TEST", licenseLocation, &license); BOOST_CHECK_EQUAL(result, PRODUCT_EXPIRED); BOOST_CHECK_EQUAL(license.has_expiry, true); BOOST_CHECK_EQUAL(license.linked_to_pc, false); diff --git a/test/functional/generate-license.cpp b/test/functional/generate-license.cpp index 00fcd6a..8ffac2b 100644 --- a/test/functional/generate-license.cpp +++ b/test/functional/generate-license.cpp @@ -17,7 +17,7 @@ using namespace std; void generate_license(const string& fname, const vector<string>& other_args) { - int argc = 4+other_args.size(); + const int argc = 4+other_args.size(); const char** argv = new const char*[argc + 1]; unsigned int i=0; argv[i++] = "lic-generator"; @@ -27,13 +27,13 @@ argv[i++] = "-o"; argv[i++] = fname.c_str(); argv[i++] = "TEST"; - int retCode = LicenseGenerator::generateLicense(argc, argv); + const int retCode = LicenseGenerator::generateLicense(argc, argv); delete[] (argv); BOOST_CHECK_EQUAL(retCode, 0); BOOST_ASSERT(fs::exists(fname)); CSimpleIniA ini; - SI_Error rc = ini.LoadFile(fname.c_str()); + const SI_Error rc = ini.LoadFile(fname.c_str()); BOOST_CHECK_GE(rc,0); - int sectionSize = ini.GetSectionSize("TEST"); + const int sectionSize = ini.GetSectionSize("TEST"); BOOST_CHECK_GT(sectionSize,0); } diff --git a/test/functional/standard-license_test.cpp b/test/functional/standard-license_test.cpp index 8b49c50..18a6ae0 100644 --- a/test/functional/standard-license_test.cpp +++ b/test/functional/standard-license_test.cpp @@ -16,7 +16,7 @@ BOOST_AUTO_TEST_CASE( standard_lic_file ) { const string licLocation(PROJECT_TEST_TEMP_DIR "/standard_license.lic"); - vector<string> extraArgs; + const vector<string> extraArgs; generate_license(licLocation, extraArgs); /* */ LicenseInfo license; @@ -24,7 +24,7 @@ licenseLocation.openFileNearModule=false; licenseLocation.licenseFileLocation = licLocation.c_str(); licenseLocation.environmentVariableName = ""; - EVENT_TYPE result = acquire_license("TEST", + const EVENT_TYPE result = acquire_license("TEST", licenseLocation, & license); BOOST_CHECK_EQUAL(result, LICENSE_OK); BOOST_CHECK_EQUAL(license.has_expiry, false); diff --git a/test/functional/volid_test.cpp b/test/functional/volid_test.cpp index f8b0d8d..f63d2b3 100644 --- a/test/functional/volid_test.cpp +++ b/test/functional/volid_test.cpp @@ -21,9 +21,9 @@ const string licLocation(PROJECT_TEST_TEMP_DIR "/volid_license.lic"); PcSignature identifier_out; - IDENTIFICATION_STRATEGY strategy = IDENTIFICATION_STRATEGY::ETHERNET; + const IDENTIFICATION_STRATEGY strategy = IDENTIFICATION_STRATEGY::ETHERNET; BOOST_TEST_CHECKPOINT("Before generate"); - FUNCTION_RETURN generate_ok = generate_user_pc_signature(identifier_out, + const FUNCTION_RETURN generate_ok = generate_user_pc_signature(identifier_out, strategy); BOOST_TEST_CHECKPOINT("After generate signature"); BOOST_ASSERT(generate_ok == FUNCTION_RETURN::FUNC_RET_OK); @@ -39,7 +39,7 @@ licenseLocation.openFileNearModule = false; licenseLocation.licenseFileLocation = licLocation.c_str(); licenseLocation.environmentVariableName = ""; - EVENT_TYPE result = acquire_license("TEST", licenseLocation, &license); + const EVENT_TYPE result = acquire_license("TEST", licenseLocation, &license); BOOST_CHECK_EQUAL(result, LICENSE_OK); BOOST_CHECK_EQUAL(license.has_expiry, false); BOOST_CHECK_EQUAL(license.linked_to_pc, true); diff --git a/test/library/LicenseReader_test.cpp b/test/library/LicenseReader_test.cpp index af1b619..193f0f8 100644 --- a/test/library/LicenseReader_test.cpp +++ b/test/library/LicenseReader_test.cpp @@ -14,7 +14,7 @@ const LicenseLocation location = { licLocation, NULL, false }; LicenseReader licenseReader(location); vector<FullLicenseInfo> licenseInfos; - EventRegistry registry = licenseReader.readLicenses("PrODUCT", + const EventRegistry registry = licenseReader.readLicenses("PrODUCT", licenseInfos); BOOST_CHECK(registry.isGood()); BOOST_CHECK_EQUAL(1, licenseInfos.size()); @@ -26,7 +26,7 @@ const LicenseLocation location = { licLocation, NULL, false }; LicenseReader licenseReader(location); vector<FullLicenseInfo> licenseInfos; - EventRegistry registry = licenseReader.readLicenses("PRODUCT-NOT", + const EventRegistry registry = licenseReader.readLicenses("PRODUCT-NOT", licenseInfos); BOOST_CHECK(!registry.isGood()); BOOST_CHECK_EQUAL(0, licenseInfos.size()); @@ -41,7 +41,7 @@ const LicenseLocation location = { licLocation, NULL, false }; LicenseReader licenseReader(location); vector<FullLicenseInfo> licenseInfos; - EventRegistry registry = licenseReader.readLicenses("PRODUCT", + const EventRegistry registry = licenseReader.readLicenses("PRODUCT", licenseInfos); BOOST_CHECK(!registry.isGood()); BOOST_CHECK_EQUAL(0, licenseInfos.size()); @@ -55,7 +55,7 @@ const LicenseLocation location = { NULL, envName, false }; LicenseReader licenseReader(location); vector<FullLicenseInfo> licenseInfos; - EventRegistry registry = licenseReader.readLicenses("PRODUCT", + const EventRegistry registry = licenseReader.readLicenses("PRODUCT", licenseInfos); BOOST_CHECK(!registry.isGood()); BOOST_CHECK_EQUAL(0, licenseInfos.size()); @@ -71,7 +71,7 @@ const LicenseLocation location = { NULL, "LIC_VAR", false }; LicenseReader licenseReader(location); vector<FullLicenseInfo> licenseInfos; - EventRegistry registry = licenseReader.readLicenses("PrODUCT", + const EventRegistry registry = licenseReader.readLicenses("PrODUCT", licenseInfos); BOOST_CHECK(registry.isGood()); BOOST_CHECK_EQUAL(1, licenseInfos.size()); diff --git a/test/license-generator/license-generator_test.cpp b/test/license-generator/license-generator_test.cpp index 7410dc9..335f787 100644 --- a/test/license-generator/license-generator_test.cpp +++ b/test/license-generator/license-generator_test.cpp @@ -12,20 +12,20 @@ using namespace std; void generate_license(const string& prod_name, const string& fname) { - int argc = 4; + const int argc = 4; const char** argv = new const char*[argc + 1]; argv[0] = "lic-generator"; argv[1] = "-o"; argv[2] = fname.c_str(); argv[3] = "test"; - int retCode = LicenseGenerator::generateLicense(argc, argv); + const int retCode = LicenseGenerator::generateLicense(argc, argv); delete[] (argv); BOOST_CHECK_EQUAL(retCode, 0); BOOST_ASSERT(fs::exists(fname)); CSimpleIniA ini; - SI_Error rc = ini.LoadFile(fname.c_str()); + const SI_Error rc = ini.LoadFile(fname.c_str()); BOOST_CHECK_GE(rc,0); - int sectionSize = ini.GetSectionSize(prod_name.c_str()); + const int sectionSize = ini.GetSectionSize(prod_name.c_str()); BOOST_CHECK_GT(sectionSize,0); } -- Gitblit v1.9.1