]> Cypherpunks repositories - gostls13.git/commitdiff
lib9: fix inconsistencies and warnings on Plan 9
authorDavid du Colombier <0intro@gmail.com>
Thu, 13 Feb 2014 19:05:55 +0000 (20:05 +0100)
committerDavid du Colombier <0intro@gmail.com>
Thu, 13 Feb 2014 19:05:55 +0000 (20:05 +0100)
warning: src/lib9/fmt/dorfmt.c:64 unreachable code RETURN
warning: src/lib9/fmt/fltfmt.c:184 set and not used: p
warning: src/lib9/utf/utflen.c:35 unreachable code RETURN
warning: src/lib9/utf/utfrrune.c:45 unreachable code RETURN
warning: src/lib9/utf/utfrune.c:44 unreachable code RETURN

LGTM=rsc
R=rsc, iant, gobot
CC=golang-codereviews
https://golang.org/cl/57170052

src/lib9/errstr.c
src/lib9/fmt/dorfmt.c
src/lib9/fmt/errfmt.c [new file with mode: 0644]
src/lib9/fmt/fltfmt.c
src/lib9/fmt/fmtfd.c
src/lib9/utf/utfecpy.c
src/lib9/utf/utflen.c
src/lib9/utf/utfrrune.c
src/lib9/utf/utfrune.c
src/lib9/utf/utfutf.c

index f42f2b5384a2d5e5032bc85aadadf9989e35cc28..9d919755d183b1831e6ad3172f0eb30064789647 100644 (file)
@@ -1,3 +1,5 @@
+// +build !plan9
+
 /*
 Plan 9 from User Space src/lib9/errstr.c
 http://code.swtch.com/plan9port/src/tip/src/lib9/errstr.c
@@ -32,7 +34,6 @@ THE SOFTWARE.
 
 #include <u.h>
 #include <errno.h>
-#include <string.h>
 #include <libc.h>
 
 enum
index c18d9ee5db64417359af809260e9637c4cc6ed8f..f760d47e5e85948812dda0145fb320c727e9c899 100644 (file)
@@ -61,5 +61,4 @@ dorfmt(Fmt *f, const Rune *fmt)
                if(fmt == nil)
                        return -1;
        }
-       return 0;               /* not reached */
 }
diff --git a/src/lib9/fmt/errfmt.c b/src/lib9/fmt/errfmt.c
new file mode 100644 (file)
index 0000000..a867093
--- /dev/null
@@ -0,0 +1,32 @@
+// +build plan9
+
+/*
+ * The authors of this software are Rob Pike and Ken Thompson,
+ * with contributions from Mike Burrows and Sean Dorward.
+ *
+ *     Copyright (c) 2002-2006 by Lucent Technologies.
+ *     Portions Copyright (c) 2004 Google Inc.
+ * 
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose without fee is hereby granted, provided that this entire notice
+ * is included in all copies of any software which is or includes a copy
+ * or modification of this software and in all copies of the supporting
+ * documentation for such software.
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES 
+ * NOR GOOGLE INC MAKE ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING 
+ * THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+ */
+
+#include <u.h>
+#include <libc.h>
+#include "fmtdef.h"
+
+int
+__errfmt(Fmt *f)
+{
+       char buf[ERRMAX];
+
+       rerrstr(buf, sizeof buf);
+       return __fmtcpy(f, buf, utflen(buf), strlen(buf));
+}
index dec6f8480c0e98d817309c9fd5a855f04687cf4a..6fe8192211412c0b52c04553e0f536e516990b41 100644 (file)
@@ -154,6 +154,7 @@ xsub1(char *a, int n)
         * so that it has a nonzero first digit.
         */
        abort();
+       return 0;
 }
 
 /*
@@ -180,7 +181,7 @@ xfmtexp(char *p, int e, int ucase)
                se[i++] = '0';
        while(i > 0)
                *p++ = se[--i];
-       *p++ = '\0';
+       *p = '\0';
 }
 
 /*
@@ -192,7 +193,8 @@ xfmtexp(char *p, int e, int ucase)
 static void
 xdtoa(double f, char *s, int *exp, int *neg, int *ns)
 {
-       int d, e2, e, ee, i, ndigit, oerrno;
+       int d, e2, e, ee, i, ndigit;
+       int oerrno;
        char c;
        char tmp[NSIGNIF+10];
        double g;
index c32abf1154b548e61d3981eaf821d20b19cee4fa..dde05b7a5e0364ceac229af6e48478e7da28b0bc 100644 (file)
@@ -43,7 +43,7 @@ fmtfdinit(Fmt *f, int fd, char *buf, int size)
        f->to = buf;
        f->stop = buf + size;
        f->flush = __fmtFdFlush;
-       f->farg = (void*)(uintptr_t)fd;
+       f->farg = (void*)(uintptr)fd;
        f->flags = 0;
        f->nfmt = 0;
        fmtlocaleinit(f, nil, nil, nil);
index 2eca85ef66d753106c5ab1843b7cd1e2a88d83a2..85406646080944e15188a2f025f35903539c1266 100644 (file)
@@ -11,8 +11,8 @@
  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
  * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  */
-#define _BSD_SOURCE 1
-#include <string.h>
+#include <u.h>
+#include <libc.h>
 #include "utf.h"
 #include "utfdef.h"
 
index 42fcb33abfe05c12189c5acc698aacd95af69172..9b961856a5832f5c2f307c21fc52a8c13058d38c 100644 (file)
@@ -32,5 +32,4 @@ utflen(const char *s)
                        s += chartorune(&rune, s);
                n++;
        }
-       return 0;
 }
index 9e28af82a5c59ea005a101cdb00e76668f3d6e6b..b1ea93b423234bfb79a35749102f23b0d5306c5c 100644 (file)
@@ -11,7 +11,8 @@
  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
  * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  */
-#include <string.h>
+#include <u.h>
+#include <libc.h>
 #include "utf.h"
 #include "utfdef.h"
 
@@ -42,5 +43,4 @@ utfrrune(const char *s, Rune c)
                        s1 = s;
                s += c1;
        }
-       return 0;
 }
index 0136b282133228fb8eac47229fb0c7781daa5271..44675c98920495f7586ce83a65e1bee7707f1046 100644 (file)
@@ -11,7 +11,8 @@
  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
  * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  */
-#include <string.h>
+#include <u.h>
+#include <libc.h>
 #include "utf.h"
 #include "utfdef.h"
 
@@ -41,5 +42,4 @@ utfrune(const char *s, Rune c)
                        return (char*)s;
                s += n;
        }
-       return 0;
 }
index e46ddd923357777301dd26bf47a848032e306dc2..05335b23e8b2e224c3793c7cc573e52581467301 100644 (file)
@@ -11,7 +11,8 @@
  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
  * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  */
-#include <string.h>
+#include <u.h>
+#include <libc.h>
 #include "utf.h"
 #include "utfdef.h"