{"thread":{"id":"6371","subject":"[PATCH 1/2] Avoid a floating point exception in merge-recursive.","startedAt":"2007-01-14T08:11:23Z","lastAt":"2007-01-14T08:11:23Z","messageCount":1,"participants":["Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"31678","messageId":"20070114081123.GA19566@spearce.org","threadId":"6371","inReplyTo":null,"subject":"[PATCH 1/2] Avoid a floating point exception in merge-recursive.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-01-14T08:11:23Z","receivedAt":"2007-01-14T08:11:23Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"If we have no files selected for processing yet but we try to\nproduce a status output this would cause a division by zero error\nwhen computing the percent done.  Last time I talked to a user,\ncrashing a program over performing an undefined operation isn't\nvery nice.  So instead lets set the percentage done to 0.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n This is on top of the merge-recursive series I just sent.\n You may already have it fixed in your tree, or maybe not.\n\n merge-recursive.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex c4e21bc..2a89461 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -182,7 +182,7 @@ static void setup_progress_signal(void)\n \n static void display_progress()\n {\n-\tunsigned percent = merged_cnt * 100 / total_cnt;\n+\tunsigned percent = total_cnt ? merged_cnt * 100 / total_cnt : 0;\n \tif (progress_update || percent != last_percent) {\n \t\tfprintf(stderr, \"%4u%% (%u/%u) done\\r\",\n \t\t\tpercent, merged_cnt, total_cnt);\n-- \n1.5.0.rc1.g4494\n"}]}