This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problem in cyg_io_compare?


Does this patch look out of place?

Without it, setting *ptr to n1 is just going to leave *ptr hanging off
the end of the 'real' n1, according to my reading of the code.  This
fix seems to make things work for me (i.e. the name parameter to my
device's lookup function actually contains something valid).

Index: iosys.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/common/current/src/iosys.c,v
retrieving revision 1.7
diff -u -r1.7 iosys.c
--- iosys.c     23 May 2002 23:05:59 -0000      1.7
+++ iosys.c     28 Jul 2003 13:00:57 -0000
@@ -68,22 +68,25 @@
 static bool
 cyg_io_compare(const char *n1, const char *n2, const char **ptr)
 {
-    while (*n1 && *n2) {
-        if (*n1++ != *n2++) {
+    char *tmp;
+    tmp = n1;
+    while (*tmp && *n2) {
+        if (*(tmp++) != *(n2++)) {
             return false;
         }
     }
-    if (*n1) {
+    if (*tmp) {
         // See if the devtab name is is a substring
-        if (*(n2-1) == '/') {
+        if (*(n2 - 1) == '/') {
             *ptr = n1;
             return true;
         }
     }
-    if (*n1 || *n2) {
+    if (*tmp || *n2) {
         return false;
     }
     *ptr = n1;
     return true;
 }
 

Thankyou,
-- 
David N. Welton
   Consulting: http://www.dedasys.com/
     Personal: http://www.dedasys.com/davidw/
Free Software: http://www.dedasys.com/freesoftware/
   Apache Tcl: http://tcl.apache.org/

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]