public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [Bug translator/10300] New: Provide more macros for embedded-C functions
@ 2009-06-19  0:39 jistone at redhat dot com
  0 siblings, 0 replies; only message in thread
From: jistone at redhat dot com @ 2009-06-19  0:39 UTC (permalink / raw)
  To: systemtap

It might be nice to have a convenience macro in embedded-C functions which sets
the return value and exits the function.  This would be specialized to the
return type of the function, basically:

  long:
  #define RETURN(val) THIS->__retvalue = (val), goto out

  string:
  #define RETURN(val) strlcpy(THIS->__retvalue, (val), MAXSTRINGLEN), goto out

  no return value:
  #define RETURN() goto out


Similarly, for signaling errors/warnings we may want:

  #define ERROR(...) \
    snprintf(CONTEXT->error_buffer, MAXSTRINGLEN, __VA_ARGS__), \
    CONTEXT->last_error = CONTEXT->error_buffer, goto out

  #define WARN(...) \
    snprintf(CONTEXT->error_buffer, MAXSTRINGLEN, __VA_ARGS__), \
    _stp_warn(CONTEXT->error_buffer)


Thoughts?

-- 
           Summary: Provide more macros for embedded-C functions
           Product: systemtap
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: translator
        AssignedTo: systemtap at sources dot redhat dot com
        ReportedBy: jistone at redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=10300

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-06-19  0:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-19  0:39 [Bug translator/10300] New: Provide more macros for embedded-C functions jistone at redhat dot com

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).