osmocom-bb[master]: mobile/gsm322.c: replace memset() by simple for-loop

2017-11-08 Thread Vadim Yanitskiy

Patch Set 2: Code-Review-1

(1 comment)

https://gerrit.osmocom.org/#/c/4645/2/src/host/layer23/src/mobile/gsm322.c
File src/host/layer23/src/mobile/gsm322.c:

Line 326:   for (i = 0; i < value && i < sizeof(bar) - 1; i++)
> you could just as well simply compute the length of the interval as a posit
The main idea of this commit was to avoid a compiler
warning related to possibility of calling memset with
zero length argument, but seems I went a long way ;)

I just found out a bit different way of solving this
issue, so this change will be updated soon.


-- 
To view, visit https://gerrit.osmocom.org/4645
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I2d8d78474614939659a7f24d5007b1c890776b1a
Gerrit-PatchSet: 2
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


osmocom-bb[master]: mobile/gsm322.c: replace memset() by simple for-loop

2017-11-07 Thread Harald Welte

Patch Set 2: Code-Review+2

(1 comment)

https://gerrit.osmocom.org/#/c/4645/2/src/host/layer23/src/mobile/gsm322.c
File src/host/layer23/src/mobile/gsm322.c:

Line 326:   for (i = 0; i < value && i < sizeof(bar) - 1; i++)
you could just as well simply compute the length of the interval as a positive 
integer and then call memset() on that. But hey, we don't need to optimize here.


-- 
To view, visit https://gerrit.osmocom.org/4645
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I2d8d78474614939659a7f24d5007b1c890776b1a
Gerrit-PatchSet: 2
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy 
Gerrit-HasComments: Yes


[PATCH] osmocom-bb[master]: mobile/gsm322.c: replace memset() by simple for-loop

2017-11-05 Thread Vadim Yanitskiy
Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

https://gerrit.osmocom.org/4645

to look at the new patch set (#2).

mobile/gsm322.c: replace memset() by simple for-loop

This change prevents a possible buffer overrun in case of
incorrect min / max values are passed and the compiler
warning about possibility of calling memset() with
constant zero length parameter.

Change-Id: I2d8d78474614939659a7f24d5007b1c890776b1a
---
M src/host/layer23/src/mobile/gsm322.c
1 file changed, 4 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/45/4645/2

diff --git a/src/host/layer23/src/mobile/gsm322.c 
b/src/host/layer23/src/mobile/gsm322.c
index ad6a83b..9fda91e 100644
--- a/src/host/layer23/src/mobile/gsm322.c
+++ b/src/host/layer23/src/mobile/gsm322.c
@@ -313,6 +313,7 @@
 static char *bargraph(int value, int min, int max)
 {
static char bar[128];
+   int i;
 
/* shift value to the range of min..max */
if (value < min)
@@ -322,8 +323,9 @@
else
value -= min;
 
-   memset(bar, '=', value);
-   bar[value] = '\0';
+   for (i = 0; i < value && i < sizeof(bar) - 1; i++)
+   bar[i] = '=';
+   bar[i] = '\0';
 
return bar;
 }

-- 
To view, visit https://gerrit.osmocom.org/4645
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I2d8d78474614939659a7f24d5007b1c890776b1a
Gerrit-PatchSet: 2
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max 
Gerrit-Reviewer: Vadim Yanitskiy