This is an archive of the discontinued Mercurial Phabricator instance.

cext: fix compiler warning about sign changing
ClosedPublic

Authored by spectral on Jan 16 2020, 3:39 PM.

Details

Summary

line.len is a Py_ssize_t, and we're casing to size_t (unsigned). On my compiler,
this causes a warning to be emitted:

mercurial/cext/manifest.c: In function 'pathlen':
mercurial/cext/manifest.c:48:44: warning: operand of ?: changes signedness from 'Py_ssize_t' {aka 'long int'} to 'long unsigned int' due to unsignedness of other operand [-Wsign-compare]
  return (end) ? (size_t)(end - l->start) : l->len;
                                            ^~~~~~

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

spectral created this revision.Jan 16 2020, 3:39 PM
mharbison72 accepted this revision.Jan 16 2020, 8:03 PM
mharbison72 added a subscriber: mharbison72.

LGTM

yuja added a subscriber: yuja.Jan 17 2020, 7:14 AM

static PyObject *hashflags(line *l)
{

	char *s = l->start;
  • size_t plen = pathlen(l);

+ Py_ssize_t plen = pathlen(l);

We'll probably want to change hplen to Py_ssize_t as well.

This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.