From a6283d7ed2fd7f743a74ab13b26bd373537d4a67 Mon Sep 17 00:00:00 2001
From: Joerg Behrmann <behrmann@physik.fu-berlin.de>
Date: Mon, 30 Jan 2017 16:57:04 +0100
Subject: [PATCH] Fix several compiler warnings.

This patch fixes the reasons for compiler warnings in
 - partitioner (signed unsigned comparison),
 - graph/util (maybe uninitialized),
 - operator (maybe uninitialized).
---
 kwant/graph/c_slicer/partitioner.cc | 2 +-
 kwant/graph/utils.pyx               | 2 +-
 kwant/operator.pyx                  | 5 ++++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/kwant/graph/c_slicer/partitioner.cc b/kwant/graph/c_slicer/partitioner.cc
index 394cb627..ea74bddb 100644
--- a/kwant/graph/c_slicer/partitioner.cc
+++ b/kwant/graph/c_slicer/partitioner.cc
@@ -116,7 +116,7 @@ void Partitioner::bisectFirst(std::vector<int> &_left, std::vector<int> &_right,
   if(slices<2) return;
 
   //Find the maximum number of edges (needed or Fiduccia-Mattheyses)
-  int max_edges=0;
+  size_t max_edges=0;
 
   for(size_t ivertex=0; ivertex < parts[0].size(); ivertex++) {
     if(graph.getEdges(parts[0][ivertex]).size() > max_edges) {
diff --git a/kwant/graph/utils.pyx b/kwant/graph/utils.pyx
index 678424cc..33ffff6f 100644
--- a/kwant/graph/utils.pyx
+++ b/kwant/graph/utils.pyx
@@ -216,7 +216,7 @@ def induced_subgraph(CGraph gr, select,
 
     cdef np.ndarray[gint, ndim=1] indextab
     cdef CGraph_malloc subgr
-    cdef np.ndarray[gint, ndim=1] sub_edge_weights
+    cdef np.ndarray[gint, ndim=1] sub_edge_weights = None
     cdef gint sub_num_nodes, sub_num_edges
     cdef gint i, iedge, edge_count
 
diff --git a/kwant/operator.pyx b/kwant/operator.pyx
index 5e8fbd3d..1dd13493 100644
--- a/kwant/operator.pyx
+++ b/kwant/operator.pyx
@@ -684,7 +684,10 @@ cdef class Density(_LocalOperator):
             data = np.asarray(self.onsite).flatten()
             data = np.resize(data, [len(data) * n_blocks])
         else:
-            onsite_matrix = self._bound_onsite or self._eval_onsites(args)
+            if self._bound_onsite is not None:
+                onsite_matrix = self._bound_onsite
+            else:
+                onsite_matrix = self._eval_onsites(args)
             data = onsite_matrix.data
             offsets = np.asarray(onsite_matrix.block_offsets)
             shapes = np.asarray(onsite_matrix.block_shapes)
-- 
GitLab