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

Re: [PATCH] Prevent gcc error on isys/eddsupport.c



Alternative fix for this coming to the list.

On 03/30/2009 11:36 AM, David Cantrell wrote:
Getting this on eddsupport.c with latest gcc:
eddsupport.c:171: error: offset ‘3’ outside bounds of constant string

gcc does not like the "." and ".." in strncmp() calls.  Do the same
thing but without calling strncmp() and without declaring temporary
variables.
---
  isys/eddsupport.c |   11 +++++++++--
  1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/isys/eddsupport.c b/isys/eddsupport.c
index ae974c5..67e22c7 100644
--- a/isys/eddsupport.c
+++ b/isys/eddsupport.c
@@ -168,9 +168,16 @@ static int mapBiosDisks(struct device** devices,const char *path) {
      }

      while ((entry = readdir(dirHandle)) != NULL) {
-        if(!strncmp(entry->d_name,".",1) || !strncmp(entry->d_name,"..",2)) {
-            continue;
+        if (strlen(entry->d_name) == 1) {
+            if (entry->d_name[0] == '.') {
+                continue;
+            }
+        } else if (strlen(entry->d_name) == 2) {
+            if (entry->d_name[0] == '.'&&  entry->d_name[1] == '.') {
+                continue;
+            }
          }
+
          ret = sscanf((entry->d_name+9), "%x",&biosNum);

          sigFileName = malloc(strlen(path) + strlen(entry->d_name) + 20);


--
David Cantrell <dcantrell redhat com>
Red Hat / Honolulu, HI


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