From 94fc7a7c2af826453914811c177daea8e3f5afb1 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Wed, 3 Nov 2010 08:19:58 +0100 Subject: [PATCH] [flower] Remove compiler warnings. This has been tested with g++ 4.5.0 (20100722). --- flower/libc-extension.cc | 4 ++-- flower/rational.cc | 4 ++-- flower/string-convert.cc | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/flower/libc-extension.cc b/flower/libc-extension.cc index 78cd6be160..4cc8412da8 100644 --- a/flower/libc-extension.cc +++ b/flower/libc-extension.cc @@ -34,7 +34,7 @@ strnlwr (char *start, int n) char *p = start + n; while (--p >= start) { - *p = tolower (*p); /* a macro on some compilers */ + *p = (char)tolower (*p); /* a macro on some compilers */ } return start; } @@ -45,7 +45,7 @@ strnupr (char *start, int n) char *p = start + n; while (--p >= start) { - *p = toupper (*p); /* a macro on some compilers */ + *p = (char)toupper (*p); /* a macro on some compilers */ } return start; } diff --git a/flower/rational.cc b/flower/rational.cc index 048d45fcbe..cf1c9850bf 100644 --- a/flower/rational.cc +++ b/flower/rational.cc @@ -31,7 +31,7 @@ double Rational::to_double () const { if (sign_ == -1 || sign_ == 1 || sign_ == 0) - return ((double)sign_) * num_ / den_; + return (double)sign_ * (double)num_ / (double)den_; if (sign_ == -2) return -HUGE_VAL; else if (sign_ == 2) @@ -365,7 +365,7 @@ Rational::to_string () const int Rational::to_int () const { - return (int) num () / den (); + return (int)(num () / den ()); } int diff --git a/flower/string-convert.cc b/flower/string-convert.cc index 03bb05b319..c372520c16 100644 --- a/flower/string-convert.cc +++ b/flower/string-convert.cc @@ -37,7 +37,7 @@ string String_convert::bin2hex (Byte bin_char) { string str; - str += to_string ((char) nibble2hex_byte (bin_char >> 4)); + str += to_string ((char) nibble2hex_byte ((Byte)(bin_char >> 4))); str += to_string ((char) nibble2hex_byte (bin_char++)); return str; } @@ -49,7 +49,7 @@ String_convert::bin2hex (string bin_string) Byte const *byte = (Byte const*)bin_string.data (); for (ssize i = 0; i < bin_string.length (); i++) { - str += to_string ((char)nibble2hex_byte (*byte >> 4)); + str += to_string ((char)nibble2hex_byte ((Byte)(*byte >> 4))); str += to_string ((char)nibble2hex_byte (*byte++)); } return str; @@ -206,9 +206,9 @@ Byte String_convert::nibble2hex_byte (Byte byte) { if ((byte & 0x0f) <= 9) - return (byte & 0x0f) + '0'; + return (Byte)((byte & 0x0f) + '0'); else - return (byte & 0x0f) - 10 + 'a'; + return (Byte)((byte & 0x0f) - 10 + 'a'); } /** Convert an integer to a string -- 2.39.2