Skip to content

Commit

Permalink
oc-payload.cc: fix signed/unsigned char issues
Browse files Browse the repository at this point in the history
When char == signed char, conversion to and from uint_8 fails in some
places. Started to happen recently in Ostro OS, perhaps because of a
compiler update.

The conversion of sid is straightforward.

OCSecurityPayload->securityData is less obvious: it is an uint_8
pointer, which seems to end up getting converted to a boolean instead
of a character string. The typecast unfortunately has to be done
inside the macro, reducing its type safety.

../src/structures/oc-payload.cc: In function 'v8::Local<v8::Object> js_OCDiscoveryPayload(OCDiscoveryPayload*)':
../src/structures/oc-payload.cc:240:30: error: invalid conversion from 'char*' to 'uint8_t* {aka unsigned char*}' [-fpermissive]
              js_SID(payload->sid));

In file included from ../src/structures/oc-payload.cc:18:0:
../src/structures/oc-payload.cc: In function 'v8::Local<v8::Object> js_OCSecurityPayload(OCSecurityPayload*)':
../src/structures/../common.h:63:45: error: 'Nan::imp::FactoryBase<v8::Boolean>::return_t {aka class v8::Local<v8::Boolean>}' has no member named 'ToLocalChecked'
              Nan::New((source)->memberName).ToLocalChecked());      \
                                             ^
../src/structures/oc-payload.cc:312:3: note: in expansion of macro 'SET_STRING_IF_NOT_NULL'
   SET_STRING_IF_NOT_NULL(returnValue, payload, securityData);

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
  • Loading branch information
pohly committed May 9, 2016
1 parent 38f7679 commit abe2ce9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
#define SET_STRING_IF_NOT_NULL(destination, source, memberName) \
if ((source)->memberName) { \
Nan::Set((destination), Nan::New(#memberName).ToLocalChecked(), \
Nan::New((source)->memberName).ToLocalChecked()); \
Nan::New(reinterpret_cast<const char *>((source)->memberName)).ToLocalChecked()); \
}

#define SET_VALUE_ON_OBJECT(destination, type, source, memberName) \
Expand Down
4 changes: 2 additions & 2 deletions src/structures/oc-payload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ static Local<Object> js_OCDiscoveryPayload(OCDiscoveryPayload *payload) {

if (payload->sid) {
Nan::Set(returnValue, Nan::New("sid").ToLocalChecked(),
js_SID(payload->sid));
js_SID(reinterpret_cast<unsigned char *>(payload->sid)));
}

// Count the resources
Expand Down Expand Up @@ -266,7 +266,7 @@ static Local<Object> js_OCDevicePayload(OCDevicePayload *payload) {

if (payload->sid) {
Nan::Set(returnValue, Nan::New("sid").ToLocalChecked(),
js_SID(payload->sid));
js_SID(reinterpret_cast<unsigned char *>(payload->sid)));
}

SET_STRING_IF_NOT_NULL(returnValue, payload, deviceName);
Expand Down

0 comments on commit abe2ce9

Please sign in to comment.