[libgit2-glib] examples/clone: avoid possible division by 0
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] examples/clone: avoid possible division by 0
- Date: Fri, 5 Aug 2016 08:44:07 +0000 (UTC)
commit 3071188d04f0eb0c7be40d39349b365b73d3f8f1
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Fri Aug 5 10:43:42 2016 +0200
examples/clone: avoid possible division by 0
examples/clone.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/examples/clone.c b/examples/clone.c
index 337250f..8f6fc87 100644
--- a/examples/clone.c
+++ b/examples/clone.c
@@ -37,8 +37,8 @@ cloner_transfer_progress (GgitRemoteCallbacks *callbacks,
totobjs = ggit_transfer_progress_get_total_objects (stats);
indexobjs = ggit_transfer_progress_get_indexed_objects (stats);
- guint network_percent = recvobjs * 100 / totobjs;
- guint index_percent = indexobjs * 100 / totobjs;
+ guint network_percent = totobjs > 0 ? recvobjs * 100 / totobjs : 0;
+ guint index_percent = totobjs > 0 ? indexobjs * 100 / totobjs : 0;
guint kbytes = ggit_transfer_progress_get_received_bytes (stats) / 1024;
g_printf ("\rnet %3d%% (%4d kb, %5d/%5d) / idx %3d%% (%5d/%5d)",
@@ -151,7 +151,9 @@ cloner_class_init (ClonerClass *klass)
cb_klass->credentials = cloner_credentials;
}
-int main(int argc, char **argv)
+int
+main(int argc,
+ char **argv)
{
GgitRepository *cloned_repo = NULL;
GgitCloneOptions *options = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]