[PATCH 2/2] Get rid of some warnings: -Wunsafe-loop-optimizations

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

 



pulsecore/core-util.c: In function ?pa_hexstr?:
pulsecore/core-util.c:1858: warning: cannot optimize loop, the loop counter may overflow [-Wunsafe-loop-optimizations]

modules/alsa/alsa-mixer.c: In function ?pa_alsa_decibel_fix_dump?:
modules/alsa/alsa-mixer.c:3678: warning: cannot optimize possibly infinite loops [-Wunsafe-loop-optimizations]
modules/alsa/alsa-mixer.c: In function ?pa_alsa_path_set_new?:
modules/alsa/alsa-mixer.c:2640: warning: cannot optimize loop, the loop counter may overflow [-Wunsafe-loop-optimizations]
---
 src/modules/alsa/alsa-mixer.c |   14 +++++++-------
 src/pulsecore/core-util.c     |    2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
index 3eef5f9..a0fa865 100644
--- a/src/modules/alsa/alsa-mixer.c
+++ b/src/modules/alsa/alsa-mixer.c
@@ -2637,7 +2637,7 @@ pa_alsa_path_set *pa_alsa_path_set_new(pa_alsa_mapping *m, pa_alsa_direction_t d
             pa_bool_t duplicate = FALSE;
             char **kn, *fn;
 
-            for (kn = pn; kn != in; kn++)
+            for (kn = pn; kn < in; kn++)
                 if (pa_streq(*kn, *in)) {
                     duplicate = TRUE;
                     break;
@@ -3669,14 +3669,14 @@ void pa_alsa_decibel_fix_dump(pa_alsa_decibel_fix *db_fix) {
 
     if (db_fix->db_values) {
         pa_strbuf *buf;
-        long i;
-        long max_i = db_fix->max_step - db_fix->min_step;
+        unsigned long i, nsteps;
 
-        buf = pa_strbuf_new();
-        pa_strbuf_printf(buf, "[%li]:%0.2f", db_fix->min_step, db_fix->db_values[0] / 100.0);
+        pa_assert(db_fix->min_step <= db_fix->max_step);
+        nsteps = db_fix->max_step - db_fix->min_step + 1;
 
-        for (i = 1; i <= max_i; ++i)
-            pa_strbuf_printf(buf, " [%li]:%0.2f", i + db_fix->min_step, db_fix->db_values[i] / 100.0);
+        buf = pa_strbuf_new();
+        for (i = 0; i < nsteps; ++i)
+            pa_strbuf_printf(buf, "[%li]:%0.2f ", i + db_fix->min_step, db_fix->db_values[i] / 100.0);
 
         db_values = pa_strbuf_tostring_free(buf);
     }
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 8ff9995..cf04191 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -1856,7 +1856,7 @@ char *pa_hexstr(const uint8_t* d, size_t dlength, char *s, size_t slength) {
     pa_assert(s);
     pa_assert(slength > 0);
 
-    while (i < dlength && j+3 <= slength) {
+    while (j+2 < slength && i < dlength) {
         s[j++] = hex[*d >> 4];
         s[j++] = hex[*d & 0xF];
 
-- 
1.7.1




[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux