mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Fixed compiler warnings
- Replace strncpy() with strmake() to ensure things are \0 terminated - Initialized some variables that caused compiler warnings - Increased buffer that caused warnings from strncpy One warning from InnoDB, others from Connect.
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
#define NO_FUNC
|
||||
#include "plgcnx.h" // For DB types
|
||||
#include "resource.h"
|
||||
#include "m_string.h" // For strmake
|
||||
|
||||
/****************************************************************************/
|
||||
/* Definitions. */
|
||||
@@ -732,7 +733,7 @@ bool DBFFAM::AllocateBuffer(PGLOBAL g)
|
||||
return true;
|
||||
} // endswitch c
|
||||
|
||||
strncpy(descp->Name, cdp->GetName(), 11);
|
||||
strmake(descp->Name, cdp->GetName(), sizeof(descp->Name)-1);
|
||||
descp->Type = c;
|
||||
descp->Length = (uchar)cdp->GetLong();
|
||||
} // endif Flags
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include <mysqld.h>
|
||||
#include <mysql.h>
|
||||
#include <sql_error.h>
|
||||
#include <stdio.h>
|
||||
#include <m_string.h>
|
||||
|
||||
#include "jsonudf.h"
|
||||
|
||||
@@ -1475,16 +1475,16 @@ static PBSON MakeBinResult(PGLOBAL g, UDF_ARGS *args, PJSON top, ulong len, int
|
||||
|
||||
if ((bsnp->Filename = (char*)args->args[0])) {
|
||||
bsnp->Filename = MakePSZ(g, args, 0);
|
||||
strncpy(bsnp->Msg, bsnp->Filename, BMX);
|
||||
strmake(bsnp->Msg, bsnp->Filename, BMX-1);
|
||||
} else
|
||||
strncpy(bsnp->Msg, "null filename", BMX);
|
||||
strmake(bsnp->Msg, "null filename", BMX-1);
|
||||
|
||||
} else if (IsJson(args, 0) == 3) {
|
||||
PBSON bsp = (PBSON)args->args[0];
|
||||
|
||||
if (bsp->Filename) {
|
||||
bsnp->Filename = bsp->Filename;
|
||||
strncpy(bsnp->Msg, bsp->Filename, BMX);
|
||||
strmake(bsnp->Msg, bsp->Filename, BMX-1);
|
||||
bsnp->Pretty = bsp->Pretty;
|
||||
} else
|
||||
strcpy(bsnp->Msg, "Json Binary item");
|
||||
@@ -4758,7 +4758,7 @@ char *jbin_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
bsp = NULL;
|
||||
|
||||
if (!bsp && (bsp = JbinAlloc(g, args, initid->max_length, NULL)))
|
||||
strncpy(bsp->Msg, g->Message, BMX);
|
||||
strmake(bsp->Msg, g->Message, BMX-1);
|
||||
|
||||
// Keep result of constant function
|
||||
g->Xchk = (initid->const_item) ? bsp : NULL;
|
||||
@@ -4829,7 +4829,7 @@ char *jbin_array_add_values(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
|
||||
} else
|
||||
if ((bsp = JbinAlloc(g, args, initid->max_length, NULL)))
|
||||
strncpy(bsp->Msg, g->Message, BMX);
|
||||
strmake(bsp->Msg, g->Message, BMX-1);
|
||||
|
||||
// Keep result of constant function
|
||||
g->Xchk = (initid->const_item) ? bsp : NULL;
|
||||
@@ -5051,7 +5051,7 @@ char *jbin_object(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
|
||||
} else
|
||||
if ((bsp = JbinAlloc(g, args, initid->max_length, NULL)))
|
||||
strncpy(bsp->Msg, g->Message, BMX);
|
||||
strmake(bsp->Msg, g->Message, BMX-1);
|
||||
|
||||
// Keep result of constant function
|
||||
g->Xchk = (initid->const_item) ? bsp : NULL;
|
||||
@@ -5107,7 +5107,7 @@ char *jbin_object_nonull(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
|
||||
} else
|
||||
if ((bsp = JbinAlloc(g, args, initid->max_length, NULL)))
|
||||
strncpy(bsp->Msg, g->Message, BMX);
|
||||
strmake(bsp->Msg, g->Message, BMX-1);
|
||||
|
||||
// Keep result of constant function
|
||||
g->Xchk = (initid->const_item) ? bsp : NULL;
|
||||
@@ -5166,7 +5166,7 @@ char *jbin_object_key(UDF_INIT *initid, UDF_ARGS *args, char *result,
|
||||
|
||||
} else
|
||||
if ((bsp = JbinAlloc(g, args, initid->max_length, NULL)))
|
||||
strncpy(bsp->Msg, g->Message, BMX);
|
||||
strmake(bsp->Msg, g->Message, BMX-1);
|
||||
|
||||
// Keep result of constant function
|
||||
g->Xchk = (initid->const_item) ? bsp : NULL;
|
||||
|
@@ -12,9 +12,8 @@
|
||||
/* Include required compiler header files. */
|
||||
/***********************************************************************/
|
||||
#include "my_global.h"
|
||||
#include <stdio.h>
|
||||
#include <m_string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#if defined(__WIN__)
|
||||
#include <io.h>
|
||||
#include <winsock2.h>
|
||||
@@ -253,9 +252,10 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info)
|
||||
more:
|
||||
if (vp->atp) {
|
||||
size_t z = sizeof(colname) - 1;
|
||||
strncpy(colname, vp->atp->GetName(g), z);
|
||||
colname[z] = 0;
|
||||
strncat(xcol->Name, colname, XLEN(xcol->Name));
|
||||
size_t xlen= strlen(xcol->Name);
|
||||
strmake(colname, vp->atp->GetName(g), z);
|
||||
strmake(xcol->Name + xlen, colname,
|
||||
sizeof(xcol->Name) - 1 - xlen);
|
||||
|
||||
switch (vp->atp->GetText(g, buf, sizeof(buf))) {
|
||||
case RC_INFO:
|
||||
@@ -272,11 +272,13 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info)
|
||||
strncat(fmt, colname, XLEN(fmt));
|
||||
|
||||
} else {
|
||||
size_t xlen;
|
||||
if (tdp->Usedom && node->GetType() != 1)
|
||||
continue;
|
||||
|
||||
strncpy(colname, node->GetName(g), sizeof(colname));
|
||||
strncat(xcol->Name, colname, XLEN(xcol->Name));
|
||||
xlen= strlen(xcol->Name);
|
||||
strmake(colname, node->GetName(g), sizeof(colname)-1);
|
||||
strmake(xcol->Name + xlen, colname, sizeof(xcol->Name) - 1 - xlen);
|
||||
|
||||
if (j)
|
||||
strncat(fmt, colname, XLEN(fmt));
|
||||
|
@@ -5127,7 +5127,7 @@ i_s_sys_tables_fill_table_stats(
|
||||
|
||||
while (rec) {
|
||||
const char* err_msg;
|
||||
dict_table_t* table_rec;
|
||||
dict_table_t* table_rec= 0;
|
||||
|
||||
mtr.commit();
|
||||
/* Fetch the dict_table_t structure corresponding to
|
||||
|
@@ -360,7 +360,7 @@ grn_ts_expr_parser_tokenize_start(grn_ctx *ctx, grn_ts_expr_parser *parser,
|
||||
grn_ts_str str, grn_ts_expr_token **token)
|
||||
{
|
||||
grn_ts_str token_str = { str.ptr, 0 };
|
||||
grn_ts_expr_start_token *new_token;
|
||||
grn_ts_expr_start_token *new_token= 0;
|
||||
grn_rc rc = grn_ts_expr_start_token_open(ctx, token_str, &new_token);
|
||||
if (rc != GRN_SUCCESS) {
|
||||
return rc;
|
||||
@@ -375,7 +375,7 @@ grn_ts_expr_parser_tokenize_end(grn_ctx *ctx, grn_ts_expr_parser *parser,
|
||||
grn_ts_str str, grn_ts_expr_token **token)
|
||||
{
|
||||
grn_ts_str token_str = { str.ptr, 0 };
|
||||
grn_ts_expr_end_token *new_token;
|
||||
grn_ts_expr_end_token *new_token= 0;
|
||||
grn_rc rc = grn_ts_expr_end_token_open(ctx, token_str, &new_token);
|
||||
if (rc != GRN_SUCCESS) {
|
||||
return rc;
|
||||
@@ -393,7 +393,7 @@ grn_ts_expr_parser_tokenize_number(grn_ctx *ctx, grn_ts_expr_parser *parser,
|
||||
grn_rc rc;
|
||||
grn_ts_int int_value;
|
||||
grn_ts_str token_str;
|
||||
grn_ts_expr_const_token *new_token;
|
||||
grn_ts_expr_const_token *new_token= 0;
|
||||
|
||||
int_value = strtol(str.ptr, &end, 0);
|
||||
if ((end != str.ptr) && (*end != '.') && (*end != 'e')) {
|
||||
@@ -442,7 +442,7 @@ grn_ts_expr_parser_tokenize_text(grn_ctx *ctx, grn_ts_expr_parser *parser,
|
||||
size_t i, n_escapes = 0;
|
||||
grn_rc rc;
|
||||
grn_ts_str token_str;
|
||||
grn_ts_expr_const_token *new_token;
|
||||
grn_ts_expr_const_token *new_token= 0;
|
||||
for (i = 1; i < str.size; i++) {
|
||||
if (str.ptr[i] == '\\') {
|
||||
i++;
|
||||
@@ -504,7 +504,7 @@ grn_ts_expr_parser_tokenize_name(grn_ctx *ctx, grn_ts_expr_parser *parser,
|
||||
token_str.size = i;
|
||||
|
||||
if (grn_ts_str_is_bool(token_str)) {
|
||||
grn_ts_expr_const_token *new_token;
|
||||
grn_ts_expr_const_token *new_token= 0;
|
||||
grn_rc rc = grn_ts_expr_const_token_open(ctx, token_str, &new_token);
|
||||
if (rc != GRN_SUCCESS) {
|
||||
return rc;
|
||||
@@ -527,7 +527,7 @@ grn_ts_expr_parser_tokenize_bridge(grn_ctx *ctx, grn_ts_expr_parser *parser,
|
||||
grn_ts_str str, grn_ts_expr_token **token)
|
||||
{
|
||||
grn_ts_str token_str = { str.ptr, 1 };
|
||||
grn_ts_expr_bridge_token *new_token;
|
||||
grn_ts_expr_bridge_token *new_token= 0;
|
||||
grn_rc rc = grn_ts_expr_bridge_token_open(ctx, token_str, &new_token);
|
||||
if (rc != GRN_SUCCESS) {
|
||||
return rc;
|
||||
@@ -543,7 +543,7 @@ grn_ts_expr_parser_tokenize_bracket(grn_ctx *ctx, grn_ts_expr_parser *parser,
|
||||
grn_ts_expr_token **token)
|
||||
{
|
||||
grn_ts_str token_str = { str.ptr, 1 };
|
||||
grn_ts_expr_bracket_token *new_token;
|
||||
grn_ts_expr_bracket_token *new_token= 0;
|
||||
grn_rc rc = grn_ts_expr_bracket_token_open(ctx, token_str, &new_token);
|
||||
if (rc != GRN_SUCCESS) {
|
||||
return rc;
|
||||
@@ -567,7 +567,7 @@ grn_ts_expr_parser_tokenize_sign(grn_ctx *ctx, grn_ts_expr_parser *parser,
|
||||
grn_ts_op_type op_type;
|
||||
grn_ts_str token_str = { str.ptr, 1 };
|
||||
grn_ts_expr_token *prev_token = parser->tokens[parser->n_tokens - 1];
|
||||
grn_ts_expr_op_token *new_token;
|
||||
grn_ts_expr_op_token *new_token= 0;
|
||||
switch (prev_token->type) {
|
||||
case GRN_TS_EXPR_START_TOKEN:
|
||||
case GRN_TS_EXPR_OP_TOKEN: {
|
||||
@@ -626,7 +626,7 @@ grn_ts_expr_parser_tokenize_op(grn_ctx *ctx, grn_ts_expr_parser *parser,
|
||||
grn_rc rc = GRN_SUCCESS;
|
||||
grn_ts_str token_str = str;
|
||||
grn_ts_op_type op_type;
|
||||
grn_ts_expr_op_token *new_token;
|
||||
grn_ts_expr_op_token *new_token= 0;
|
||||
switch (str.ptr[0]) {
|
||||
case '+': case '-': {
|
||||
return grn_ts_expr_parser_tokenize_sign(ctx, parser, str, token);
|
||||
|
@@ -439,7 +439,7 @@ normalize(grn_ctx *ctx, grn_obj *string,
|
||||
normalized[normalized_length_in_bytes] = '\0';
|
||||
|
||||
if (rest_length > 0) {
|
||||
char buffer[SNIPPET_BUFFER_SIZE];
|
||||
char buffer[SNIPPET_BUFFER_SIZE+1];
|
||||
GRN_PLUGIN_LOG(ctx, GRN_LOG_DEBUG,
|
||||
"[normalizer][%s] failed to normalize at %u byte: %s",
|
||||
normalizer_type_label,
|
||||
|
Reference in New Issue
Block a user