summaryrefslogtreecommitdiffstats
path: root/runtime/string.c
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2010-02-15 21:27:37 -0800
committerJosh Stone <jistone@redhat.com>2010-02-16 15:55:01 -0800
commitd9f58253e30ea80e57d8f54e41e9cd114cc13973 (patch)
tree557c38cd069499be0defe734595af161a166bd98 /runtime/string.c
parent4fa8e6497405fd4f121a3eee0c6d772aaeeef6d8 (diff)
downloadsystemtap-steved-d9f58253e30ea80e57d8f54e41e9cd114cc13973.tar.gz
systemtap-steved-d9f58253e30ea80e57d8f54e41e9cd114cc13973.tar.xz
systemtap-steved-d9f58253e30ea80e57d8f54e41e9cd114cc13973.zip
Use clamping to more easily normalize input values
The kernel has min/max/clamp macros to make range comparisons easier. Clamp is a newer invention, but we can define it for older kernels in terms of min and max.
Diffstat (limited to 'runtime/string.c')
-rw-r--r--runtime/string.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/runtime/string.c b/runtime/string.c
index 1d4cb255..afef191a 100644
--- a/runtime/string.c
+++ b/runtime/string.c
@@ -68,10 +68,10 @@ static void _stp_text_str(char *outstr, char *in, int len, int quoted, int user)
{
char c, *out = outstr;
- if (len == 0 || len > MAXSTRINGLEN-1)
+ if (len <= 0 || len > MAXSTRINGLEN-1)
len = MAXSTRINGLEN-1;
if (quoted) {
- len -= 2;
+ len = max(len, 5) - 2;
*out++ = '"';
}