diff mbox series

[3/4] progress: Add assert to avoid programming errors

Message ID 20180802043507.28734-4-amitay@ozlabs.org
State Accepted
Headers show
Series Refactoring progress bar code | expand

Commit Message

Amitay Isaacs Aug. 2, 2018, 4:35 a.m. UTC
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 src/progress.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

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[");