Skip to content

Commit a36d394

Browse files
committed
Fix some compiler warnings and improve compiler compatibility.
1 parent 909339d commit a36d394

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/tree.c

+14-9
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern PyTypeObject TreeIterType;
4343
extern PyTypeObject IndexType;
4444

4545
#if PY_MAJOR_VERSION >= 3
46-
#define Py_TPFLAGS_CHECKTYPES 0 // removed in Py3, needed in Py2
46+
#define Py_TPFLAGS_CHECKTYPES 0 /* removed in Py3, needed in Py2 */
4747
#endif
4848

4949

@@ -184,6 +184,7 @@ treeentry_to_subtree(TreeEntry* self)
184184
{
185185
Repository *py_repo;
186186
git_tree *subtree = NULL;
187+
int err;
187188

188189
if (git_tree_entry_type(self->entry) != GIT_OBJ_TREE) {
189190
PyErr_SetString(PyExc_TypeError, "Only for trees");
@@ -196,7 +197,7 @@ treeentry_to_subtree(TreeEntry* self)
196197
}
197198

198199
py_repo = self->repo;
199-
int err = git_tree_lookup(&subtree, py_repo->repo, git_tree_entry_id(self->entry));
200+
err = git_tree_lookup(&subtree, py_repo->repo, git_tree_entry_id(self->entry));
200201
if (err < 0) {
201202
Error_set(err);
202203
return NULL;
@@ -210,14 +211,15 @@ treeentry_to_object(TreeEntry* self)
210211
{
211212
Repository *py_repo;
212213
git_object *obj= NULL;
214+
int err;
213215

214216
if (self->repo == NULL) {
215217
PyErr_SetString(PyExc_ValueError, "No repository associated with this TreeEntry");
216218
return NULL;
217219
}
218220
py_repo = self->repo;
219221

220-
int err = git_tree_entry_to_object(&obj, py_repo->repo, self->entry);
222+
err = git_tree_entry_to_object(&obj, py_repo->repo, self->entry);
221223
if (err < 0) {
222224
Error_set(err);
223225
return NULL;
@@ -230,8 +232,9 @@ PyDoc_STRVAR(TreeEntry_obj__doc__, "Object (subtree/blob)");
230232
PyObject *
231233
TreeEntry_obj__get__(TreeEntry *self)
232234
{
235+
git_tree* subtree;
233236
if (git_tree_entry_type(self->entry) == GIT_OBJ_TREE) {
234-
git_tree* subtree = treeentry_to_subtree(self);
237+
subtree = treeentry_to_subtree(self);
235238
if (subtree == NULL)
236239
return NULL;
237240

@@ -339,8 +342,9 @@ PyMappingMethods TreeEntry_as_mapping = {
339342
0, /* mp_ass_subscript */
340343
};
341344

342-
// Py2/3 compatible structure
343-
// see https://py3c.readthedocs.io/en/latest/ext-types.html#pynumbermethods
345+
/* Py2/3 compatible structure
346+
* see https://py3c.readthedocs.io/en/latest/ext-types.html#pynumbermethods
347+
*/
344348
PyNumberMethods TreeEntry_as_number = {
345349
0, /* nb_add */
346350
0, /* nb_subtract */
@@ -479,7 +483,7 @@ wrap_tree_entry(const git_tree_entry *entry, Repository *repo)
479483
if (py_entry)
480484
{
481485
py_entry->entry = entry;
482-
py_entry->repo = repo; // can be NULL
486+
py_entry->repo = repo; /* can be NULL */
483487
Py_XINCREF(repo);
484488
}
485489

@@ -790,8 +794,9 @@ PyMethodDef Tree_methods[] = {
790794
{NULL}
791795
};
792796

793-
// Py2/3 compatible structure
794-
// see https://py3c.readthedocs.io/en/latest/ext-types.html#pynumbermethods
797+
/* Py2/3 compatible structure
798+
* see https://py3c.readthedocs.io/en/latest/ext-types.html#pynumbermethods
799+
*/
795800
PyNumberMethods Tree_as_number = {
796801
0, /* nb_add */
797802
0, /* nb_subtract */

src/treebuilder.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ TreeBuilder_get(TreeBuilder *self, PyObject *py_filename)
124124
PyErr_SetNone(PyExc_MemoryError);
125125
return NULL;
126126
}
127-
return (PyObject*)wrap_tree_entry(entry, Py_None);
127+
return (PyObject*)wrap_tree_entry(entry, NULL);
128128
}
129129

130130

0 commit comments

Comments
 (0)