dbTalk Databases Forums  

Patch to fix char signedness issue on ppc

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Patch to fix char signedness issue on ppc in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Michael Hanselmann
 
Posts: n/a

Default Patch to fix char signedness issue on ppc - 11-22-2006 , 05:41 PM






--pvezYHf7grwyp3Bc
Content-Type: multipart/mixed; boundary="UugvWAfsgieZRqgk"
Content-Disposition: inline


--UugvWAfsgieZRqgk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello

On Linux/ppc, gcc uses unsigned char's by default. query.cpp constructs
an object of SQLParseElement and gives it a value of -1 for the "char"
parameter (n). Later this value is compared to -1, which will be 255
when using unsigned chars. The result is a wrongly thrown exception. The
attached patch changes the type to "short int" where the number is used.

Signed-off-by: Michael Hanselmann <mysql (AT) hansmi (DOT) ch>

Greets,
Michael

--=20
Gentoo Linux developer, http://hansmi.ch/, http://forkbomb.ch/

--UugvWAfsgieZRqgk
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="mysql++-signed-char-fix.diff"
Content-Transfer-Encoding: quoted-printable

diff -ru mysql++-2.1.1.orig/lib/qparms.h mysql++-2.1.1/lib/qparms.h
--- mysql++-2.1.1.orig/lib/qparms.h 2006-04-05 06:44:49.000000000 +0200
+++ mysql++-2.1.1/lib/qparms.h 2006-11-23 00:11:05.000000000 +0100
@@ -232,7 +232,7 @@
/// \param b the 'before' value
/// \param o the 'option' value
/// \param n the 'num' value
- SQLParseElement(std::string b, char o, char n) :
+ SQLParseElement(std::string b, char o, short int n) :
before(b),
option(o),
num(n)
@@ -241,7 +241,7 @@
=09
std::string before; ///< string inserted before the parameter
char option; ///< the parameter option, or blank if none
- char num; ///< the parameter position to use
+ short int num; ///< the parameter position to use
};
=20
} // end namespace mysqlpp
diff -ru mysql++-2.1.1.orig/lib/query.cpp mysql++-2.1.1/lib/query.cpp
--- mysql++-2.1.1.orig/lib/query.cpp 2006-04-05 06:44:49.000000000 +0200
+++ mysql++-2.1.1/lib/query.cpp 2006-11-23 00:16:04.000000000 +0100
@@ -220,7 +220,7 @@
}
=20
// Finished parsing parameter; save it.
- parse_elems_.push_back(SQLParseElement(str, option, char(n)));
+ parse_elems_.push_back(SQLParseElement(str, option, n));
str =3D "";
name =3D "";
}
@@ -304,7 +304,7 @@
{
sbuffer_.str("");
=20
- char num;
+ short int num;
SQLString* ss;
SQLQueryParms* c;
=20

--UugvWAfsgieZRqgk--

--pvezYHf7grwyp3Bc
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFZN/z6J0saEpRu+oRAgLMAJ4i8seUW2knQ5VKahALa/9UZx44QwCffTvX
UrzZ5fxC1shoecknALxNt/E=
=UmvO
-----END PGP SIGNATURE-----

--pvezYHf7grwyp3Bc--

Reply With Quote
  #2  
Old   
Ovidiu Bivolaru
 
Posts: n/a

Default Re: Patch to fix char signedness issue on ppc - 11-22-2006 , 05:49 PM






Nice patch. I have always used: CFLAGS/CXXFLAGS with -fsigned-char to
compile on Linux/PPC.

Regards,
Ovidiu

Michael Hanselmann wrote:
Quote:
Hello

On Linux/ppc, gcc uses unsigned char's by default. query.cpp constructs
an object of SQLParseElement and gives it a value of -1 for the "char"
parameter (n). Later this value is compared to -1, which will be 255
when using unsigned chars. The result is a wrongly thrown exception. The
attached patch changes the type to "short int" where the number is used.

Signed-off-by: Michael Hanselmann <mysql (AT) hansmi (DOT) ch

Greets,
Michael


------------------------------------------------------------------------

diff -ru mysql++-2.1.1.orig/lib/qparms.h mysql++-2.1.1/lib/qparms.h
--- mysql++-2.1.1.orig/lib/qparms.h 2006-04-05 06:44:49.000000000 +0200
+++ mysql++-2.1.1/lib/qparms.h 2006-11-23 00:11:05.000000000 +0100
@@ -232,7 +232,7 @@
/// \param b the 'before' value
/// \param o the 'option' value
/// \param n the 'num' value
- SQLParseElement(std::string b, char o, char n) :
+ SQLParseElement(std::string b, char o, short int n) :
before(b),
option(o),
num(n)
@@ -241,7 +241,7 @@

std::string before; ///< string inserted before the parameter
char option; ///< the parameter option, or blank if none
- char num; ///< the parameter position to use
+ short int num; ///< the parameter position to use
};

} // end namespace mysqlpp
diff -ru mysql++-2.1.1.orig/lib/query.cpp mysql++-2.1.1/lib/query.cpp
--- mysql++-2.1.1.orig/lib/query.cpp 2006-04-05 06:44:49.000000000 +0200
+++ mysql++-2.1.1/lib/query.cpp 2006-11-23 00:16:04.000000000 +0100
@@ -220,7 +220,7 @@
}

// Finished parsing parameter; save it.
- parse_elems_.push_back(SQLParseElement(str, option, char(n)));
+ parse_elems_.push_back(SQLParseElement(str, option, n));
str = "";
name = "";
}
@@ -304,7 +304,7 @@
{
sbuffer_.str("");

- char num;
+ short int num;
SQLString* ss;
SQLQueryParms* c;



--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
Warren Young
 
Posts: n/a

Default Re: Patch to fix char signedness issue on ppc - 11-27-2006 , 06:31 PM



Michael Hanselmann wrote:
Quote:
On Linux/ppc, gcc uses unsigned char's by default. query.cpp constructs
an object of SQLParseElement and gives it a value of -1 for the "char"
parameter (n). Later this value is compared to -1, which will be 255
when using unsigned chars. The result is a wrongly thrown exception. The
attached patch changes the type to "short int" where the number is used.
Unfortunately, that will change the ABI of the library, which would
force this change to wait for v3.0. Instead, why not just make the
required signedness explicit? Then the library interface stays the
same, so I can apply it immediately.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #4  
Old   
Michael Hanselmann
 
Posts: n/a

Default Re: Patch to fix char signedness issue on ppc - 11-28-2006 , 02:44 PM



--/Uq4LBwYP4y1W6pO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hello Warren

On Mon, Nov 27, 2006 at 04:58:49PM -0700, Warren Young wrote:
Quote:
Unfortunately, that will change the ABI of the library, which would
force this change to wait for v3.0.
True, didn't consider that.

Quote:
Instead, why not just make the required signedness explicit? Then the
library interface stays the same, so I can apply it immediately.
See attached patch.

Greets,
Michael

--
Gentoo Linux developer, http://hansmi.ch/, http://forkbomb.ch/

--/Uq4LBwYP4y1W6pO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="mysql++-signed-char-fix-try2.diff"

diff -ru mysql++-2.1.1.orig/lib/qparms.h mysql++-2.1.1/lib/qparms.h
--- mysql++-2.1.1.orig/lib/qparms.h 2006-04-05 06:44:49.000000000 +0200
+++ mysql++-2.1.1/lib/qparms.h 2006-11-28 21:40:36.000000000 +0100
@@ -232,7 +232,7 @@
/// \param b the 'before' value
/// \param o the 'option' value
/// \param n the 'num' value
- SQLParseElement(std::string b, char o, char n) :
+ SQLParseElement(std::string b, char o, signed char n) :
before(b),
option(o),
num(n)
@@ -241,7 +241,7 @@

std::string before; ///< string inserted before the parameter
char option; ///< the parameter option, or blank if none
- char num; ///< the parameter position to use
+ signed char num; ///< the parameter position to use
};

} // end namespace mysqlpp
diff -ru mysql++-2.1.1.orig/lib/query.cpp mysql++-2.1.1/lib/query.cpp
--- mysql++-2.1.1.orig/lib/query.cpp 2006-04-05 06:44:49.000000000 +0200
+++ mysql++-2.1.1/lib/query.cpp 2006-11-28 21:40:52.000000000 +0100
@@ -185,7 +185,7 @@
else {
num[1] = 0;
}
- short int n = atoi(num);
+ signed char n = atoi(num);

// Look for option character following position value.
char option = ' ';
@@ -220,7 +220,7 @@
}

// Finished parsing parameter; save it.
- parse_elems_.push_back(SQLParseElement(str, option, char(n)));
+ parse_elems_.push_back(SQLParseElement(str, option, n));
str = "";
name = "";
}
@@ -304,7 +304,7 @@
{
sbuffer_.str("");

- char num;
+ signed char num;
SQLString* ss;
SQLQueryParms* c;



--/Uq4LBwYP4y1W6pO
Content-Type: text/plain; charset=us-ascii


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw
--/Uq4LBwYP4y1W6pO--


Reply With Quote
  #5  
Old   
Warren Young
 
Posts: n/a

Default Re: Patch to fix char signedness issue on ppc - 12-20-2006 , 12:36 PM



Michael Hanselmann wrote:
Quote:
Instead, why not just make the required signedness explicit? Then the
library interface stays the same, so I can apply it immediately.

See attached patch.
I finally got around to applying this. It'll appear in the next version
of the library. Thanks!

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.