Patchwork [2,of,5] statfs: simplify handling of return value

login
register
mail settings
Submitter Yuya Nishihara
Date March 25, 2017, 10:38 a.m.
Message ID <ca3ea70b04791670fa70.1490438328@mimosa>
Download mbox | patch
Permalink /patch/19662/
State Accepted
Headers show

Comments

Yuya Nishihara - March 25, 2017, 10:38 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1490429592 -32400
#      Sat Mar 25 17:13:12 2017 +0900
# Node ID ca3ea70b04791670fa70eabc2531629b4d82d7a2
# Parent  32202fca1b0a8f3dd4debb9b35daff002c454f75
statfs: simplify handling of return value

Py_BuildValue() can translate NULL pointer to None.

Patch

diff --git a/mercurial/osutil.c b/mercurial/osutil.c
--- a/mercurial/osutil.c
+++ b/mercurial/osutil.c
@@ -1088,12 +1088,7 @@  static PyObject *pygetfstype(PyObject *s
 		return NULL;
 
 	memset(&buf, 0, sizeof(buf));
-	const char *type = getfstype(path, &buf);
-	if (type == NULL)
-		Py_RETURN_NONE;
-
-	PyObject *result = Py_BuildValue("s", type);
-	return result;
+	return Py_BuildValue("s", getfstype(path, &buf));
 }
 #endif /* defined(HAVE_LINUX_STATFS) || defined(HAVE_BSD_STATFS) */