guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: templates: Fix possible division by zero when ren


From: Ludovic Courtès
Subject: branch master updated: templates: Fix possible division by zero when rendering spec table.
Date: Tue, 12 Sep 2023 04:41:31 -0400

This is an automated email from the git hooks/post-receive script.

civodul pushed a commit to branch master
in repository guix-cuirass.

The following commit(s) were added to refs/heads/master by this push:
     new c20ca60  templates: Fix possible division by zero when rendering spec 
table.
c20ca60 is described below

commit c20ca601c221fd47e8cff0683bda16d4f5e60650
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Tue Sep 12 10:40:13 2023 +0200

    templates: Fix possible division by zero when rendering spec table.
    
    Division by zero could happen in the unlikely case of a successful
    evaluation containing zero jobs.
    
    * src/cuirass/templates.scm (specifications-table)[summary->percentage]:
    Check whether TOTAL is zero before dividing.
---
 src/cuirass/templates.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/cuirass/templates.scm b/src/cuirass/templates.scm
index 254d7f2..4a74cdc 100644
--- a/src/cuirass/templates.scm
+++ b/src/cuirass/templates.scm
@@ -285,7 +285,9 @@ system whose names start with " (code "guile-") ":" (br)
   (define (summary->percentage summary)
     (let ((total (evaluation-summary-total summary))
           (succeeded (evaluation-summary-succeeded summary)))
-      (nearest-exact-integer (* 100 (/ succeeded total)))))
+      (if (zero? total)
+          0
+          (nearest-exact-integer (* 100 (/ succeeded total))))))
 
   `((div (@ (class "d-flex flex-row mb-3"))
          (div (@ (class "lead mr-auto"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]