gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Good bits from Marcin's patch3


From: Pavel Machek
Subject: Good bits from Marcin's patch3
Date: Wed, 3 Apr 2002 11:55:59 +0200
User-agent: Mutt/1.3.27i

Hi!

These seem to be good bits ("should not hurt non-windoze") from
Marcin's patch... Okay to commit?

[What is semantics of snprintf? Is it possible that result is not
0-terminated after snprintf?
                                                        Pavel

Index: common/devices/winserial.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/devices/winserial.c,v
retrieving revision 1.4
diff -u -u -r1.4 winserial.c
--- common/devices/winserial.c  29 Mar 2002 20:51:22 -0000      1.4
+++ common/devices/winserial.c  3 Apr 2002 09:50:12 -0000
@@ -33,6 +33,7 @@
 #include <memory.h>
 
 #include "misc.h"
+#include "compat.h"
 #include "gsm-error.h"
 
 #define USECOMM      /* yes, we need the COMM API */
Index: common/phones/nk6510.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/phones/nk6510.c,v
retrieving revision 1.6
diff -u -u -r1.6 nk6510.c
--- common/phones/nk6510.c      2 Apr 2002 14:31:13 -0000       1.6
+++ common/phones/nk6510.c      3 Apr 2002 09:50:30 -0000
@@ -435,6 +435,7 @@
 
                        n = s ? s - message - 26 : GSM_MAX_MODEL_LENGTH;
                        snprintf(data->Model, GNOKII_MIN(n, 
GSM_MAX_MODEL_LENGTH), "%s", message + 27);
+                       data->Model[GNOKII_MIN(n, GSM_MAX_MODEL_LENGTH)-1]=0;
                        dprintf("Received model %s\n",data->Model);
                }
                if (data->Revision) {
@@ -443,6 +444,7 @@
 
                        n = s ? s - message - 9 : GSM_MAX_REVISION_LENGTH;
                        snprintf(data->Revision, GNOKII_MIN(n, 
GSM_MAX_REVISION_LENGTH), "%s", message + 10);
+                       data->Revision[GNOKII_MIN(n, 
GSM_MAX_REVISION_LENGTH)-1]=0;
                        dprintf("Received revision %s\n",data->Revision);
                }
                break;
Index: common/phones/nk7110.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/common/phones/nk7110.c,v
retrieving revision 1.69
diff -u -u -r1.69 nk7110.c
--- common/phones/nk7110.c      2 Apr 2002 14:37:05 -0000       1.69
+++ common/phones/nk7110.c      3 Apr 2002 09:50:50 -0000
@@ -708,6 +708,7 @@
 
                        n = s ? s - message - 21 : GSM_MAX_MODEL_LENGTH;
                        snprintf(data->Model, GNOKII_MIN(n, 
GSM_MAX_MODEL_LENGTH), "%s", message + 22);
+                       data->Model[GNOKII_MIN(n, GSM_MAX_MODEL_LENGTH)-1]=0;
                        dprintf("Received model %s\n",data->Model);
                }
                if (data->Revision) {
@@ -716,6 +717,7 @@
 
                        n = s ? s - message - 6 : GSM_MAX_REVISION_LENGTH;
                        snprintf(data->Revision, GNOKII_MIN(n, 
GSM_MAX_REVISION_LENGTH), "%s", message + 7);
+                       data->Revision[GNOKII_MIN(n, 
GSM_MAX_REVISION_LENGTH)-1]=0;
                        dprintf("Received revision %s\n",data->Revision);
                }
                break;
Index: include/compat.h
===================================================================
RCS file: /cvsroot/gnokii/gnokii/include/compat.h,v
retrieving revision 1.6
diff -u -u -r1.6 compat.h
--- include/compat.h    3 Apr 2002 01:03:58 -0000       1.6
+++ include/compat.h    3 Apr 2002 09:50:53 -0000
@@ -50,11 +50,13 @@
 /* Convenience macros for operations on timevals.
    NOTE: `timercmp' does not work for >= or <=.  */
 # define timerisset(tvp)       ((tvp)->tv_sec || (tvp)->tv_usec)
-# define timerclear(tvp)       ((tvp)->tv_sec = (tvp)->tv_usec = 0)
-# define timercmp(a, b, CMP)                                                 \
-  (((a)->tv_sec == (b)->tv_sec) ?                                            \
-   ((a)->tv_usec CMP (b)->tv_usec) :                                         \
-   ((a)->tv_sec CMP (b)->tv_sec))
+#ifndef WIN32
+#  define timerclear(tvp)      ((tvp)->tv_sec = (tvp)->tv_usec = 0)
+#  define timercmp(a, b, CMP)                                                \
+   (((a)->tv_sec == (b)->tv_sec) ?                                           \
+    ((a)->tv_usec CMP (b)->tv_usec) :                                        \
+    ((a)->tv_sec CMP (b)->tv_sec))
+#endif
 # define timeradd(a, b, result)                                                
      \
   do {                                                                       \
     (result)->tv_sec = (a)->tv_sec + (b)->tv_sec;                            \

-- 
(about SSSCA) "I don't say this lightly.  However, I really think that the U.S.
no longer is classifiable as a democracy, but rather as a plutocracy." --hpa



reply via email to

[Prev in Thread] Current Thread [Next in Thread]