Closed
Bug 972248
Opened 11 years ago
Closed 11 years ago
[B2F][NFC] : nfcd should using error code instead of boolean
Categories
(Firefox OS Graveyard :: NFC, defect)
Tracking
(feature-b2g:2.0, tracking-b2g:backlog)
RESOLVED
FIXED
People
(Reporter: dimi, Assigned: dimi)
References
Details
Attachments
(1 file, 6 obsolete files)
Many API in NFC daemon now only return boolean to represent success or fail.
It would be better return error code instead of boolean
Blocks: b2g-nfc
Updated•11 years ago
|
Blocks: b2g-NFC-2.0
Updated•11 years ago
|
blocking-b2g: --- → backlog
Blocks: 933595
Comment 1•11 years ago
|
||
Hi, I understand the error codes will be the ones defined in Bug 897312.
https://bugzilla.mozilla.org/attachment.cgi?id=831587
Assignee | ||
Comment 2•11 years ago
|
||
Hi Yoshi.
This is draft version of using error code, could you help check if you think the error code provided in this version is ok or you think nfcd should provide more detail error code. Thanks!
Attachment #8415161 -
Flags: feedback?(allstars.chh)
Comment on attachment 8415161 [details] [diff] [review]
WIP Patch v1
Review of attachment 8415161 [details] [diff] [review]:
-----------------------------------------------------------------
::: src/NfcGonkMessage.h
@@ +55,5 @@
> + NFC_ERROR_INITIALIZE_FAIL = 8,
> + NFC_ERROR_DEINITIALIZE_FAIL = 9,
> + NFC_ERROR_COULD_NOT_ENABLE_DISCOVERY = 10,
> + NFC_ERROR_COULD_NOT_DISABLE_DISCOVERY = 11,
> + NFC_ERROR_COULD_NOT_CONNECAT_TAG = 12,
CONNECT
@@ +57,5 @@
> + NFC_ERROR_COULD_NOT_ENABLE_DISCOVERY = 10,
> + NFC_ERROR_COULD_NOT_DISABLE_DISCOVERY = 11,
> + NFC_ERROR_COULD_NOT_CONNECAT_TAG = 12,
> + NFC_ERROR_COULD_NOT_WRITE_TAG = 13,
> + NFC_ERROR_COULD_NOT_MAKE_TAG_READ_ONLY = 14
Bug 897312 has already defined some error code, can we reuse them?
::: src/NfcService.cpp
@@ +65,5 @@
> static sem_t thread_sem;
>
> +#define CHECK_ERR_RTN(sta, err) \
> + if (sta) { \
> + mMsgHandler->processResponse(res, err, NULL); \
Not sure if this is a good macro,
1. We need to define 'res' when calling this macro, and the naming in Mozilla is usually .._ENSURE_...
2. Also usually we need to align \.
3. Usually we need to wrap it with do{} while(0) so caller can add semicolon and can prevent
if (foo)
CHECK_ERR_RTN
else
...
proble,
::: src/NfcUtil.h
@@ +10,5 @@
> #include "NfcGonkMessage.h"
> #include "TagTechnology.h"
>
> +#define SUCCESSED(result) (result == NFC_SUCCESS)
> +#define FAILED(result) (result != NFC_SUCCESS)
These two macros doesn't bring much advantage.
If you'd like to use it, seems one is enough.
SUCCEED(result) ((result) == NFC_SUCCESS)
Attachment #8415161 -
Flags: feedback?(allstars.chh)
Assignee | ||
Comment 4•11 years ago
|
||
(In reply to Yoshi Huang[:allstars.chh] from comment #3)
> Comment on attachment 8415161 [details] [diff] [review]
> WIP Patch v1
>
> Review of attachment 8415161 [details] [diff] [review]:
> -----------------------------------------------------------------
> @@ +57,5 @@
> > + NFC_ERROR_COULD_NOT_ENABLE_DISCOVERY = 10,
> > + NFC_ERROR_COULD_NOT_DISABLE_DISCOVERY = 11,
> > + NFC_ERROR_COULD_NOT_CONNECAT_TAG = 12,
> > + NFC_ERROR_COULD_NOT_WRITE_TAG = 13,
> > + NFC_ERROR_COULD_NOT_MAKE_TAG_READ_ONLY = 14
>
> Bug 897312 has already defined some error code, can we reuse them?
>
I will re-use them in next version but still i'll add some more error code because this is not sufficient.
Assignee | ||
Comment 5•11 years ago
|
||
Following Error code is modified:
NFC_ERROR_NFC_OFF = ‐18,
NFC_ERROR_NFC_DISCOVERY_ON = ‐19,
NFC_ERROR_NFC_DISCOVERY_OFF = ‐20,
NFC_ERROR_NFC_ENABLE_DISCOVERY = ‐21,
NFC_ERROR_NFC_DISABLE_DISCOVERY = ‐22,
Most of the error code value in (v1.9) Nfcd/Gonk Protocol Specification is also changed.
Attachment #8415161 -
Attachment is obsolete: true
Attachment #8417222 -
Flags: review?(allstars.chh)
Comment on attachment 8417222 [details] [review]
NFCD use error code patch v1
see comments on the github
Attachment #8417222 -
Flags: review?(allstars.chh)
Assignee | ||
Comment 7•11 years ago
|
||
1.Update yoshi's review comment
2.Update following error code definition
* NFC_ERROR_NFC_ON -> NFC_ERROR_NFC_ALREADY_ON
* NFC_ERROR_NFC_OFF -> NFC_ERROR_NFC_ALREADY_OFF
* Add NFC_ERROR_ALREADY_DISCOVERY_ON
* Add NFC_ERROR_ALREADY_DISCOVERY_OFF
* Add NFC_ERROR_INITIALIZE_FAIL
* Add NFC_ERROR_DEINITIALIZE_FAIL
Attachment #8417222 -
Attachment is obsolete: true
Attachment #8417297 -
Flags: review?(allstars.chh)
Assignee | ||
Comment 8•11 years ago
|
||
Attachment #8417297 -
Attachment is obsolete: true
Attachment #8417297 -
Flags: review?(allstars.chh)
Attachment #8417298 -
Flags: review?(allstars.chh)
Comment on attachment 8417298 [details] [review]
NFCD use error code patch v2
basically ok, but I'd like to make code shorter and review this again.
Attachment #8417298 -
Flags: review?(allstars.chh)
Assignee | ||
Comment 10•11 years ago
|
||
Update code according to yoshi's suggestion
Attachment #8417298 -
Attachment is obsolete: true
Attachment #8417855 -
Flags: review?(allstars.chh)
Comment on attachment 8417855 [details] [review]
NFCD use error code patch v3
see github for some nits
Attachment #8417855 -
Flags: review?(allstars.chh) → review+
Assignee | ||
Comment 12•11 years ago
|
||
Hi Yoshi,
I have made some modification for Patch v3 according to suggestion, could you help review again ? Thanks.
If you are ok with this, i will create another pull request
Attachment #8417873 -
Flags: review?(allstars.chh)
Attachment #8417873 -
Flags: review?(allstars.chh) → review+
Assignee | ||
Comment 13•11 years ago
|
||
Attachment #8417855 -
Attachment is obsolete: true
Attachment #8417873 -
Attachment is obsolete: true
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Depends on: 1008109
Updated•11 years ago
|
feature-b2g: --- → 2.0
Updated•11 years ago
|
Flags: in-moztrap-
Updated•10 years ago
|
blocking-b2g: backlog → ---
tracking-b2g:
--- → backlog
You need to log in
before you can comment on or make changes to this bug.
Description
•