All of lore.kernel.org
 help / color / mirror / Atom feed
* Bug/Oversight in gatchat/gatresult.c with negative numbers
@ 2021-07-20 16:11 Alex J Lennon
  2021-07-27 14:38 ` Denis Kenzior
  0 siblings, 1 reply; 14+ messages in thread
From: Alex J Lennon @ 2021-07-20 16:11 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1398 bytes --]

Hi all,

I'm doing a bit of work with Ofono again, extending support for a 
Quectel EG91 - handling additional cell strength information which seems 
necessary for LTE.

I'm using Quectel's AT+QCOPS which is returning some negative signal 
strengths and after some investigation I've spotted that 
gatresult::g_at_result_iter_next_number() doesn't handle negative numbers.

No doubt there's a better solution than mine, but this does appear to work.

Cheers,

Alex

--- ofono-1.22.org/gatchat/gatresult.c  2011-10-11 18:21:45.000000000 +0000
+++ ofono-1.22/gatchat/gatresult.c      2021-07-20 15:50:06.300001000 +0000
@@ -262,6 +262,7 @@
         int end;
         int len;
         int value = 0;
+       int sign = 1;
         char *line;

         if (iter == NULL)
@@ -276,10 +277,16 @@
         pos = iter->line_pos;
         end = pos;

+       if(line[end] == '-') {
+               sign = -1;
+               end += 1;
+       }
+
         while (line[end] >= '0' && line[end] <= '9') {
                 value = value * 10 + (int)(line[end] - '0');
                 end += 1;
         }
+       value = sign * value;

         if (pos == end)
                 return FALSE;

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-08-09  6:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-20 16:11 Bug/Oversight in gatchat/gatresult.c with negative numbers Alex J Lennon
2021-07-27 14:38 ` Denis Kenzior
2021-07-27 15:02   ` Alex J Lennon
2021-08-03  9:48   ` Alex J Lennon
2021-08-03 14:28     ` Denis Kenzior
2021-08-03 14:45       ` Alex J Lennon
2021-08-06  9:31       ` Alex J Lennon
2021-08-06 14:06       ` Alex J Lennon
2021-08-06 14:20         ` Denis Kenzior
2021-08-06 14:28           ` Alex J Lennon
2021-08-06 14:44             ` Denis Kenzior
2021-08-06 14:49               ` Alex J Lennon
2021-08-06 15:02                 ` Denis Kenzior
2021-08-09  6:40                   ` Martin =?unknown-8bit?q?Hundeb=C3=B8ll?=

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.