Steven Dake wrote:
> On 06/01/2011 09:14 AM, Jan Friesse wrote:
>> Signed-off-by: Jan Friesse <jfrie...@redhat.com>
>> ---
>>  test/testcpgzc.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/test/testcpgzc.c b/test/testcpgzc.c
>> index 5b496a8..14f621d 100644
>> --- a/test/testcpgzc.c
>> +++ b/test/testcpgzc.c
>> @@ -218,7 +218,7 @@ int main (int argc, char *argv[]) {
>>                      perror ("select\n");
>>              }
>>              if (FD_ISSET (STDIN_FILENO, &read_fds)) {
>> -                    fgets_res = fgets(buffer, sizeof(buffer), stdin);
>> +                    fgets_res = fgets(buffer, 8192, stdin);
>>                      if (fgets_res == NULL) {
>>                              cpg_leave(handle, &group_name);
>>                      }
> 
> Reviewed-by: Steven Dake <sd...@redhat.com>
> 
> If you are feeling adventurous, might get rid of the magic number and
> put it in a define (along with all the other magic numbers in this file).
> 
> Regards
> -steve

Better version of patch included.

>From 7ad085f8d9948d5f8a0bdfe389a53e0f6ba7ca13 Mon Sep 17 00:00:00 2001
From: Jan Friesse <jfrie...@redhat.com>
Date: Mon, 30 May 2011 15:51:45 +0200
Subject: [PATCH] testcpgzc: fgets buffer to really allocated size

Signed-off-by: Jan Friesse <jfrie...@redhat.com>
---
 test/testcpgzc.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/test/testcpgzc.c b/test/testcpgzc.c
index 5b496a8..6b3713b 100644
--- a/test/testcpgzc.c
+++ b/test/testcpgzc.c
@@ -49,6 +49,9 @@
 #include <corosync/corotypes.h>
 #include <corosync/cpg.h>
 
+#define BUFFER_SIZE    8192
+#define DEFAULT_GROUP_NAME     "GROUP"
+
 static int quit = 0;
 static int show_ip = 0;
 
@@ -181,8 +184,8 @@ int main (int argc, char *argv[]) {
                group_name.length = strlen(argv[optind])+1;
        }
        else {
-               strcpy(group_name.value, "GROUP");
-               group_name.length = 6;
+               strcpy(group_name.value, DEFAULT_GROUP_NAME);
+               group_name.length = strlen(DEFAULT_GROUP_NAME) + 1;
        }
 
        result = cpg_initialize (&handle, &callbacks);
@@ -190,9 +193,9 @@ int main (int argc, char *argv[]) {
                printf ("Could not initialize Cluster Process Group API 
instance error %d\n", result);
                exit (1);
        }
-       cpg_zcb_alloc (handle, 8192, &buffer);
+       cpg_zcb_alloc (handle, BUFFER_SIZE, &buffer);
        cpg_zcb_free (handle, buffer);
-       cpg_zcb_alloc (handle, 8192, &buffer);
+       cpg_zcb_alloc (handle, BUFFER_SIZE, &buffer);
 
        result = cpg_local_get (handle, &nodeid);
        if (result != CS_OK) {
@@ -218,7 +221,7 @@ int main (int argc, char *argv[]) {
                        perror ("select\n");
                }
                if (FD_ISSET (STDIN_FILENO, &read_fds)) {
-                       fgets_res = fgets(buffer, sizeof(buffer), stdin);
+                       fgets_res = fgets(buffer, BUFFER_SIZE, stdin);
                        if (fgets_res == NULL) {
                                cpg_leave(handle, &group_name);
                        }
-- 
1.7.1

_______________________________________________
Openais mailing list
Openais@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to