NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Patch for Linux PPC


Joined: 31 Oct 2004
Posts: 3
Reply with quote
I post a patch for Linux PPC :
There is a bug in main() which cause an infinite loop since C type 'char' is unsigned on PPC.
Second is a bad use of va_start/va_end in std_sprintf() which crash on PPC.

Here is the patch (cannot post attachments ?):
Code:
diff -ru dbg_client-2.11.30/dbg/main.cpp dbg_client-2.11.30.jc/dbg/main.cpp
--- dbg_client-2.11.30/dbg/main.cpp     2004-09-07 14:01:58.000000000 +0200
+++ dbg_client-2.11.30.jc/dbg/main.cpp  2004-10-31 15:45:50.000000000 +0100
@@ -91,7 +91,7 @@
                char c;

                c = getopt_long_only (argc, argv, "", long_options, &option_index);
-               if (c == EOF) break;
+               if (c == (char)EOF) break;

                if (c == 0 && long_options[option_index].flag == 0) {
                        c = long_options[option_index].val;
diff -ru dbg_client-2.11.30/dbgbase/dbgbase_globals.cpp dbg_client-2.11.30.jc/dbgbase/dbgbase_globals.cpp
--- dbg_client-2.11.30/dbgbase/dbgbase_globals.cpp      2004-09-07 14:08:08.000000000 +0200
+++ dbg_client-2.11.30.jc/dbgbase/dbgbase_globals.cpp   2004-10-31 15:45:38.000000000 +0100
@@ -145,10 +145,11 @@
        int sz, ret_val, i;
        char *cbuf = NULL;

-       va_start(args, format);
        for (sz=512, i=0; i < 16; i++, sz=sz*2) {
                cbuf = new char[sz];
+               va_start(args, format);
                ret_val = vsnprintf(cbuf, sz, format, args);
+               va_end(args);
                if (ret_val >= 0 && ret_val < sz) break;
                delete cbuf;
                cbuf = NULL;
@@ -159,7 +160,6 @@
        } else {
                buf = "";
        }
-       va_end(args);
        return buf.length();
 }


Last edited by djiss on Sun Oct 31, 2004 10:25 am; edited 1 time in total
View user's profileFind all posts by djissSend private message


Joined: 31 Oct 2004
Posts: 3
Reply with quote
Oops i forgot ot tell that this patch is for dbg_cli...
View user's profileFind all posts by djissSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8342
Reply with quote
Thanks!
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Patch for Linux PPC
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic