Hi,

Find by Yang Xichun ([email protected]).
But, I think, we should remove meaningless variable and ambiguous comment.

==== patch =====

Subject: [PATCH] core: Remove meaningless variable and ambiguous comment

Signed-off-by: Zhang Wanming <[email protected]>
---
 src/pulsecore/random.c |   18 ++++--------------
 1 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/src/pulsecore/random.c b/src/pulsecore/random.c
index a87d24e..b5e9257 100644
--- a/src/pulsecore/random.c
+++ b/src/pulsecore/random.c
@@ -37,8 +37,6 @@

 #include "random.h"

-static pa_bool_t has_whined = TRUE;
-
static const char * const devices[] = { "/dev/urandom", "/dev/random", NULL };

 static int random_proper(void *ret_data, size_t length) {
@@ -48,7 +46,7 @@ static int random_proper(void *ret_data, size_t length) {

     return -1;

-#else /* OS_IS_WIN32 */
+#else

     int fd, ret = -1;
     ssize_t r = 0;
@@ -78,19 +76,14 @@ static int random_proper(void *ret_data, size_t length) {
     }

     return ret;
-#endif /* OS_IS_WIN32 */
+#endif
 }

 void pa_random_seed(void) {
     unsigned int seed;

     if (random_proper(&seed, sizeof(unsigned int)) < 0) {
-
-        if (!has_whined) {
- pa_log_warn("Failed to get proper entropy. Falling back to seeding with current time.");
-            has_whined = TRUE;
-        }
-
+ pa_log_warn("Failed to get proper entropy. Falling back to seeding with current time.");
         seed = (unsigned int) time(NULL);
     }

@@ -106,11 +99,8 @@ void pa_random(void *ret_data, size_t length) {
     if (random_proper(ret_data, length) >= 0)
         return;
-
-    if (!has_whined) {
+    else
pa_log_warn("Failed to get proper entropy. Falling back to unsecure pseudo RNG.");
-        has_whined = TRUE;
-    }

     for (p = ret_data, l = length; l > 0; p++, l--)
         *p = (uint8_t) rand();
--
1.7.1


On 12/16/2010 11:31 AM, yang xichuan wrote:
Hi all,

In the file src/pulsecore/random.c

I found that the log information "Failed to get proper entropy. Falling back to seeding with current time." would never be printed.

So I changed  its value.

Here's the patch:

Signed-off-by: xichuan.yang <[email protected]>
---
 src/pulsecore/random.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/pulsecore/random.c b/src/pulsecore/random.c
index a87d24e..3d159bf 100644
--- a/src/pulsecore/random.c
+++ b/src/pulsecore/random.c
@@ -37,7 +37,7 @@

 #include "random.h"

-static pa_bool_t has_whined = TRUE;
+static pa_bool_t has_whined = FALSE;

static const char * const devices[] = { "/dev/urandom", "/dev/random", NULL };

--
1.7.1



Best wishes,
Xichuan Yang
xichuan.yang<[email protected]>




--
Thanks&  best regards,
Wanming Zhang
---
Software Developer
Tieto Device R&D Chengdu, China

>From 56020baee1d08b26515fc173997b0b6a71e2bf8d Mon Sep 17 00:00:00 2001
From: Zhang Wanming <[email protected]>
Date: Thu, 16 Dec 2010 12:57:51 +0800
Subject: [PATCH] core: Remove meaningless variable and ambiguous comment


Signed-off-by: Zhang Wanming <[email protected]>
---
 src/pulsecore/random.c |   18 ++++--------------
 1 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/src/pulsecore/random.c b/src/pulsecore/random.c
index a87d24e..b5e9257 100644
--- a/src/pulsecore/random.c
+++ b/src/pulsecore/random.c
@@ -37,8 +37,6 @@
 
 #include "random.h"
 
-static pa_bool_t has_whined = TRUE;
-
 static const char * const devices[] = { "/dev/urandom", "/dev/random", NULL };
 
 static int random_proper(void *ret_data, size_t length) {
@@ -48,7 +46,7 @@ static int random_proper(void *ret_data, size_t length) {
 
     return -1;
 
-#else /* OS_IS_WIN32 */
+#else
 
     int fd, ret = -1;
     ssize_t r = 0;
@@ -78,19 +76,14 @@ static int random_proper(void *ret_data, size_t length) {
     }
 
     return ret;
-#endif /* OS_IS_WIN32 */
+#endif
 }
 
 void pa_random_seed(void) {
     unsigned int seed;
 
     if (random_proper(&seed, sizeof(unsigned int)) < 0) {
-
-        if (!has_whined) {
-            pa_log_warn("Failed to get proper entropy. Falling back to seeding with current time.");
-            has_whined = TRUE;
-        }
-
+        pa_log_warn("Failed to get proper entropy. Falling back to seeding with current time.");
         seed = (unsigned int) time(NULL);
     }
 
@@ -106,11 +99,8 @@ void pa_random(void *ret_data, size_t length) {
 
     if (random_proper(ret_data, length) >= 0)
         return;
-
-    if (!has_whined) {
+    else
         pa_log_warn("Failed to get proper entropy. Falling back to unsecure pseudo RNG.");
-        has_whined = TRUE;
-    }
 
     for (p = ret_data, l = length; l > 0; p++, l--)
         *p = (uint8_t) rand();
-- 
1.7.1

_______________________________________________
pulseaudio-discuss mailing list
[email protected]
https://tango.0pointer.de/mailman/listinfo/pulseaudio-discuss

Reply via email to