summaryrefslogtreecommitdiff
path: root/sql/field.h
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2017-03-01 08:27:39 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2017-03-07 19:07:27 +0200
commit89d80c1b0be94639d0913dee7b6a284c32787b09 (patch)
treea08340d45a09b067df4490259f68b5a3f9d2fa03 /sql/field.h
parentd2f5e624223fe502ddf4c6f42062c29edb988627 (diff)
downloadmariadb-git-89d80c1b0be94639d0913dee7b6a284c32787b09.tar.gz
Fix many -Wconversion warnings.
Define my_thread_id as an unsigned type, to avoid mismatch with ulonglong. Change some parameters to this type. Use size_t in a few more places. Declare many flag constants as unsigned to avoid sign mismatch when shifting bits or applying the unary ~ operator. When applying the unary ~ operator to enum constants, explictly cast the result to an unsigned type, because enum constants can be treated as signed. In InnoDB, change the source code line number parameters from ulint to unsigned type. Also, make some InnoDB functions return a narrower type (unsigned or uint32_t instead of ulint; bool instead of ibool).
Diffstat (limited to 'sql/field.h')
-rw-r--r--sql/field.h54
1 files changed, 28 insertions, 26 deletions
diff --git a/sql/field.h b/sql/field.h
index 2dc5d91c126..50dcb397616 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1,7 +1,7 @@
#ifndef FIELD_INCLUDED
#define FIELD_INCLUDED
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
- Copyright (c) 2008, 2015, MariaDB
+ Copyright (c) 2008, 2017, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1022,7 +1022,7 @@ public:
virtual int cmp_max(const uchar *a, const uchar *b, uint max_len)
{ return cmp(a, b); }
virtual int cmp(const uchar *,const uchar *)=0;
- virtual int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L)
+ virtual int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0U)
{ return memcmp(a,b,pack_length()); }
virtual int cmp_offset(uint row_offset)
{ return cmp(ptr,ptr+row_offset); }
@@ -1373,7 +1373,8 @@ public:
void set_storage_type(ha_storage_media storage_type_arg)
{
DBUG_ASSERT(field_storage_type() == HA_SM_DEFAULT);
- flags |= (storage_type_arg << FIELD_FLAGS_STORAGE_MEDIA);
+ flags |= static_cast<uint32>(storage_type_arg) <<
+ FIELD_FLAGS_STORAGE_MEDIA;
}
column_format_type column_format() const
@@ -1385,7 +1386,8 @@ public:
void set_column_format(column_format_type column_format_arg)
{
DBUG_ASSERT(column_format() == COLUMN_FORMAT_TYPE_DEFAULT);
- flags |= (column_format_arg << FIELD_FLAGS_COLUMN_FORMAT);
+ flags |= static_cast<uint32>(column_format_arg) <<
+ FIELD_FLAGS_COLUMN_FORMAT;
}
/*
@@ -3134,7 +3136,7 @@ public:
int cmp_max(const uchar *, const uchar *, uint max_length);
int cmp(const uchar *a,const uchar *b)
{
- return cmp_max(a, b, ~0L);
+ return cmp_max(a, b, ~0U);
}
void sort_string(uchar *buff,uint length);
uint get_key_image(uchar *buff,uint length, imagetype type);
@@ -3143,7 +3145,7 @@ public:
virtual uchar *pack(uchar *to, const uchar *from, uint max_length);
virtual const uchar *unpack(uchar* to, const uchar *from,
const uchar *from_end, uint param_data);
- int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L);
+ int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0U);
int key_cmp(const uchar *,const uchar*);
int key_cmp(const uchar *str, uint length);
uint packed_col_length(const uchar *to, uint length);
@@ -3253,9 +3255,9 @@ public:
my_decimal *val_decimal(my_decimal *);
int cmp_max(const uchar *, const uchar *, uint max_length);
int cmp(const uchar *a,const uchar *b)
- { return cmp_max(a, b, ~0L); }
+ { return cmp_max(a, b, ~0U); }
int cmp(const uchar *a, uint32 a_length, const uchar *b, uint32 b_length);
- int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L);
+ int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0U);
int key_cmp(const uchar *,const uchar*);
int key_cmp(const uchar *str, uint length);
/* Never update the value of min_val for a blob field */
@@ -3955,26 +3957,26 @@ bool check_expression(Virtual_column_info *vcol, const char *name,
The following are for the interface with the .frm file
*/
-#define FIELDFLAG_DECIMAL 1
-#define FIELDFLAG_BINARY 1 // Shares same flag
-#define FIELDFLAG_NUMBER 2
-#define FIELDFLAG_ZEROFILL 4
-#define FIELDFLAG_PACK 120 // Bits used for packing
-#define FIELDFLAG_INTERVAL 256 // mangled with decimals!
-#define FIELDFLAG_BITFIELD 512 // mangled with decimals!
-#define FIELDFLAG_BLOB 1024 // mangled with decimals!
-#define FIELDFLAG_GEOM 2048 // mangled with decimals!
-
-#define FIELDFLAG_TREAT_BIT_AS_CHAR 4096 /* use Field_bit_as_char */
-#define FIELDFLAG_LONG_DECIMAL 8192
-#define FIELDFLAG_NO_DEFAULT 16384 /* sql */
-#define FIELDFLAG_MAYBE_NULL ((uint) 32768)// sql
-#define FIELDFLAG_HEX_ESCAPE ((uint) 0x10000)
+#define FIELDFLAG_DECIMAL 1U
+#define FIELDFLAG_BINARY 1U // Shares same flag
+#define FIELDFLAG_NUMBER 2U
+#define FIELDFLAG_ZEROFILL 4U
+#define FIELDFLAG_PACK 120U // Bits used for packing
+#define FIELDFLAG_INTERVAL 256U // mangled with decimals!
+#define FIELDFLAG_BITFIELD 512U // mangled with decimals!
+#define FIELDFLAG_BLOB 1024U // mangled with decimals!
+#define FIELDFLAG_GEOM 2048U // mangled with decimals!
+
+#define FIELDFLAG_TREAT_BIT_AS_CHAR 4096U /* use Field_bit_as_char */
+#define FIELDFLAG_LONG_DECIMAL 8192U
+#define FIELDFLAG_NO_DEFAULT 16384U /* sql */
+#define FIELDFLAG_MAYBE_NULL 32768U // sql
+#define FIELDFLAG_HEX_ESCAPE 0x10000U
#define FIELDFLAG_PACK_SHIFT 3
#define FIELDFLAG_DEC_SHIFT 8
-#define FIELDFLAG_MAX_DEC 63
+#define FIELDFLAG_MAX_DEC 63U
-#define MTYP_TYPENR(type) (type & 127) /* Remove bits from type */
+#define MTYP_TYPENR(type) (type & 127U) /* Remove bits from type */
#define f_is_dec(x) ((x) & FIELDFLAG_DECIMAL)
#define f_is_num(x) ((x) & FIELDFLAG_NUMBER)
@@ -3988,7 +3990,7 @@ bool check_expression(Virtual_column_info *vcol, const char *name,
#define f_is_bitfield(x) (((x) & (FIELDFLAG_BITFIELD | FIELDFLAG_NUMBER)) == FIELDFLAG_BITFIELD)
#define f_is_blob(x) (((x) & (FIELDFLAG_BLOB | FIELDFLAG_NUMBER)) == FIELDFLAG_BLOB)
#define f_is_geom(x) (((x) & (FIELDFLAG_GEOM | FIELDFLAG_NUMBER)) == FIELDFLAG_GEOM)
-#define f_settype(x) (((int) (x)) << FIELDFLAG_PACK_SHIFT)
+#define f_settype(x) (((uint) (x)) << FIELDFLAG_PACK_SHIFT)
#define f_maybe_null(x) ((x) & FIELDFLAG_MAYBE_NULL)
#define f_no_default(x) ((x) & FIELDFLAG_NO_DEFAULT)
#define f_bit_as_char(x) ((x) & FIELDFLAG_TREAT_BIT_AS_CHAR)