Changeset 35632


Ignore:
Timestamp:
2021-10-18T17:33:52+13:00 (3 years ago)
Author:
davidb
Message:

Tidy up on treatment of 'string', 'char *', and 'const char*'. It was noticed that g++ was generating a warning message (warning: deprecated conversion from string constant to ‘char*’) on a call to extract_bundled_file() where a string literal was being passed as an argument. As this is C++ code, the string literal is treated as a 'const char*', however it was being passed to a function expecting a 'char *' mean the function could technically alter it if it wanted to (not easy to do -- danger, danger -- if you're a string literalfg). Of course our function doesn't do that, but the compiler isn't to know that. Simplest fix is to change our function to work with a 'const char*'. This also means some other lines of code in wrapper.cpp calling extract_bundled_file() could then loose the typecast they had for passing in a string as (char *)s.c_str()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/release-kits/shared/linux/wrapper.cpp

    r35568 r35632  
    1515#include "wrapper.h"
    1616#include "libsearch4j.h"
    17 bool extract_bundled_file( const char[], int, char*, bool );
     17bool extract_bundled_file( const char[], int, const char*, bool );
    1818#else
    1919bool prep_java( string wd );
     
    125125    //extract files
    126126    cout << "Extracting installer jar..." << endl;
    127     succeeded = extract_bundled_file( greenstonejar, sizeof(greenstonejar), (char*)jarfile.c_str(), false);
     127    succeeded = extract_bundled_file( greenstonejar, sizeof(greenstonejar), jarfile.c_str(), false);
    128128
    129129    #ifdef java_is_bundled
    130130    cout << "Preparing Greenstone installer..." << endl;
    131     succeeded = extract_bundled_file( java, sizeof(java), (char*)javafile.c_str(), true ) && succeeded;
     131    succeeded = extract_bundled_file( java, sizeof(java), javafile.c_str(), true ) && succeeded;
    132132    #endif
    133133       
     
    219219}
    220220#ifndef CDROM
    221 bool extract_bundled_file( const char data[], int size, char* filename, bool make_executable) {
     221bool extract_bundled_file( const char data[], int size, const char* filename, bool make_executable) {
    222222
    223223    if ( size == 0 ) return false;
Note: See TracChangeset for help on using the changeset viewer.