From 41debb52b9d719dbb6f3ee7963de8913eff0c13d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 6 Jun 2010 07:34:09 +0000 Subject: ext: the N in /dev/fd/N must be unsigned There's no way in hell a valid file descriptor can have a negative number attached to it. --- ext/clogger_ext/clogger.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ext/clogger_ext/clogger.c b/ext/clogger_ext/clogger.c index 834debe..cc08fac 100644 --- a/ext/clogger_ext/clogger.c +++ b/ext/clogger_ext/clogger.c @@ -806,6 +806,7 @@ static VALUE to_path(VALUE self) VALUE path = rb_funcall(c->body, to_path_id, 0); struct stat sb; int rv; + unsigned devfd; const char *cpath; Check_Type(path, T_STRING); @@ -815,11 +816,11 @@ static VALUE to_path(VALUE self) if (rb_respond_to(c->body, to_io_id)) rv = fstat(my_fileno(c->body), &sb); /* - * Rainbows! can use "/dev/fd/%d" in to_path output to avoid + * Rainbows! can use "/dev/fd/%u" in to_path output to avoid * extra open() syscalls, too. */ - else if (sscanf(cpath, "/dev/fd/%d", &rv) == 1) - rv = fstat(rv, &sb); + else if (sscanf(cpath, "/dev/fd/%u", &devfd) == 1) + rv = fstat((int)devfd, &sb); else rv = stat(cpath, &sb); -- cgit v1.2.3-24-ge0c7