gnokii-users
[Top][All Lists]
Advanced

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

Check error returns


From: Pavel Machek
Subject: Check error returns
Date: Fri, 26 Apr 2002 19:31:24 +0200
User-agent: Mutt/1.3.28i

Hi!

It is bad not to check error returns... This fixes it for key
pressing. Please try to fix/not introduce similar problems. Commited
to CVS.

                                                                Pavel



? gnokii
Index: gnokii.c
===================================================================
RCS file: /cvsroot/gnokii/gnokii/gnokii/gnokii.c,v
retrieving revision 1.232
diff -u -u -r1.232 gnokii.c
--- gnokii.c    26 Apr 2002 12:03:34 -0000      1.232
+++ gnokii.c    26 Apr 2002 17:30:08 -0000
@@ -3169,6 +3169,15 @@
        return 0;
 }
 
+static void presskey(void)
+{
+       GSM_Error error;
+       error = SM_Functions(GOP_PressPhoneKey, &data, &State);
+       if (error == GE_NONE)
+               error = SM_Functions(GOP_ReleasePhoneKey, &data, &State);
+       fprintf(stdout, "Failed to press key: %d\n", error);
+}
+
 static int presskeysequence(void)
 {
        unsigned char *syms = "0123456789#*PGR+-UDMN";
@@ -3189,9 +3198,7 @@
                        data.KeyCode = keys[pos - syms];
                else
                        continue;
-               
-               SM_Functions(GOP_PressPhoneKey, &data, &State);
-               SM_Functions(GOP_ReleasePhoneKey, &data, &State);
+               presskey();
        }
 
        return 0;
@@ -3200,6 +3207,7 @@
 static int enterchar(void)
 {
        unsigned char ch;
+       GSM_Error error;
 
        GSM_DataClear(&data);
        console_raw();
@@ -3210,17 +3218,17 @@
                        break;
                case '\n':
                        data.KeyCode = GSM_KEY_MENU;
-                       SM_Functions(GOP_PressPhoneKey, &data, &State);
-                       SM_Functions(GOP_ReleasePhoneKey, &data, &State);
+                       presskey();
                        break;
                case '\e':
                        data.KeyCode = GSM_KEY_NAMES;
-                       SM_Functions(GOP_PressPhoneKey, &data, &State);
-                       SM_Functions(GOP_ReleasePhoneKey, &data, &State);
+                       presskey();
                        break;
                default:
                        data.Character = ch;
-                       SM_Functions(GOP_EnterChar, &data, &State);
+                       error = SM_Functions(GOP_EnterChar, &data, &State);
+                       if (error != GE_NONE)
+                               printf("Error entering char: %d\n", error);
                        break;
                }
        }

-- 
(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]