classification
Title: Cure signedness warnings introduced by #22003
Type: compile error Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, dw, meador.inge, pitrou, zach.ware
Priority: normal Keywords: patch

Created on 2014-08-02 22:11 by dw, last changed 2016-07-13 12:18 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
cow-sign.patch dw, 2014-08-02 22:11 cow-sign.patch v1 against hg 5b95f3fdcc0b review
Messages (4)
msg224593 - (view) Author: David Wilson (dw) * Date: 2014-08-02 22:11
The attached patch (hopefully) silences the signedness warnings generated by Visual Studio and reported on python-dev in <https://mail.python.org/pipermail/python-dev/2014-July/135603.html>. 

This was sloppiness on my part, I even noted the problem in the original ticket and never fixed it. :)

I don't have a local dev environment setup for MSVC and Python, but at least the attached patch cures the signedness errors on Clang. They don't seem to occur at all with GCC on my Mac.

The added casts ensure comparisons uniformly compare in the unsigned domain. It seems "size_t buf_size" is pretty redundant in the original struct, it just introduces lots of casting when it only appears to be required during write_bytes() to avoid signed overflow (undefined behaviour)
msg224601 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2014-08-03 00:42
Hmmmm, maybe I am missing some context, but why not avoid the casting and do?

diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c
--- a/Modules/_io/bytesio.c
+++ b/Modules/_io/bytesio.c
@@ -47,7 +47,7 @@ typedef struct {
  * exception and returns -1 on failure. Existing state is preserved on failure.
  */
 static int
-unshare(bytesio *self, size_t preferred_size, int truncate)
+unshare(bytesio *self, Py_ssize_t preferred_size, int truncate)
 {
     if (self->initvalue) {
         Py_ssize_t copy_size;
msg224742 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2014-08-04 16:31
Either patch makes MSVC happy; Meador's gets points from me for simplicity.
msg270307 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-07-13 12:18
Since 2e29d54843a4 this is no longer needed. Thanks for the patches!
History
Date User Action Args
2016-07-13 12:18:55berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg270307

resolution: out of date
stage: patch review -> resolved
2014-08-04 16:31:32zach.waresetmessages: + msg224742
2014-08-03 00:42:12meador.ingesetnosy: + meador.inge

messages: + msg224601
stage: patch review
2014-08-02 22:11:52dwcreate