This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap 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]

Re: Dealing with empty aggregates?


"Bryn M. Reeves" <bmr@redhat.com> writes:

> [...]
> ERROR: empty aggregate near identifier '@sum' at <input>:1:42
> [...]
> probe timer.ms(1000) {
>     if (have_stuff) {
>         printf("Sum of stuff: %d\n", @sum(stuff))
>     } else {
>         print("Sum of stuff: n/a\n")
>     }
> }

The canonical construct doesn't require a hand-maintained flag:

probe timer.ms(1000) {
    if (@count(stuff))
       printf("Sum of stuff: %d\n", @sum(stuff))
    else
       printf("No stuff.")
}


- FChE


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