--- a/mercurial/cext/charencode.c Thu Jan 24 11:35:40 2019 -0500
+++ b/mercurial/cext/charencode.c Thu Jan 24 10:21:59 2019 -0500
@@ -114,8 +114,9 @@
ret = PyBytes_FromStringAndSize(NULL, len / 2);
- if (!ret)
+ if (!ret) {
return NULL;
+ }
d = PyBytes_AsString(ret);
@@ -133,21 +134,24 @@
const char *buf;
Py_ssize_t i, len;
if (!PyArg_ParseTuple(args, PY23("s#:isasciistr", "y#:isasciistr"),
- &buf, &len))
+ &buf, &len)) {
return NULL;
+ }
i = 0;
/* char array in PyStringObject should be at least 4-byte aligned */
if (((uintptr_t)buf & 3) == 0) {
const uint32_t *p = (const uint32_t *)buf;
for (; i < len / 4; i++) {
- if (p[i] & 0x80808080U)
+ if (p[i] & 0x80808080U) {
Py_RETURN_FALSE;
+ }
}
i *= 4;
}
for (; i < len; i++) {
- if (buf[i] & 0x80)
+ if (buf[i] & 0x80) {
Py_RETURN_FALSE;
+ }
}
Py_RETURN_TRUE;
}
@@ -164,8 +168,9 @@
len = PyBytes_GET_SIZE(str_obj);
newobj = PyBytes_FromStringAndSize(NULL, len);
- if (!newobj)
+ if (!newobj) {
goto quit;
+ }
newstr = PyBytes_AS_STRING(newobj);
@@ -197,16 +202,18 @@
PyObject *asciilower(PyObject *self, PyObject *args)
{
PyObject *str_obj;
- if (!PyArg_ParseTuple(args, "O!:asciilower", &PyBytes_Type, &str_obj))
+ if (!PyArg_ParseTuple(args, "O!:asciilower", &PyBytes_Type, &str_obj)) {
return NULL;
+ }
return _asciitransform(str_obj, lowertable, NULL);
}
PyObject *asciiupper(PyObject *self, PyObject *args)
{
PyObject *str_obj;
- if (!PyArg_ParseTuple(args, "O!:asciiupper", &PyBytes_Type, &str_obj))
+ if (!PyArg_ParseTuple(args, "O!:asciiupper", &PyBytes_Type, &str_obj)) {
return NULL;
+ }
return _asciitransform(str_obj, uppertable, NULL);
}
@@ -222,8 +229,9 @@
if (!PyArg_ParseTuple(args, "O!O!O!:make_file_foldmap", &PyDict_Type,
&dmap, &PyInt_Type, &spec_obj, &PyFunction_Type,
- &normcase_fallback))
+ &normcase_fallback)) {
goto quit;
+ }
spec = (int)PyInt_AS_LONG(spec_obj);
switch (spec) {
@@ -244,8 +252,9 @@
/* Add some more entries to deal with additions outside this
function. */
file_foldmap = _dict_new_presized((PyDict_Size(dmap) / 10) * 11);
- if (file_foldmap == NULL)
+ if (file_foldmap == NULL) {
goto quit;
+ }
while (PyDict_Next(dmap, &pos, &k, &v)) {
if (!dirstate_tuple_check(v)) {
@@ -265,8 +274,9 @@
normcase_fallback, k, NULL);
}
- if (normed == NULL)
+ if (normed == NULL) {
goto quit;
+ }
if (PyDict_SetItem(file_foldmap, normed, k) == -1) {
Py_DECREF(normed);
goto quit;
@@ -377,22 +387,25 @@
Py_ssize_t origlen, esclen;
int paranoid;
if (!PyArg_ParseTuple(args, "O!i:jsonescapeu8fast", &PyBytes_Type,
- &origstr, ¶noid))
+ &origstr, ¶noid)) {
return NULL;
+ }
origbuf = PyBytes_AS_STRING(origstr);
origlen = PyBytes_GET_SIZE(origstr);
esclen = jsonescapelen(origbuf, origlen, paranoid);
- if (esclen < 0)
+ if (esclen < 0) {
return NULL; /* unsupported char found or overflow */
+ }
if (origlen == esclen) {
Py_INCREF(origstr);
return origstr;
}
escstr = PyBytes_FromStringAndSize(NULL, esclen);
- if (!escstr)
+ if (!escstr) {
return NULL;
+ }
encodejsonescape(PyBytes_AS_STRING(escstr), esclen, origbuf, origlen,
paranoid);