[Olsr-dev] [olsrd] [PATCH v3 1/2] gateway: fix serialize_gw_speed
Henning Rogge
(spam-protected)
Thu Jul 19 10:07:17 CEST 2012
Looks okay.
Henning
On 07/19/2012 09:54 AM, Ferry Huberts wrote:
> From: Ferry Huberts <(spam-protected)>
>
> Values over 320000000 would serialize to 0, which is not correct,
> since they should be clipped to the maximum value of the
> serialization range.
>
> v2: unchanged, sent with another patch
>
> v3: values 100000000 and 200000000 would result in an exponent of 8,
> which is out-of-range for the exponent.
>
> Signed-off-by: Ferry Huberts <(spam-protected)>
> ---
> src/gateway.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/gateway.c b/src/gateway.c
> index 048a7cb..ee122b7 100644
> --- a/src/gateway.c
> +++ b/src/gateway.c
> @@ -62,11 +62,15 @@ static uint8_t
> serialize_gw_speed(uint32_t speed) {
> uint8_t exp = 0;
>
> - if (speed == 0 || speed > 320000000) {
> + if (speed == 0) {
> return 0;
> }
>
> - while (speed > 32 || (speed % 10) == 0) {
> + if (speed > 320000000) {
> + return 0xff;
> + }
> +
> + while ((speed > 32 || (speed % 10) == 0) && exp < 7) {
> speed /= 10;
> exp ++;
> }
>
--
Diplom-Informatiker Henning Rogge , Fraunhofer-Institut für
Kommunikation, Informationsverarbeitung und Ergonomie FKIE
Kommunikationssysteme (KOM)
Neuenahrer Straße 20, 53343 Wachtberg, Germany
Telefon +49 228 9435-961, Fax +49 228 9435 685
mailto:(spam-protected) http://www.fkie.fraunhofer.de
GPG: E1C6 0914 490B 3909 D944 F80D 4487 C67C 55EC CFE0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6169 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.olsr.org/pipermail/olsr-dev/attachments/20120719/8a58212f/attachment.bin>
More information about the Olsr-dev
mailing list