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]

script coding style - mask_string.stp


Hi, Kevin -

Regarding mask_string.stp, some comments.  Script code need not look
like C so much.  Script functions generally don't need the
parameter/result type declarations, nor all those semicolons.  These
functions could be placed within system_calls.stp, if there is little
likelihood of them being used from elsewhere.  Use of the _name/_bits
global arrays as additional implicit arguments to _bitstring() is both
inefficient and unsafe (in the face of concurrency).  Consider instead
this simpler, safer version:

function _bitstring_buildup (bs,number,name,mask) {
        // bs contains built-up string so far
        if (number & mask)
           if (bs == "")
              return name
           else
              return bs."|".name
}

function sys_adjtimex_mode_str (flags) {
        // bs is local, initialized empty
        bs = _bitstring_buildup (bs, flags, "ADJ_OFFSET", 1)
        bs = _bitstring_buildup (bs, flags, "ADJ_FREQUENCY", 2)
        // and so on
        return bs
}


- FChE


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