{"action":"closed","number":63,"pull_request":{"url":"https://api.github.com/repos/digitalbitbox/mcu/pulls/63","id":45634080,"html_url":"https://github.com/digitalbitbox/mcu/pull/63","diff_url":"https://github.com/digitalbitbox/mcu/pull/63.diff","patch_url":"https://github.com/digitalbitbox/mcu/pull/63.patch","issue_url":"https://api.github.com/repos/digitalbitbox/mcu/issues/63","number":63,"state":"closed","locked":false,"title":"house cleaning, add error codes","user":{"login":"dbitbox","id":7711591,"avatar_url":"https://avatars.githubusercontent.com/u/7711591?v=3","gravatar_id":"","url":"https://api.github.com/users/dbitbox","html_url":"https://github.com/dbitbox","followers_url":"https://api.github.com/users/dbitbox/followers","following_url":"https://api.github.com/users/dbitbox/following{/other_user}","gists_url":"https://api.github.com/users/dbitbox/gists{/gist_id}","starred_url":"https://api.github.com/users/dbitbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbitbox/subscriptions","organizations_url":"https://api.github.com/users/dbitbox/orgs","repos_url":"https://api.github.com/users/dbitbox/repos","events_url":"https://api.github.com/users/dbitbox/events{/privacy}","received_events_url":"https://api.github.com/users/dbitbox/received_events","type":"User","site_admin":false},"body":"#### Add error codes; fixes #51. \r\n\r\nFor example:\r\n\r\n**send**\r\n```\r\n{ \"password\": \"abc\" }\r\n```\r\n\r\n**reply**\r\n```\r\n{\r\n\"error\": \r\n    {\r\n    \"message\": \"The password length must be at least 4 characters.\", \r\n    \"code\": 102,\r\n    \"command\": \"password\"\r\n    }\r\n}\r\n```\r\n\r\n**error codes** (a macro prefixes `DBB_` to each)\r\n```\r\n#define FLAG_TABLE \\\r\nX(ERR_IO_NO_PASSWORD,  101, \"Please set a password.\")\\\r\nX(ERR_IO_PASSWORD_LEN, 102, \"The password length must be at least \" STRINGIFY(PASSWORD_LEN_MIN) \" characters.\")\\\r\nX(ERR_IO_NO_INPUT,     103, \"No input received.\")\\\r\nX(ERR_IO_INVALID_CMD,  104, \"Invalid command.\")\\\r\nX(ERR_IO_MULT_CMD,     105, \"Only one command allowed at a time.\")\\\r\nX(ERR_IO_DATA_LEN,     106, \"Data must be less than \" STRINGIFY(AES_DATA_LEN_MAX)\" characters.\")\\\r\nX(ERR_IO_REPORT_BUF,   107, \"Output buffer overflow.\")\\\r\nX(ERR_IO_DECRYPT,      108, \"Could not decrypt.\")\\\r\nX(ERR_IO_JSON_PARSE,   109, \"JSON parse error.\")\\\r\nX(ERR_IO_RESET,        110, \"Too many failed access attempts. Device reset.\")\\\r\nX(ERR_IO_LOCKED,       111, \"Device locked. Erase device to access this command.\")\\\r\nX(ERR_SEED_SD,         200, \"Seed creation requires an SD card for automatic encrypted backup of the seed.\")\\\r\nX(ERR_SEED_SD_NUM,     201, \"Too many backup files. Please remove one from the SD card.\")\\\r\nX(ERR_SEED_MEM,        202, \"Could not allocate memory for seed.\")\\\r\nX(ERR_SEED_SALT_LEN,   203, \"Salt must be less than \" STRINGIFY(SALT_LEN_MAX) \" characters.\")\\\r\nX(ERR_SEED_INVALID,    204, \"Invalid seed.\")\\\r\nX(ERR_KEY_MASTER,      250, \"Master key not present.\")\\\r\nX(ERR_KEY_CHILD,       251, \"Could not generate key.\")\\\r\nX(ERR_SIGN_ADDR_LEN,   300, \"Incorrect address length. A 34 character address is expected.\")\\\r\nX(ERR_SIGN_HASH_LEN,   301, \"Incorrect hash length. A 32-byte hexadecimal value (64 characters) is expected.\")\\\r\nX(ERR_SIGN_DESERIAL,   302, \"Could not deserialize outputs or wrong change keypath.\")\\\r\nX(ERR_SIGN_ECCLIB,     303, \"Could not sign.\")\\\r\nX(ERR_SD_CARD,         400, \"Please insert SD card.\")\\\r\nX(ERR_SD_MOUNT,        401, \"Could not mount the SD card.\")\\\r\nX(ERR_SD_OPEN_FILE,    402, \"Could not open a file to write - it may already exist.\")\\\r\nX(ERR_SD_OPEN_DIR,     403, \"Could not open the directory.\")\\\r\nX(ERR_SD_CORRUPT_FILE, 404, \"Corrupted file.\")\\\r\nX(ERR_SD_WRITE_FILE,   405, \"Could not write the file.\")\\\r\nX(ERR_SD_WRITE_LEN,    406, \"Text to write is too large.\")\\\r\nX(ERR_SD_READ_FILE,    407, \"Could not read the file.\")\\\r\nX(ERR_SD_ERASE,        408, \"May not have erased all files (or no file present).\")\\\r\nX(ERR_SD_NUM_FILES,    409, \"Too many files to read. The list is truncated.\")\\\r\nX(ERR_MEM_ATAES,       500, \"Chip communication error.\")\\\r\nX(ERR_MEM_FLASH,       501, \"Could not read flash.\")\\\r\nX(ERR_MEM_ENCRYPT,     502, \"Could not encrypt.\")\\\r\nX(WARN_RESET,          900, \"attempts remain before the device is reset.\")\\\r\nX(WARN_NO_MCU,         901, \"Ignored for non-embedded testing.\")\\\r\nX(FLAG_NUM,              0, 0)/* keep last */\r\n```\r\n\r\n#### Test coverage\r\n- cmake option enables compilation with test coverage flags \r\n- increased test coverage in general\r\n- use `utest.h` macros in `tests_api` (already used in `tests_unit`)(better readability and easier to update)\r\n\r\n\r\n#### General house cleaning\r\n- improve code consistency and efficiency\r\n- fix white space\r\n- use snprintf instead of sprintf or memcpy when possible\r\n- use [X macros](http://www.drdobbs.com/the-new-c-x-macros/184401387) in `flags.h` `flags.c` \r\n\r\n\r\n","created_at":"2015-09-22T07:36:51Z","updated_at":"2015-09-27T09:58:09Z","closed_at":"2015-09-27T09:58:09Z","merged_at":"2015-09-27T09:58:09Z","merge_commit_sha":"0cca0ec9bf9ba92f2000169486897a8d69466bbf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/digitalbitbox/mcu/pulls/63/commits","review_comments_url":"https://api.github.com/repos/digitalbitbox/mcu/pulls/63/comments","review_comment_url":"https://api.github.com/repos/digitalbitbox/mcu/pulls/comments{/number}","comments_url":"https://api.github.com/repos/digitalbitbox/mcu/issues/63/comments","statuses_url":"https://api.github.com/repos/digitalbitbox/mcu/statuses/35726553c58e85dd257d798de644c1fdf2ef32e2","head":{"label":"dbitbox:cleaning","ref":"cleaning","sha":"35726553c58e85dd257d798de644c1fdf2ef32e2","user":{"login":"dbitbox","id":7711591,"avatar_url":"https://avatars.githubusercontent.com/u/7711591?v=3","gravatar_id":"","url":"https://api.github.com/users/dbitbox","html_url":"https://github.com/dbitbox","followers_url":"https://api.github.com/users/dbitbox/followers","following_url":"https://api.github.com/users/dbitbox/following{/other_user}","gists_url":"https://api.github.com/users/dbitbox/gists{/gist_id}","starred_url":"https://api.github.com/users/dbitbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbitbox/subscriptions","organizations_url":"https://api.github.com/users/dbitbox/orgs","repos_url":"https://api.github.com/users/dbitbox/repos","events_url":"https://api.github.com/users/dbitbox/events{/privacy}","received_events_url":"https://api.github.com/users/dbitbox/received_events","type":"User","site_admin":false},"repo":{"id":38921021,"name":"mcu","full_name":"dbitbox/mcu","owner":{"login":"dbitbox","id":7711591,"avatar_url":"https://avatars.githubusercontent.com/u/7711591?v=3","gravatar_id":"","url":"https://api.github.com/users/dbitbox","html_url":"https://github.com/dbitbox","followers_url":"https://api.github.com/users/dbitbox/followers","following_url":"https://api.github.com/users/dbitbox/following{/other_user}","gists_url":"https://api.github.com/users/dbitbox/gists{/gist_id}","starred_url":"https://api.github.com/users/dbitbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbitbox/subscriptions","organizations_url":"https://api.github.com/users/dbitbox/orgs","repos_url":"https://api.github.com/users/dbitbox/repos","events_url":"https://api.github.com/users/dbitbox/events{/privacy}","received_events_url":"https://api.github.com/users/dbitbox/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dbitbox/mcu","description":"MCU code for the Digital Bitbox hardware wallet","fork":true,"url":"https://api.github.com/repos/dbitbox/mcu","forks_url":"https://api.github.com/repos/dbitbox/mcu/forks","keys_url":"https://api.github.com/repos/dbitbox/mcu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dbitbox/mcu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dbitbox/mcu/teams","hooks_url":"https://api.github.com/repos/dbitbox/mcu/hooks","issue_events_url":"https://api.github.com/repos/dbitbox/mcu/issues/events{/number}","events_url":"https://api.github.com/repos/dbitbox/mcu/events","assignees_url":"https://api.github.com/repos/dbitbox/mcu/assignees{/user}","branches_url":"https://api.github.com/repos/dbitbox/mcu/branches{/branch}","tags_url":"https://api.github.com/repos/dbitbox/mcu/tags","blobs_url":"https://api.github.com/repos/dbitbox/mcu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dbitbox/mcu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dbitbox/mcu/git/refs{/sha}","trees_url":"https://api.github.com/repos/dbitbox/mcu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dbitbox/mcu/statuses/{sha}","languages_url":"https://api.github.com/repos/dbitbox/mcu/languages","stargazers_url":"https://api.github.com/repos/dbitbox/mcu/stargazers","contributors_url":"https://api.github.com/repos/dbitbox/mcu/contributors","subscribers_url":"https://api.github.com/repos/dbitbox/mcu/subscribers","subscription_url":"https://api.github.com/repos/dbitbox/mcu/subscription","commits_url":"https://api.github.com/repos/dbitbox/mcu/commits{/sha}","git_commits_url":"https://api.github.com/repos/dbitbox/mcu/git/commits{/sha}","comments_url":"https://api.github.com/repos/dbitbox/mcu/comments{/number}","issue_comment_url":"https://api.github.com/repos/dbitbox/mcu/issues/comments{/number}","contents_url":"https://api.github.com/repos/dbitbox/mcu/contents/{+path}","compare_url":"https://api.github.com/repos/dbitbox/mcu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dbitbox/mcu/merges","archive_url":"https://api.github.com/repos/dbitbox/mcu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dbitbox/mcu/downloads","issues_url":"https://api.github.com/repos/dbitbox/mcu/issues{/number}","pulls_url":"https://api.github.com/repos/dbitbox/mcu/pulls{/number}","milestones_url":"https://api.github.com/repos/dbitbox/mcu/milestones{/number}","notifications_url":"https://api.github.com/repos/dbitbox/mcu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dbitbox/mcu/labels{/name}","releases_url":"https://api.github.com/repos/dbitbox/mcu/releases{/id}","created_at":"2015-07-11T09:37:49Z","updated_at":"2015-07-11T09:37:50Z","pushed_at":"2015-09-27T09:55:57Z","git_url":"git://github.com/dbitbox/mcu.git","ssh_url":"git@github.com:dbitbox/mcu.git","clone_url":"https://github.com/dbitbox/mcu.git","svn_url":"https://github.com/dbitbox/mcu","homepage":"","size":1279,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"digitalbitbox:master","ref":"master","sha":"58333f9c0738beb9e0319f71a4d21baa55113883","user":{"login":"digitalbitbox","id":12703801,"avatar_url":"https://avatars.githubusercontent.com/u/12703801?v=3","gravatar_id":"","url":"https://api.github.com/users/digitalbitbox","html_url":"https://github.com/digitalbitbox","followers_url":"https://api.github.com/users/digitalbitbox/followers","following_url":"https://api.github.com/users/digitalbitbox/following{/other_user}","gists_url":"https://api.github.com/users/digitalbitbox/gists{/gist_id}","starred_url":"https://api.github.com/users/digitalbitbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/digitalbitbox/subscriptions","organizations_url":"https://api.github.com/users/digitalbitbox/orgs","repos_url":"https://api.github.com/users/digitalbitbox/repos","events_url":"https://api.github.com/users/digitalbitbox/events{/privacy}","received_events_url":"https://api.github.com/users/digitalbitbox/received_events","type":"Organization","site_admin":false},"repo":{"id":28983102,"name":"mcu","full_name":"digitalbitbox/mcu","owner":{"login":"digitalbitbox","id":12703801,"avatar_url":"https://avatars.githubusercontent.com/u/12703801?v=3","gravatar_id":"","url":"https://api.github.com/users/digitalbitbox","html_url":"https://github.com/digitalbitbox","followers_url":"https://api.github.com/users/digitalbitbox/followers","following_url":"https://api.github.com/users/digitalbitbox/following{/other_user}","gists_url":"https://api.github.com/users/digitalbitbox/gists{/gist_id}","starred_url":"https://api.github.com/users/digitalbitbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/digitalbitbox/subscriptions","organizations_url":"https://api.github.com/users/digitalbitbox/orgs","repos_url":"https://api.github.com/users/digitalbitbox/repos","events_url":"https://api.github.com/users/digitalbitbox/events{/privacy}","received_events_url":"https://api.github.com/users/digitalbitbox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/digitalbitbox/mcu","description":"MCU code for the Digital Bitbox hardware wallet","fork":false,"url":"https://api.github.com/repos/digitalbitbox/mcu","forks_url":"https://api.github.com/repos/digitalbitbox/mcu/forks","keys_url":"https://api.github.com/repos/digitalbitbox/mcu/keys{/key_id}","collaborators_url":"https://api.github.com/repos/digitalbitbox/mcu/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/digitalbitbox/mcu/teams","hooks_url":"https://api.github.com/repos/digitalbitbox/mcu/hooks","issue_events_url":"https://api.github.com/repos/digitalbitbox/mcu/issues/events{/number}","events_url":"https://api.github.com/repos/digitalbitbox/mcu/events","assignees_url":"https://api.github.com/repos/digitalbitbox/mcu/assignees{/user}","branches_url":"https://api.github.com/repos/digitalbitbox/mcu/branches{/branch}","tags_url":"https://api.github.com/repos/digitalbitbox/mcu/tags","blobs_url":"https://api.github.com/repos/digitalbitbox/mcu/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/digitalbitbox/mcu/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/digitalbitbox/mcu/git/refs{/sha}","trees_url":"https://api.github.com/repos/digitalbitbox/mcu/git/trees{/sha}","statuses_url":"https://api.github.com/repos/digitalbitbox/mcu/statuses/{sha}","languages_url":"https://api.github.com/repos/digitalbitbox/mcu/languages","stargazers_url":"https://api.github.com/repos/digitalbitbox/mcu/stargazers","contributors_url":"https://api.github.com/repos/digitalbitbox/mcu/contributors","subscribers_url":"https://api.github.com/repos/digitalbitbox/mcu/subscribers","subscription_url":"https://api.github.com/repos/digitalbitbox/mcu/subscription","commits_url":"https://api.github.com/repos/digitalbitbox/mcu/commits{/sha}","git_commits_url":"https://api.github.com/repos/digitalbitbox/mcu/git/commits{/sha}","comments_url":"https://api.github.com/repos/digitalbitbox/mcu/comments{/number}","issue_comment_url":"https://api.github.com/repos/digitalbitbox/mcu/issues/comments{/number}","contents_url":"https://api.github.com/repos/digitalbitbox/mcu/contents/{+path}","compare_url":"https://api.github.com/repos/digitalbitbox/mcu/compare/{base}...{head}","merges_url":"https://api.github.com/repos/digitalbitbox/mcu/merges","archive_url":"https://api.github.com/repos/digitalbitbox/mcu/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/digitalbitbox/mcu/downloads","issues_url":"https://api.github.com/repos/digitalbitbox/mcu/issues{/number}","pulls_url":"https://api.github.com/repos/digitalbitbox/mcu/pulls{/number}","milestones_url":"https://api.github.com/repos/digitalbitbox/mcu/milestones{/number}","notifications_url":"https://api.github.com/repos/digitalbitbox/mcu/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/digitalbitbox/mcu/labels{/name}","releases_url":"https://api.github.com/repos/digitalbitbox/mcu/releases{/id}","created_at":"2015-01-08T19:51:09Z","updated_at":"2015-07-12T18:21:34Z","pushed_at":"2015-09-27T09:58:09Z","git_url":"git://github.com/digitalbitbox/mcu.git","ssh_url":"git@github.com:digitalbitbox/mcu.git","clone_url":"https://github.com/digitalbitbox/mcu.git","svn_url":"https://github.com/digitalbitbox/mcu","homepage":"","size":1921,"stargazers_count":6,"watchers_count":6,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/digitalbitbox/mcu/pulls/63"},"html":{"href":"https://github.com/digitalbitbox/mcu/pull/63"},"issue":{"href":"https://api.github.com/repos/digitalbitbox/mcu/issues/63"},"comments":{"href":"https://api.github.com/repos/digitalbitbox/mcu/issues/63/comments"},"review_comments":{"href":"https://api.github.com/repos/digitalbitbox/mcu/pulls/63/comments"},"review_comment":{"href":"https://api.github.com/repos/digitalbitbox/mcu/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/digitalbitbox/mcu/pulls/63/commits"},"statuses":{"href":"https://api.github.com/repos/digitalbitbox/mcu/statuses/35726553c58e85dd257d798de644c1fdf2ef32e2"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"dbitbox","id":7711591,"avatar_url":"https://avatars.githubusercontent.com/u/7711591?v=3","gravatar_id":"","url":"https://api.github.com/users/dbitbox","html_url":"https://github.com/dbitbox","followers_url":"https://api.github.com/users/dbitbox/followers","following_url":"https://api.github.com/users/dbitbox/following{/other_user}","gists_url":"https://api.github.com/users/dbitbox/gists{/gist_id}","starred_url":"https://api.github.com/users/dbitbox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbitbox/subscriptions","organizations_url":"https://api.github.com/users/dbitbox/orgs","repos_url":"https://api.github.com/users/dbitbox/repos","events_url":"https://api.github.com/users/dbitbox/events{/privacy}","received_events_url":"https://api.github.com/users/dbitbox/received_events","type":"User","site_admin":false},"comments":3,"review_comments":0,"commits":1,"additions":1890,"deletions":2098,"changed_files":35}}