Browse Source

src: clean up unused macros in node_file.cc

Remove a few unused or barely used macros from src/node_file.cc.

PR-URL: https://github.com/iojs/io.js/pull/529
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
v1.8.0-commit
Ben Noordhuis 10 years ago
parent
commit
668420d1f7
  1. 26
      src/node_file.cc

26
src/node_file.cc

@ -44,6 +44,8 @@ using v8::Value;
#define THROW_BAD_ARGS TYPE_ERROR("Bad argument") #define THROW_BAD_ARGS TYPE_ERROR("Bad argument")
#define GET_OFFSET(a) ((a)->IsNumber() ? (a)->IntegerValue() : -1)
class FSReqWrap: public ReqWrap<uv_fs_t> { class FSReqWrap: public ReqWrap<uv_fs_t> {
public: public:
void* operator new(size_t size) { return new char[size]; } void* operator new(size_t size) { return new char[size]; }
@ -85,17 +87,6 @@ static void NewFSReqWrap(const FunctionCallbackInfo<Value>& args) {
} }
#define ASSERT_OFFSET(a) \
if (!(a)->IsUndefined() && !(a)->IsNull() && !IsInt64((a)->NumberValue())) { \
return env->ThrowTypeError("Not an integer"); \
}
#define ASSERT_TRUNCATE_LENGTH(a) \
if (!(a)->IsUndefined() && !(a)->IsNull() && !IsInt64((a)->NumberValue())) { \
return env->ThrowTypeError("Not an integer"); \
}
#define GET_OFFSET(a) ((a)->IsNumber() ? (a)->IntegerValue() : -1)
#define GET_TRUNCATE_LENGTH(a) ((a)->IntegerValue())
static inline bool IsInt64(double x) { static inline bool IsInt64(double x) {
return x == static_cast<double>(static_cast<int64_t>(x)); return x == static_cast<double>(static_cast<int64_t>(x));
} }
@ -599,8 +590,17 @@ static void FTruncate(const FunctionCallbackInfo<Value>& args) {
int fd = args[0]->Int32Value(); int fd = args[0]->Int32Value();
ASSERT_TRUNCATE_LENGTH(args[1]); // FIXME(bnoordhuis) It's questionable to reject non-ints here but still
int64_t len = GET_TRUNCATE_LENGTH(args[1]); // allow implicit coercion from null or undefined to zero. Probably best
// handled in lib/fs.js.
Local<Value> len_v(args[1]);
if (!len_v->IsUndefined() &&
!len_v->IsNull() &&
!IsInt64(len_v->NumberValue())) {
return env->ThrowTypeError("Not an integer");
}
const int64_t len = len_v->IntegerValue();
if (args[2]->IsObject()) { if (args[2]->IsObject()) {
ASYNC_CALL(ftruncate, args[2], fd, len) ASYNC_CALL(ftruncate, args[2], fd, len)

Loading…
Cancel
Save