Skip to content

Commit

Permalink
Fix some lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Sannis committed Feb 14, 2011
1 parent 5b4637e commit dd1c69e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/mysql_bindings_connection.cc
Expand Up @@ -425,7 +425,8 @@ int MysqlConnection::EIO_After_Connect(eio_req *req) {
Local<Value> argv[1];

if (req->result) {
unsigned int error_string_length = strlen(conn_req->conn->connect_error) + 25;
unsigned int error_string_length =
strlen(conn_req->conn->connect_error) + 25;
char* error_string = new char[error_string_length];
snprintf(error_string, error_string_length, "Connection error #%d: %s",
conn_req->errno, conn_req->error);
Expand Down Expand Up @@ -710,9 +711,9 @@ Handle<Value> MysqlConnection::FieldCountSync(const Arguments& args) {

MYSQLCONN_MUSTBE_CONNECTED;

return scope.Close(Integer::NewFromUnsigned(
mysql_field_count(conn->_conn)
));
return scope.Close(
Integer::NewFromUnsigned(
mysql_field_count(conn->_conn)));
}

/**
Expand Down Expand Up @@ -800,8 +801,7 @@ Handle<Value> MysqlConnection::GetInfoSync(const Arguments& args) {
V8STR(mysql_get_server_info(conn->_conn)));
js_result->Set(V8STR("server_version"),
Integer::NewFromUnsigned(
mysql_get_server_version(conn->_conn)
));
mysql_get_server_version(conn->_conn)));
js_result->Set(V8STR("host_info"),
V8STR(mysql_get_host_info(conn->_conn)));
js_result->Set(V8STR("proto_info"),
Expand Down
29 changes: 19 additions & 10 deletions src/mysql_bindings_result.cc
Expand Up @@ -88,7 +88,9 @@ void MysqlResult::AddFieldProperties(
Integer::NewFromUnsigned(field->decimals));
}

Local<Value> MysqlResult::GetFieldValue(MYSQL_FIELD field, char* field_value, unsigned long field_length) {
Local<Value> MysqlResult::GetFieldValue(MYSQL_FIELD field,
char* field_value,
unsigned long field_length) {
HandleScope scope;

Local<Value> js_field = Local<Value>::New(Null());
Expand Down Expand Up @@ -211,17 +213,20 @@ Local<Value> MysqlResult::GetFieldValue(MYSQL_FIELD field, char* field_value, un
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
if(field_value) {
if(field.flags & BINARY_FLAG) {
if (field_value) {
if (field.flags & BINARY_FLAG) {
#if NODE_MINOR_VERSION < 3
node::Buffer *bp = node::Buffer::New(field_length);
memcpy(bp->data(), field_value, field_length);
js_field = Local<Value>::New(bp->handle_);
#else // NODE_VERSION
//SlowBuffer
//node::Buffer *bp = node::Buffer::New(field_value, field_length);
js_field = Local<Value>::New(node::Buffer::New(V8STR2(field_value, field_length)));
#endif // NODE_VERSION
#else // NODE_VERSION
// SlowBuffer
// node::Buffer *bp = node::Buffer::New(field_value,
// field_length);
js_field = Local<Value>::New(
node::Buffer::New(
V8STR2(field_value, field_length)));
#endif // NODE_VERSION
} else {
js_field = V8STR2(field_value, field_length);
}
Expand Down Expand Up @@ -395,7 +400,9 @@ int MysqlResult::EIO_After_FetchAll(eio_req *req) {
}

for (j = 0; j < num_fields; j++) {
js_field = GetFieldValue(fields[j], result_row[j], field_lengths[j]);
js_field = GetFieldValue(fields[j],
result_row[j],
field_lengths[j]);
if (fetchAll_req->results_array) {
js_result_row->Set(Integer::NewFromUnsigned(j), js_field);
} else {
Expand Down Expand Up @@ -604,7 +611,9 @@ Handle<Value> MysqlResult::FetchAllSync(const Arguments& args) {
}

for (j = 0; j < num_fields; j++) {
js_field = GetFieldValue(fields[j], result_row[j], field_lengths[j]);
js_field = GetFieldValue(fields[j],
result_row[j],
field_lengths[j]);
if (results_array) {
js_result_row->Set(Integer::NewFromUnsigned(j), js_field);
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/mysql_bindings_result.h
Expand Up @@ -52,7 +52,9 @@ class MysqlResult : public node::EventEmitter {
Local<Object> &js_field_obj,
MYSQL_FIELD *field);

static Local<Value> GetFieldValue(MYSQL_FIELD field, char* field_value, unsigned long field_length);
static Local<Value> GetFieldValue(MYSQL_FIELD field,
char* field_value,
unsigned long field_length);

void Free();

Expand Down
1 change: 1 addition & 0 deletions tests/complex/test-binary-buffers.js
Expand Up @@ -66,3 +66,4 @@ exports.FetchAllSyncWithBinaryFields = function (test) {
conn.closeSync();
test.done();
};

2 changes: 1 addition & 1 deletion tests/complex/test-fetchAll.js
Expand Up @@ -341,5 +341,5 @@ exports.setOptionSyncQueryFetchAll = function (test) {
test.done();
});
});
}
};

0 comments on commit dd1c69e

Please sign in to comment.