Re: empty function macros

2011-02-01 Thread Roman Divacky
On Mon, Jan 31, 2011 at 09:51:58AM +, Alexander Best wrote:
> On Mon Jan 31 11, Roman Divacky wrote:
> > no problem with this with clang :)
> 
> hmso compiling the following code
> 
> int
> main(int argc, char **argv)
> {
> if (1<2)
> ;
> }
> 
> with clang -Werror code.c -o code works for you?

if (1<2)
 ;

gives a warning (and it should), on the other hand

#define NOTHING

if (1<2)
 NOTHING;

does not warn, which is what you want right?
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: empty function macros

2011-02-01 Thread Alexander Best
On Tue Feb  1 11, Roman Divacky wrote:
> On Mon, Jan 31, 2011 at 09:51:58AM +, Alexander Best wrote:
> > On Mon Jan 31 11, Roman Divacky wrote:
> > > no problem with this with clang :)
> > 
> > hmso compiling the following code
> > 
> > int
> > main(int argc, char **argv)
> > {
> > if (1<2)
> > ;
> > }
> > 
> > with clang -Werror code.c -o code works for you?
> 
> if (1<2)
>  ;
> 
> gives a warning (and it should), on the other hand
> 
> #define NOTHING
> 
> if (1<2)
>  NOTHING;
> 
> does not warn, which is what you want right?

actually

#define NOTHING

int
main(int argc, char **argv)
{
if (1<2)
NOTHING;

return (0);
}

*does* warn for me:

otaku% clang test.c -o test  
test.c:7:12: warning: if statement has empty body [-Wempty-body]
NOTHING;
   ^
1 warning generated.

..gcc on the otherhand will only warn with -Wextra. so the questions still
stands:

should

#define NOTHING

be replaced with

#define NOTHING do { } while (0)

?

cheers.
alex

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


weird characters in top(1) output

2011-02-01 Thread Alexander Best
hi there,

i was doing the following:

top inf > ~/output

when i noticed that this was missing the overall statistics line. so i went
ahead and did:

top -d2 inf > ~/output

funny thing is that for the second output some weird characters seem to get
spammed into the overall statistics line:

last pid: 14320;  load averages:  0.42,  0.44,  0.37  up 1+14:02:0213:21:05
249 processes: 1 running, 248 sleeping
CPU: ^[[3;6H 7.8% user,  0.0% nice, 10.6% system,  0.6% interrupt, 81.0% idle
Mem: 1271M Active, 205M Inact, 402M Wired, 67M Cache, 212M Buf, 18M Free
Swap: 18G Total, 782M Used, 17G Free, 4% Inuse

this only seems to happen when i redirect the top(1) output to a file. if i do:

top -d2 inf

...everything works fine. i verified the issue under zsh(1) and sh(1).

cheers.
alex

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: weird characters in top(1) output

2011-02-01 Thread Sergey Kandaurov
On 1 February 2011 15:24, Alexander Best  wrote:
> hi there,
>
> i was doing the following:
>
> top inf > ~/output
>
> when i noticed that this was missing the overall statistics line. so i went
> ahead and did:
>
> top -d2 inf > ~/output
>
> funny thing is that for the second output some weird characters seem to get
> spammed into the overall statistics line:
>
> last pid: 14320;  load averages:  0.42,  0.44,  0.37  up 1+14:02:02    
> 13:21:05
> 249 processes: 1 running, 248 sleeping
> CPU: ^[[3;6H 7.8% user,  0.0% nice, 10.6% system,  0.6% interrupt, 81.0% idle
> Mem: 1271M Active, 205M Inact, 402M Wired, 67M Cache, 212M Buf, 18M Free
> Swap: 18G Total, 782M Used, 17G Free, 4% Inuse
>
> this only seems to happen when i redirect the top(1) output to a file. if i 
> do:
>
> top -d2 inf
>
> ...everything works fine. i verified the issue under zsh(1) and sh(1).

My quick check shows that this is a regression between 7.2 and 7.3.
Reverting r196382 fixes this bug for me.

-- 
wbr,
pluknet
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: weird characters in top(1) output

2011-02-01 Thread Alexander Best
On Tue Feb  1 11, Sergey Kandaurov wrote:
> On 1 February 2011 15:24, Alexander Best  wrote:
> > hi there,
> >
> > i was doing the following:
> >
> > top inf > ~/output
> >
> > when i noticed that this was missing the overall statistics line. so i went
> > ahead and did:
> >
> > top -d2 inf > ~/output
> >
> > funny thing is that for the second output some weird characters seem to get
> > spammed into the overall statistics line:
> >
> > last pid: 14320;  load averages:  0.42,  0.44,  0.37  up 1+14:02:02    
> > 13:21:05
> > 249 processes: 1 running, 248 sleeping
> > CPU: ^[[3;6H 7.8% user,  0.0% nice, 10.6% system,  0.6% interrupt, 81.0% 
> > idle
> > Mem: 1271M Active, 205M Inact, 402M Wired, 67M Cache, 212M Buf, 18M Free
> > Swap: 18G Total, 782M Used, 17G Free, 4% Inuse
> >
> > this only seems to happen when i redirect the top(1) output to a file. if i 
> > do:
> >
> > top -d2 inf
> >
> > ...everything works fine. i verified the issue under zsh(1) and sh(1).
> 
> My quick check shows that this is a regression between 7.2 and 7.3.
> Reverting r196382 fixes this bug for me.

thanks for the help. indeed reverting r196382 fixes the issue.

cheers.
alex

> 
> -- 
> wbr,
> pluknet

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: weird characters in top(1) output

2011-02-01 Thread John Baldwin
On Tuesday, February 01, 2011 8:11:54 am Alexander Best wrote:
> On Tue Feb  1 11, Sergey Kandaurov wrote:
> > On 1 February 2011 15:24, Alexander Best  wrote:
> > > hi there,
> > >
> > > i was doing the following:
> > >
> > > top inf > ~/output
> > >
> > > when i noticed that this was missing the overall statistics line. so i 
> > > went
> > > ahead and did:
> > >
> > > top -d2 inf > ~/output
> > >
> > > funny thing is that for the second output some weird characters seem to 
> > > get
> > > spammed into the overall statistics line:
> > >
> > > last pid: 14320;  load averages:  0.42,  0.44,  0.37  up 1+14:02:02
> > > 13:21:05
> > > 249 processes: 1 running, 248 sleeping
> > > CPU: ^[[3;6H 7.8% user,  0.0% nice, 10.6% system,  0.6% interrupt, 81.0% 
> > > idle
> > > Mem: 1271M Active, 205M Inact, 402M Wired, 67M Cache, 212M Buf, 18M Free
> > > Swap: 18G Total, 782M Used, 17G Free, 4% Inuse
> > >
> > > this only seems to happen when i redirect the top(1) output to a file. if 
> > > i do:
> > >
> > > top -d2 inf
> > >
> > > ...everything works fine. i verified the issue under zsh(1) and sh(1).
> > 
> > My quick check shows that this is a regression between 7.2 and 7.3.
> > Reverting r196382 fixes this bug for me.
> 
> thanks for the help. indeed reverting r196382 fixes the issue.

Hmm, you need more than 10 CPUs to understand the reason for that fix.
Without it all of the updated per-CPU states are off by one column so you
get weird screen effects.  The "garbage" characters are actually just a
terminal sequence to move the cursor.  top uses these things a _lot_ to
move the cursor around.

You can try this instead though, it figures out the appropriate number of
spaces rather than using Move_to() for these two routines:

Index: display.c
===
--- display.c   (revision 218032)
+++ display.c   (working copy)
@@ -447,12 +447,14 @@
 /* print tag and bump lastline */
 if (num_cpus == 1)
printf("\nCPU: ");
-else
-   printf("\nCPU %d: ", cpu);
+else {
+   value = printf("\nCPU %d: ", cpu);
+   while (value++ <= cpustates_column)
+   printf(" ");
+}
 lastline++;
 
 /* now walk thru the names and print the line */
-Move_to(cpustates_column, y_cpustates + cpu);
 while ((thisname = *names++) != NULL)
 {
if (*thisname != '\0')
@@ -532,7 +534,7 @@
 register char **names;
 register char *thisname;
 register int *lp;
-int cpu;
+int cpu, value;
 
 for (cpu = 0; cpu < num_cpus; cpu++) {
 names = cpustate_names;
@@ -540,11 +542,13 @@
 /* show tag and bump lastline */
 if (num_cpus == 1)
printf("\nCPU: ");
-else
-   printf("\nCPU %d: ", cpu);
+else {
+   value = printf("\nCPU %d: ", cpu);
+   while (value++ <= cpustates_column)
+   printf(" ");
+}
 lastline++;
 
-Move_to(cpustates_column, y_cpustates + cpu);
 while ((thisname = *names++) != NULL)
 {
if (*thisname != '\0')

-- 
John Baldwin
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: weird characters in top(1) output

2011-02-01 Thread Alexander Best
On Tue Feb  1 11, John Baldwin wrote:
> On Tuesday, February 01, 2011 8:11:54 am Alexander Best wrote:
> > On Tue Feb  1 11, Sergey Kandaurov wrote:
> > > On 1 February 2011 15:24, Alexander Best  wrote:
> > > > hi there,
> > > >
> > > > i was doing the following:
> > > >
> > > > top inf > ~/output
> > > >
> > > > when i noticed that this was missing the overall statistics line. so i 
> > > > went
> > > > ahead and did:
> > > >
> > > > top -d2 inf > ~/output
> > > >
> > > > funny thing is that for the second output some weird characters seem to 
> > > > get
> > > > spammed into the overall statistics line:
> > > >
> > > > last pid: 14320;  load averages:  0.42,  0.44,  0.37  up 1+14:02:02
> > > > 13:21:05
> > > > 249 processes: 1 running, 248 sleeping
> > > > CPU: ^[[3;6H 7.8% user,  0.0% nice, 10.6% system,  0.6% interrupt, 
> > > > 81.0% idle
> > > > Mem: 1271M Active, 205M Inact, 402M Wired, 67M Cache, 212M Buf, 18M Free
> > > > Swap: 18G Total, 782M Used, 17G Free, 4% Inuse
> > > >
> > > > this only seems to happen when i redirect the top(1) output to a file. 
> > > > if i do:
> > > >
> > > > top -d2 inf
> > > >
> > > > ...everything works fine. i verified the issue under zsh(1) and sh(1).
> > > 
> > > My quick check shows that this is a regression between 7.2 and 7.3.
> > > Reverting r196382 fixes this bug for me.
> > 
> > thanks for the help. indeed reverting r196382 fixes the issue.
> 
> Hmm, you need more than 10 CPUs to understand the reason for that fix.
> Without it all of the updated per-CPU states are off by one column so you
> get weird screen effects.  The "garbage" characters are actually just a
> terminal sequence to move the cursor.  top uses these things a _lot_ to
> move the cursor around.
> 
> You can try this instead though, it figures out the appropriate number of
> spaces rather than using Move_to() for these two routines:

the patch works for me:

last pid: 15311;  load averages:  0.13,  0.54,  0.73  up 1+16:56:1816:15:21
276 processes: 2 running, 273 sleeping, 1 zombie
CPU:  9.8% user,  0.0% nice, 16.5% system,  2.2% interrupt, 71.6% idle
Mem: 1329M Active, 135M Inact, 417M Wired, 79M Cache, 212M Buf, 1608K Free
Swap: 18G Total, 1414M Used, 17G Free, 7% Inuse, 4K In

#CPU cores == 2 on my system btw.

cheers.
alex

> 
> Index: display.c
> ===
> --- display.c (revision 218032)
> +++ display.c (working copy)
> @@ -447,12 +447,14 @@
>  /* print tag and bump lastline */
>  if (num_cpus == 1)
>   printf("\nCPU: ");
> -else
> - printf("\nCPU %d: ", cpu);
> +else {
> + value = printf("\nCPU %d: ", cpu);
> + while (value++ <= cpustates_column)
> + printf(" ");
> +}
>  lastline++;
>  
>  /* now walk thru the names and print the line */
> -Move_to(cpustates_column, y_cpustates + cpu);
>  while ((thisname = *names++) != NULL)
>  {
>   if (*thisname != '\0')
> @@ -532,7 +534,7 @@
>  register char **names;
>  register char *thisname;
>  register int *lp;
> -int cpu;
> +int cpu, value;
>  
>  for (cpu = 0; cpu < num_cpus; cpu++) {
>  names = cpustate_names;
> @@ -540,11 +542,13 @@
>  /* show tag and bump lastline */
>  if (num_cpus == 1)
>   printf("\nCPU: ");
> -else
> - printf("\nCPU %d: ", cpu);
> +else {
> + value = printf("\nCPU %d: ", cpu);
> + while (value++ <= cpustates_column)
> + printf(" ");
> +}
>  lastline++;
>  
> -Move_to(cpustates_column, y_cpustates + cpu);
>  while ((thisname = *names++) != NULL)
>  {
>   if (*thisname != '\0')
> 
> -- 
> John Baldwin

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: empty function macros

2011-02-01 Thread Roman Divacky
On Tue, Feb 01, 2011 at 11:25:01AM +, Alexander Best wrote:
> On Tue Feb  1 11, Roman Divacky wrote:
> > On Mon, Jan 31, 2011 at 09:51:58AM +, Alexander Best wrote:
> > > On Mon Jan 31 11, Roman Divacky wrote:
> > > > no problem with this with clang :)
> > > 
> > > hmso compiling the following code
> > > 
> > > int
> > > main(int argc, char **argv)
> > > {
> > > if (1<2)
> > > ;
> > > }
> > > 
> > > with clang -Werror code.c -o code works for you?
> > 
> > if (1<2)
> >  ;
> > 
> > gives a warning (and it should), on the other hand
> > 
> > #define NOTHING
> > 
> > if (1<2)
> >  NOTHING;
> > 
> > does not warn, which is what you want right?
> 
> actually
> 
> #define NOTHING
> 
> int
> main(int argc, char **argv)
> {
> if (1<2)
> NOTHING;
> 
> return (0);
> }
> 
> *does* warn for me:
> 
> otaku% clang test.c -o test  
> test.c:7:12: warning: if statement has empty body [-Wempty-body]
> NOTHING;
>^
> 1 warning generated.

are you using clang2.8? if so this is 2.9 feature then :)
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: empty function macros

2011-02-01 Thread Alexander Best
On Tue Feb  1 11, Roman Divacky wrote:
> On Tue, Feb 01, 2011 at 11:25:01AM +, Alexander Best wrote:
> > On Tue Feb  1 11, Roman Divacky wrote:
> > > On Mon, Jan 31, 2011 at 09:51:58AM +, Alexander Best wrote:
> > > > On Mon Jan 31 11, Roman Divacky wrote:
> > > > > no problem with this with clang :)
> > > > 
> > > > hmso compiling the following code
> > > > 
> > > > int
> > > > main(int argc, char **argv)
> > > > {
> > > > if (1<2)
> > > > ;
> > > > }
> > > > 
> > > > with clang -Werror code.c -o code works for you?
> > > 
> > > if (1<2)
> > >  ;
> > > 
> > > gives a warning (and it should), on the other hand
> > > 
> > > #define NOTHING
> > > 
> > > if (1<2)
> > >  NOTHING;
> > > 
> > > does not warn, which is what you want right?
> > 
> > actually
> > 
> > #define NOTHING
> > 
> > int
> > main(int argc, char **argv)
> > {
> > if (1<2)
> > NOTHING;
> > 
> > return (0);
> > }
> > 
> > *does* warn for me:
> > 
> > otaku% clang test.c -o test  
> > test.c:7:12: warning: if statement has empty body [-Wempty-body]
> > NOTHING;
> >^
> > 1 warning generated.
> 
> are you using clang2.8? if so this is 2.9 feature then :)

indeed only clang 2.8 generates the warning:

otaku% clang test.c -o test   
test.c:7:15: warning: if statement has empty body [-Wempty-body]
NOTHING(1);
  ^
1 warning generated.
otaku% /usr/local/bin/clang test.c -o test
otaku%

thanks for the hint. so there's no need to remove any

#define NOTHING

lines, since gcc doesn't complain and with the import of clang 2.9 clang will
no longer complain about it.

cheers.
alex

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"


Re: weird characters in top(1) output

2011-02-01 Thread Alexander Best
On Tue Feb  1 11, John Baldwin wrote:
> On Tuesday, February 01, 2011 8:11:54 am Alexander Best wrote:
> > On Tue Feb  1 11, Sergey Kandaurov wrote:
> > > On 1 February 2011 15:24, Alexander Best  wrote:
> > > > hi there,
> > > >
> > > > i was doing the following:
> > > >
> > > > top inf > ~/output
> > > >
> > > > when i noticed that this was missing the overall statistics line. so i 
> > > > went
> > > > ahead and did:
> > > >
> > > > top -d2 inf > ~/output
> > > >
> > > > funny thing is that for the second output some weird characters seem to 
> > > > get
> > > > spammed into the overall statistics line:
> > > >
> > > > last pid: 14320;  load averages:  0.42,  0.44,  0.37  up 1+14:02:02
> > > > 13:21:05
> > > > 249 processes: 1 running, 248 sleeping
> > > > CPU: ^[[3;6H 7.8% user,  0.0% nice, 10.6% system,  0.6% interrupt, 
> > > > 81.0% idle
> > > > Mem: 1271M Active, 205M Inact, 402M Wired, 67M Cache, 212M Buf, 18M Free
> > > > Swap: 18G Total, 782M Used, 17G Free, 4% Inuse
> > > >
> > > > this only seems to happen when i redirect the top(1) output to a file. 
> > > > if i do:
> > > >
> > > > top -d2 inf
> > > >
> > > > ...everything works fine. i verified the issue under zsh(1) and sh(1).
> > > 
> > > My quick check shows that this is a regression between 7.2 and 7.3.
> > > Reverting r196382 fixes this bug for me.
> > 
> > thanks for the help. indeed reverting r196382 fixes the issue.
> 
> Hmm, you need more than 10 CPUs to understand the reason for that fix.
> Without it all of the updated per-CPU states are off by one column so you
> get weird screen effects.  The "garbage" characters are actually just a
> terminal sequence to move the cursor.  top uses these things a _lot_ to
> move the cursor around.
> 
> You can try this instead though, it figures out the appropriate number of
> spaces rather than using Move_to() for these two routines:

btw: shouldn't top(1) switch to batch mode when redirecting the output to a
file? because right now it seems to stay in interactive mode.

doing `top -b -d2 inf > output` works even without your changes.

cheers.
alex

> 
> Index: display.c
> ===
> --- display.c (revision 218032)
> +++ display.c (working copy)
> @@ -447,12 +447,14 @@
>  /* print tag and bump lastline */
>  if (num_cpus == 1)
>   printf("\nCPU: ");
> -else
> - printf("\nCPU %d: ", cpu);
> +else {
> + value = printf("\nCPU %d: ", cpu);
> + while (value++ <= cpustates_column)
> + printf(" ");
> +}
>  lastline++;
>  
>  /* now walk thru the names and print the line */
> -Move_to(cpustates_column, y_cpustates + cpu);
>  while ((thisname = *names++) != NULL)
>  {
>   if (*thisname != '\0')
> @@ -532,7 +534,7 @@
>  register char **names;
>  register char *thisname;
>  register int *lp;
> -int cpu;
> +int cpu, value;
>  
>  for (cpu = 0; cpu < num_cpus; cpu++) {
>  names = cpustate_names;
> @@ -540,11 +542,13 @@
>  /* show tag and bump lastline */
>  if (num_cpus == 1)
>   printf("\nCPU: ");
> -else
> - printf("\nCPU %d: ", cpu);
> +else {
> + value = printf("\nCPU %d: ", cpu);
> + while (value++ <= cpustates_column)
> + printf(" ");
> +}
>  lastline++;
>  
> -Move_to(cpustates_column, y_cpustates + cpu);
>  while ((thisname = *names++) != NULL)
>  {
>   if (*thisname != '\0')
> 
> -- 
> John Baldwin

-- 
a13x
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"