Merge pull request #656 from gittiver/fix_conversion_warnings

fix diverse compiler warnings
This commit is contained in:
Farook Al-Sammarraie 2023-06-17 09:04:15 +00:00 committed by GitHub
commit 13a91a1941
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 15 deletions

View File

@ -1300,7 +1300,7 @@ namespace crow
type t() const { return t_; }
/// Create an empty json value (outputs "{}" instead of a "null" string)
static crow::json::wvalue empty_object() { return crow::json::wvalue(std::move(crow::json::wvalue::object())); }
static crow::json::wvalue empty_object() { return crow::json::wvalue::object(); }
private:
type t_{type::Null}; ///< The type of the value.

View File

@ -173,10 +173,8 @@ namespace crow
bool isTagInsideObjectBlock(const int& current, const std::vector<context*>& stack) const
{
int openedBlock = 0;
int totalBlocksBefore = 0;
for (int i = current; i > 0; --i)
{
++totalBlocksBefore;
auto& action = actions_[i - 1];
if (action.t == ActionType::OpenBlock)

View File

@ -23,7 +23,7 @@ int qs_strncmp(const char* s, const char* qs, size_t n);
* Also decodes the value portion of the k/v pair *in-place*. In a future
* enhancement it will also have a compile-time option of sorting qs_kv
* alphabetically by key. */
int qs_parse(char* qs, char* qs_kv[], int qs_kv_size, bool parse_url);
size_t qs_parse(char* qs, char* qs_kv[], size_t qs_kv_size, bool parse_url);
/* Used by qs_parse to decode the value portion of a k/v pair */
@ -34,7 +34,7 @@ int qs_decode(char * qs);
* A future enhancement will be a compile-time option to look up the key
* in a pre-sorted qs_kv array via a binary search. */
//char * qs_k2v(const char * key, char * qs_kv[], int qs_kv_size);
char * qs_k2v(const char * key, char * const * qs_kv, int qs_kv_size, int nth);
char * qs_k2v(const char * key, char * const * qs_kv, size_t qs_kv_size, int nth);
/* Non-destructive lookup of value, based on key. User provides the
@ -51,7 +51,6 @@ char * qs_scanvalue(const char * key, const char * qs, char * val, size_t val_le
inline int qs_strncmp(const char * s, const char * qs, size_t n)
{
int i=0;
unsigned char u1, u2, unyb, lnyb;
while(n-- > 0)
@ -88,7 +87,6 @@ inline int qs_strncmp(const char * s, const char * qs, size_t n)
return u1 - u2;
if ( u1 == '\0' )
return 0;
i++;
}
if ( CROW_QS_ISQSCHR(*qs) )
return -1;
@ -97,9 +95,9 @@ inline int qs_strncmp(const char * s, const char * qs, size_t n)
}
inline int qs_parse(char* qs, char* qs_kv[], int qs_kv_size, bool parse_url = true)
inline size_t qs_parse(char* qs, char* qs_kv[], size_t qs_kv_size, bool parse_url = true)
{
int i, j;
size_t i, j;
char * substr_ptr;
for(i=0; i<qs_kv_size; i++) qs_kv[i] = NULL;
@ -172,9 +170,9 @@ inline int qs_decode(char * qs)
}
inline char * qs_k2v(const char * key, char * const * qs_kv, int qs_kv_size, int nth = 0)
inline char * qs_k2v(const char * key, char * const * qs_kv, size_t qs_kv_size, int nth = 0)
{
int i;
size_t i;
size_t key_len, skip;
key_len = strlen(key);
@ -202,9 +200,9 @@ inline char * qs_k2v(const char * key, char * const * qs_kv, int qs_kv_size, int
return nullptr;
}
inline std::unique_ptr<std::pair<std::string, std::string>> qs_dict_name2kv(const char * dict_name, char * const * qs_kv, int qs_kv_size, int nth = 0)
inline std::unique_ptr<std::pair<std::string, std::string>> qs_dict_name2kv(const char * dict_name, char * const * qs_kv, size_t qs_kv_size, int nth = 0)
{
int i;
size_t i;
size_t name_len, skip_to_eq, skip_to_brace_open, skip_to_brace_close;
name_len = strlen(dict_name);
@ -342,7 +340,7 @@ namespace crow
key_value_pairs_.resize(MAX_KEY_VALUE_PAIRS_COUNT);
int count = qs_parse(&url_[0], &key_value_pairs_[0], MAX_KEY_VALUE_PAIRS_COUNT, url);
size_t count = qs_parse(&url_[0], &key_value_pairs_[0], MAX_KEY_VALUE_PAIRS_COUNT, url);
key_value_pairs_.resize(count);
}

View File

@ -715,7 +715,8 @@ namespace crow
// a special device. Thus we search for the string (case-insensitive), and then check if the string ends or if
// is has a dangerous follow up character (.:\/)
auto sanitizeSpecialFile = [](std::string& source, unsigned ofs, const char* pattern, bool includeNumber, char replacement) {
unsigned i = ofs, len = source.length();
unsigned i = ofs;
size_t len = source.length();
const char* p = pattern;
while (*p)
{