* script coding style - mask_string.stp
@ 2005-09-28 10:49 Frank Ch. Eigler
0 siblings, 0 replies; only message in thread
From: Frank Ch. Eigler @ 2005-09-28 10:49 UTC (permalink / raw)
To: systemtap
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-09-28 10:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-28 10:49 script coding style - mask_string.stp Frank Ch. Eigler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).