[epiphany-extensions] soup-fly: clamp percentage value to [0, 100] range



commit 16623df38568701ad51880486c6cc4bc9aeec152
Author: Xan Lopez <xan gnome org>
Date:   Mon Sep 7 00:41:04 2009 +0300

    soup-fly: clamp percentage value to [0,100] range
    
    To avoid warnings, although I believe this shouldn't be needed in the
    first place...

 extensions/soup-fly/soup-fly.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/extensions/soup-fly/soup-fly.c b/extensions/soup-fly/soup-fly.c
index 53c5ffc..e5d239c 100644
--- a/extensions/soup-fly/soup-fly.c
+++ b/extensions/soup-fly/soup-fly.c
@@ -280,8 +280,9 @@ message_got_chunk_cb (SoupMessage *message, SoupBuffer *chunk, FlyMessageData *d
 
   data->received += chunk->length;
   if (data->content_length && data->received) {
+    gint percentage = CLAMP ((int)(data->received * 100 / data->content_length), 0, 100);
     gtk_list_store_set (GTK_LIST_STORE (priv->model), &data->iter,
-                        COL_PROGRESS, (int)(data->received * 100 / data->content_length),
+                        COL_PROGRESS, percentage,
                         -1);
   }
 }



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