Discussion:
[ast-developers] "clang" fixes for Solaris+Linux ...
Roland Mainz
2013-08-17 14:52:45 UTC
Permalink
Hi!

----

Attached (as "astksh20130814_clang_fixes001.diff.txt") is a patch
which fixes a couple annyoing (understatement... :-) ) of "clang"
build warnings for Solaris+Linux +fixes.

Comments/rants/questions welcome... including feedback if the patch is
changed in some way...

----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
-------------- next part --------------
diff -r -u original/src/cmd/INIT/proto.c build_clang/src/cmd/INIT/proto.c
--- src/cmd/INIT/proto.c 2013-08-13 20:40:05.000000000 +0200
+++ src/cmd/INIT/proto.c 2013-08-17 15:39:30.139082660 +0200
@@ -4646,7 +4646,8 @@
{
if (proto->flags & (1L<<29))
{
- proto->op = strcopy(( proto->op),( "\n%{\n"+ !notice));
+ const char *s = "\n%{\n";
+ proto->op = strcopy(( proto->op),( &s[(int)(!notice)]));
proto->op = strcopy(( proto->op),( "/* : : generated by proto : : */\n"));
proto->op = strcopy(( proto->op),( "%}\n"));
}
diff -r -u original/src/cmd/ksh93/sh/name.c build_clang/src/cmd/ksh93/sh/name.c
--- src/cmd/ksh93/sh/name.c 2013-08-12 16:33:09.000000000 +0200
+++ src/cmd/ksh93/sh/name.c 2013-08-17 15:01:55.047453450 +0200
@@ -1949,7 +1949,8 @@
}
else if((nv_isattr(np, NV_RJUST|NV_ZFILL|NV_LJUST)) && sp)
{
- for(;*sp == ' '|| *sp=='\t';sp++);
+ for(;*sp == ' '|| *sp=='\t';sp++)
+ ;
if((nv_isattr(np,NV_ZFILL)) && (nv_isattr(np,NV_LJUST)))
for(;*sp=='0';sp++);
size = nv_size(np);
diff -r -u original/src/lib/libast/comp/wordexp.c build_clang/src/lib/libast/comp/wordexp.c
--- src/lib/libast/comp/wordexp.c 2004-12-24 18:28:14.000000000 +0100
+++ src/lib/libast/comp/wordexp.c 2013-08-17 15:39:52.253431919 +0200
@@ -91,6 +91,8 @@
literal = !literal;
else if(!literal)
{
+ const char *symbols = "|&\n;<>";
+
if(c=='\\' && (!quoted || strchr("\\\"`\n$",c)))
{
stakputc('\\');
@@ -112,7 +114,7 @@
stakputs(cp-1);
break;
}
- else if(!quoted && strchr("|&\n;<>"+ac,c))
+ else if(!quoted && strchr(&symbols[ac],c))
{
c=WRDE_BADCHAR;
goto err;
diff -r -u original/src/lib/libast/features/aso build_clang/src/lib/libast/features/aso
--- src/lib/libast/features/aso 2013-08-09 09:44:33.000000000 +0200
+++ src/lib/libast/features/aso 2013-08-17 15:17:51.488048844 +0200
@@ -35,10 +35,19 @@
#define asosub64(p,n) __sync_fetch_and_sub(p,n)
#define asoinc64(p) __sync_fetch_and_add(p,1)
#define asodec64(p) __sync_fetch_and_sub(p,1)
- #if _ast_sizeof_pointer == 8
- #define asocasptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,asointegralof(o),asointegralof(n)))
+ #if (__STDC_VERSION__ - 0) >= 199901L
+ #if _ast_sizeof_pointer == 8
+ #define asocasptr(p,o,n) ((__typeof__(o))__sync_val_compare_and_swap((p),(o),(n)))
+ #else
+ #define asocasptr(p,o,n) ((__typeof__(o))__sync_val_compare_and_swap((p),(o),(n)))
+ #endif
+
#else
- #define asocasptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,asointegralof(o),asointegralof(n)))
+ #if _ast_sizeof_pointer == 8
+ #define asocasptr(p,o,n) ((void*)__sync_val_compare_and_swap((p),asointegralof(o),asointegralof(n)))
+ #else
+ #define asocasptr(p,o,n) ((void*)__sync_val_compare_and_swap((p),asointegralof(o),asointegralof(n)))
+ #endif
#endif
}
elif aso note{ gcc 4.1+ 32 bit memory atomic operations model }end link{
diff -r -u original/src/lib/libast/port/intercept.c build_clang/src/lib/libast/port/intercept.c
--- src/lib/libast/port/intercept.c 2013-08-13 23:03:05.000000000 +0200
+++ src/lib/libast/port/intercept.c 2013-08-17 14:51:47.873167168 +0200
@@ -325,7 +325,7 @@
}
}
#else
- if (r < 0 && (flags & (O_DIRECTORY|O_SEARCH)) == O_DIRECTORY && O_SEARCH && O_SEARCH < _ast_O_LOCAL)
+ if ((r < 0) && ((flags & (O_DIRECTORY|O_SEARCH)) == O_DIRECTORY) && (O_SEARCH != 0) && (O_SEARCH < _ast_O_LOCAL))
{
flags |= O_SEARCH|O_INTERCEPT;
goto whither_kiss;
diff -r -u original/src/lib/libast/port/lcgen.c build_clang/src/lib/libast/port/lcgen.c
--- src/lib/libast/port/lcgen.c 2011-03-01 22:13:23.000000000 +0100
+++ src/lib/libast/port/lcgen.c 2013-08-17 14:52:33.517000219 +0200
@@ -185,7 +185,8 @@
if (!f)
return 0;
b = t = *p;
- while (*t++ = *f++);
+ while (*t++ = *f++)
+ ;
*p = t;
return b;
}
diff -r -u original/src/lib/libast/tm/tmxdate.c build_clang/src/lib/libast/tm/tmxdate.c
--- src/lib/libast/tm/tmxdate.c 2012-12-04 20:50:05.000000000 +0100
+++ src/lib/libast/tm/tmxdate.c 2013-08-17 14:56:27.565781749 +0200
@@ -836,7 +836,8 @@
}
else
{
- for (u = t; isspace(*u); u++);
+ for (u = t; isspace(*u); u++)
+ ;
message((-1, "AHA#%d n=%d u=\"%s\"", __LINE__, n, u));
if ((j = tmlex(u, NiL, tm_info.format, TM_NFORM, tm_info.format + TM_SUFFIXES, TM_PARTS - TM_SUFFIXES)) >= 0 && tm_data.lex[j] == TM_PARTS)
s = u;
@@ -978,7 +979,8 @@
}
continue;
}
- for (s = t; skip[*s]; s++);
+ for (s = t; skip[*s]; s++)
+ ;
message((-1, "AHA#%d s=\"%s\"", __LINE__, s));
if (*s == ':' || *s == '.' && ((set|state) & (YEAR|MONTH|DAY|HOUR)) == (YEAR|MONTH|DAY))
{
diff -r -u original/src/lib/libast/vmalloc/vmpool.c build_clang/src/lib/libast/vmalloc/vmpool.c
--- src/lib/libast/vmalloc/vmpool.c 2013-07-18 20:21:17.000000000 +0200
+++ src/lib/libast/vmalloc/vmpool.c 2013-08-17 15:42:52.443572559 +0200
@@ -80,7 +80,7 @@
for(;;) /* grab the free list */
{ if(!(list = pool->free) )
break;
- if(asocasptr(&pool->free, list, NIL(Block_t*)) == list)
+ if(asocasptr(&pool->free, list, NIL(Pool_t*)) == list)
break;
}

@@ -101,7 +101,7 @@

pl = list; /* grab 1 then reinsert the rest */
if((list = list->next) )
- { if(asocasptr(&pool->free, NIL(Block_t*), list) != NIL(Block_t*))
+ { if(asocasptr(&pool->free, NIL(Pool_t*), list) != NIL(Pool_t*))
{ if(!last)
for(last = list;; last = last->next)
if(!last->next)
diff -r -u original/src/lib/libcmd/tail.c build_clang/src/lib/libcmd/tail.c
--- src/lib/libcmd/tail.c 2012-10-10 06:16:54.000000000 +0200
+++ src/lib/libcmd/tail.c 2013-08-17 15:43:43.990047621 +0200
@@ -103,6 +103,7 @@
#include <ctype.h>
#include <ls.h>
#include <tv.h>
+#include <time.h>
#include <rev.h>

#define COUNT (1<<0)
Roland Mainz
2013-10-24 09:40:36 UTC
Permalink
Post by Roland Mainz
Attached (as "astksh20130814_clang_fixes001.diff.txt") is a patch
which fixes a couple annyoing (understatement... :-) ) of "clang"
build warnings for Solaris+Linux +fixes.
Comments/rants/questions welcome... including feedback if the patch is
changed in some way...
Erm... it seems the patch is missing (again) which prevents the
"pathcc" compiler from producing a working binary (I've re-attached
the patch (with lots of cursing since I more or less spend an hour
investigating... old... bugs... ;-( ))...

----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
-------------- next part --------------
diff -r -u original/src/cmd/INIT/proto.c build_clang/src/cmd/INIT/proto.c
--- src/cmd/INIT/proto.c 2013-08-13 20:40:05.000000000 +0200
+++ src/cmd/INIT/proto.c 2013-08-17 15:39:30.139082660 +0200
@@ -4646,7 +4646,8 @@
{
if (proto->flags & (1L<<29))
{
- proto->op = strcopy(( proto->op),( "\n%{\n"+ !notice));
+ const char *s = "\n%{\n";
+ proto->op = strcopy(( proto->op),( &s[(int)(!notice)]));
proto->op = strcopy(( proto->op),( "/* : : generated by proto : : */\n"));
proto->op = strcopy(( proto->op),( "%}\n"));
}
diff -r -u original/src/cmd/ksh93/sh/name.c build_clang/src/cmd/ksh93/sh/name.c
--- src/cmd/ksh93/sh/name.c 2013-08-12 16:33:09.000000000 +0200
+++ src/cmd/ksh93/sh/name.c 2013-08-17 15:01:55.047453450 +0200
@@ -1949,7 +1949,8 @@
}
else if((nv_isattr(np, NV_RJUST|NV_ZFILL|NV_LJUST)) && sp)
{
- for(;*sp == ' '|| *sp=='\t';sp++);
+ for(;*sp == ' '|| *sp=='\t';sp++)
+ ;
if((nv_isattr(np,NV_ZFILL)) && (nv_isattr(np,NV_LJUST)))
for(;*sp=='0';sp++);
size = nv_size(np);
diff -r -u original/src/lib/libast/comp/wordexp.c build_clang/src/lib/libast/comp/wordexp.c
--- src/lib/libast/comp/wordexp.c 2004-12-24 18:28:14.000000000 +0100
+++ src/lib/libast/comp/wordexp.c 2013-08-17 15:39:52.253431919 +0200
@@ -91,6 +91,8 @@
literal = !literal;
else if(!literal)
{
+ const char *symbols = "|&\n;<>";
+
if(c=='\\' && (!quoted || strchr("\\\"`\n$",c)))
{
stakputc('\\');
@@ -112,7 +114,7 @@
stakputs(cp-1);
break;
}
- else if(!quoted && strchr("|&\n;<>"+ac,c))
+ else if(!quoted && strchr(&symbols[ac],c))
{
c=WRDE_BADCHAR;
goto err;
diff -r -u original/src/lib/libast/features/aso build_clang/src/lib/libast/features/aso
--- src/lib/libast/features/aso 2013-08-09 09:44:33.000000000 +0200
+++ src/lib/libast/features/aso 2013-08-17 15:17:51.488048844 +0200
@@ -35,10 +35,19 @@
#define asosub64(p,n) __sync_fetch_and_sub(p,n)
#define asoinc64(p) __sync_fetch_and_add(p,1)
#define asodec64(p) __sync_fetch_and_sub(p,1)
- #if _ast_sizeof_pointer == 8
- #define asocasptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,asointegralof(o),asointegralof(n)))
+ #if (__STDC_VERSION__ - 0) >= 199901L
+ #if _ast_sizeof_pointer == 8
+ #define asocasptr(p,o,n) ((__typeof__(o))__sync_val_compare_and_swap((p),(o),(n)))
+ #else
+ #define asocasptr(p,o,n) ((__typeof__(o))__sync_val_compare_and_swap((p),(o),(n)))
+ #endif
+
#else
- #define asocasptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,asointegralof(o),asointegralof(n)))
+ #if _ast_sizeof_pointer == 8
+ #define asocasptr(p,o,n) ((void*)__sync_val_compare_and_swap((p),asointegralof(o),asointegralof(n)))
+ #else
+ #define asocasptr(p,o,n) ((void*)__sync_val_compare_and_swap((p),asointegralof(o),asointegralof(n)))
+ #endif
#endif
}
elif aso note{ gcc 4.1+ 32 bit memory atomic operations model }end link{
diff -r -u original/src/lib/libast/port/intercept.c build_clang/src/lib/libast/port/intercept.c
--- src/lib/libast/port/intercept.c 2013-08-13 23:03:05.000000000 +0200
+++ src/lib/libast/port/intercept.c 2013-08-17 14:51:47.873167168 +0200
@@ -325,7 +325,7 @@
}
}
#else
- if (r < 0 && (flags & (O_DIRECTORY|O_SEARCH)) == O_DIRECTORY && O_SEARCH && O_SEARCH < _ast_O_LOCAL)
+ if ((r < 0) && ((flags & (O_DIRECTORY|O_SEARCH)) == O_DIRECTORY) && (O_SEARCH != 0) && (O_SEARCH < _ast_O_LOCAL))
{
flags |= O_SEARCH|O_INTERCEPT;
goto whither_kiss;
diff -r -u original/src/lib/libast/port/lcgen.c build_clang/src/lib/libast/port/lcgen.c
--- src/lib/libast/port/lcgen.c 2011-03-01 22:13:23.000000000 +0100
+++ src/lib/libast/port/lcgen.c 2013-08-17 14:52:33.517000219 +0200
@@ -185,7 +185,8 @@
if (!f)
return 0;
b = t = *p;
- while (*t++ = *f++);
+ while (*t++ = *f++)
+ ;
*p = t;
return b;
}
diff -r -u original/src/lib/libast/tm/tmxdate.c build_clang/src/lib/libast/tm/tmxdate.c
--- src/lib/libast/tm/tmxdate.c 2012-12-04 20:50:05.000000000 +0100
+++ src/lib/libast/tm/tmxdate.c 2013-08-17 14:56:27.565781749 +0200
@@ -836,7 +836,8 @@
}
else
{
- for (u = t; isspace(*u); u++);
+ for (u = t; isspace(*u); u++)
+ ;
message((-1, "AHA#%d n=%d u=\"%s\"", __LINE__, n, u));
if ((j = tmlex(u, NiL, tm_info.format, TM_NFORM, tm_info.format + TM_SUFFIXES, TM_PARTS - TM_SUFFIXES)) >= 0 && tm_data.lex[j] == TM_PARTS)
s = u;
@@ -978,7 +979,8 @@
}
continue;
}
- for (s = t; skip[*s]; s++);
+ for (s = t; skip[*s]; s++)
+ ;
message((-1, "AHA#%d s=\"%s\"", __LINE__, s));
if (*s == ':' || *s == '.' && ((set|state) & (YEAR|MONTH|DAY|HOUR)) == (YEAR|MONTH|DAY))
{
diff -r -u original/src/lib/libast/vmalloc/vmpool.c build_clang/src/lib/libast/vmalloc/vmpool.c
--- src/lib/libast/vmalloc/vmpool.c 2013-07-18 20:21:17.000000000 +0200
+++ src/lib/libast/vmalloc/vmpool.c 2013-08-17 15:42:52.443572559 +0200
@@ -80,7 +80,7 @@
for(;;) /* grab the free list */
{ if(!(list = pool->free) )
break;
- if(asocasptr(&pool->free, list, NIL(Block_t*)) == list)
+ if(asocasptr(&pool->free, list, NIL(Pool_t*)) == list)
break;
}

@@ -101,7 +101,7 @@

pl = list; /* grab 1 then reinsert the rest */
if((list = list->next) )
- { if(asocasptr(&pool->free, NIL(Block_t*), list) != NIL(Block_t*))
+ { if(asocasptr(&pool->free, NIL(Pool_t*), list) != NIL(Pool_t*))
{ if(!last)
for(last = list;; last = last->next)
if(!last->next)
diff -r -u original/src/lib/libcmd/tail.c build_clang/src/lib/libcmd/tail.c
--- src/lib/libcmd/tail.c 2012-10-10 06:16:54.000000000 +0200
+++ src/lib/libcmd/tail.c 2013-08-17 15:43:43.990047621 +0200
@@ -103,6 +103,7 @@
#include <ctype.h>
#include <ls.h>
#include <tv.h>
+#include <time.h>
#include <rev.h>

#define COUNT (1<<0)
Loading...