[Pdbg] [PATCH 3/4] progress: Add assert to avoid programming errors
Amitay Isaacs
amitay at ozlabs.org
Thu Aug 2 14:35:06 AEST 2018
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
src/progress.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/progress.c b/src/progress.c
index 8aef486..648596d 100644
--- a/src/progress.c
+++ b/src/progress.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <assert.h>
#include "progress.h"
@@ -33,6 +34,8 @@ static void progress_bar(unsigned int percent)
{
unsigned int i, progress;
+ assert(percent <= 100);
+
progress = (percent * PROGRESS_CHARS) / 101;
fprintf(stderr, "\r[");
--
2.17.1
More information about the Pdbg
mailing list