public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "Frank Ch. Eigler" <fche@redhat.com>
To: systemtap@sources.redhat.com
Subject: script coding style - mask_string.stp
Date: Wed, 28 Sep 2005 10:49:00 -0000	[thread overview]
Message-ID: <20050928104921.GA16346@redhat.com> (raw)

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

                 reply	other threads:[~2005-09-28 10:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050928104921.GA16346@redhat.com \
    --to=fche@redhat.com \
    --cc=systemtap@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).