gnokii-commit
[Top][All Lists]
Advanced

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

[SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-51


From: Daniele Forsi
Subject: [SCM] libgnokii and core programs branch, master, updated. rel_0_6_29-515-gcc0992d
Date: Mon, 29 Apr 2013 11:53:24 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "libgnokii and core programs".

The branch, master has been updated
       via  cc0992d7b3e0408521c5fa77923961bf5a01f5e5 (commit)
      from  83d5217a612c4b152731bb91a02067e6cc32bf77 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii.git/commit/?id=cc0992d7b3e0408521c5fa77923961bf5a01f5e5


commit cc0992d7b3e0408521c5fa77923961bf5a01f5e5
Author: Daniele Forsi <address@hidden>
Date:   Mon Apr 29 13:49:12 2013 +0200

    Refactor code. No functional changes
    
    Just an if-else is needed to check the return value from fread()
    because it is a size_t.

diff --git a/gnokii/gnokii-utils.c b/gnokii/gnokii-utils.c
index 3516ea3..7637af0 100644
--- a/gnokii/gnokii-utils.c
+++ b/gnokii/gnokii-utils.c
@@ -117,7 +117,7 @@ gn_error readtext(gn_sms_user_data *udata)
        /* The maximum length of an uncompressed concatenated short message is
           255 * 153 = 39015 default alphabet characters */
        char message_buffer[255 * GN_SMS_MAX_LENGTH];
-       int chars_read;
+       size_t chars_read;
 
 #ifndef        WIN32
        if (isatty(0))
@@ -126,16 +126,18 @@ gn_error readtext(gn_sms_user_data *udata)
 
        /* Get message text from stdin. */
        chars_read = fread(message_buffer, 1, sizeof(message_buffer), stdin);
-       if (chars_read == 0 && ferror(stdin)) {
-               fprintf(stderr, _("Couldn't read from stdin!\n"));
-               return GN_ERR_FAILED;
-       }
-       if (udata->type != GN_SMS_DATA_iMelody && chars_read > 0 && 
message_buffer[chars_read - 1] == '\n')
-               message_buffer[--chars_read] = 0;
-       if (chars_read > (sizeof(udata->u.text) - 1)) {
-               fprintf(stderr, _("Input too long! (%d, maximum is %d)\n"), 
chars_read, (int)(sizeof(udata->u.text) - 1));
-               return GN_ERR_ENTRYTOOLONG;
+       if (chars_read == 0) {
+               if (ferror(stdin)) {
+                       fprintf(stderr, _("Couldn't read from stdin!\n"));
+                       return GN_ERR_FAILED;
+               }
        } else {
+               if (udata->type != GN_SMS_DATA_iMelody && 
message_buffer[chars_read - 1] == '\n')
+                       chars_read--;
+               if (chars_read > (sizeof(udata->u.text) - 1)) {
+                       fprintf(stderr, _("Input too long! (%d, maximum is 
%d)\n"), chars_read, (int)(sizeof(udata->u.text) - 1));
+                       return GN_ERR_ENTRYTOOLONG;
+               }
                message_buffer[chars_read] = '\0';
        }
 

-----------------------------------------------------------------------

Summary of changes:
 gnokii/gnokii-utils.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
libgnokii and core programs



reply via email to

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