{"action":"opened","number":6609,"pull_request":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/pulls/6609","id":181039466,"html_url":"https://github.com/ARMmbed/mbed-os/pull/6609","diff_url":"https://github.com/ARMmbed/mbed-os/pull/6609.diff","patch_url":"https://github.com/ARMmbed/mbed-os/pull/6609.patch","issue_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6609","number":6609,"state":"open","locked":false,"title":"STM32 PCD negative numbers issue","user":{"login":"pauluap","id":573966,"avatar_url":"https://avatars3.githubusercontent.com/u/573966?v=4","gravatar_id":"","url":"https://api.github.com/users/pauluap","html_url":"https://github.com/pauluap","followers_url":"https://api.github.com/users/pauluap/followers","following_url":"https://api.github.com/users/pauluap/following{/other_user}","gists_url":"https://api.github.com/users/pauluap/gists{/gist_id}","starred_url":"https://api.github.com/users/pauluap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pauluap/subscriptions","organizations_url":"https://api.github.com/users/pauluap/orgs","repos_url":"https://api.github.com/users/pauluap/repos","events_url":"https://api.github.com/users/pauluap/events{/privacy}","received_events_url":"https://api.github.com/users/pauluap/received_events","type":"User","site_admin":false},"body":"\r\n### Description\r\n\r\nThis issue was initiated by a compiler warning\r\n```\r\nCompile: stm32f7xx_hal_pcd.c\r\n../targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_pcd.c: In function 'PCD_WriteEmptyTxFifo':\r\n../targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_pcd.c:1310:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]\r\n   if (len > ep->maxpacket)\r\n           ^\r\n../targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_pcd.c:1325:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]\r\n     if (len > ep->maxpacket)\r\n             ^\r\n```\r\n\r\nMy first pass at fixing this issue concentrated on the comparison itself.  The implementation can be seen at https://github.com/pauluap/mbed-os/commit/c6ca03df764a16b4a36e5598f881acf601fb9b0f\r\n\r\nUpon inspection, I determined that there were further problems \r\n\r\nhttps://github.com/pauluap/mbed-os/blob/c6ca03df764a16b4a36e5598f881acf601fb9b0f/targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_pcd.c#L1318\r\nThe line   `len32b = (len + 3) / 4;` (and an identical one a bit further on) could end up negative even if the warning message was cleaned up.\r\n\r\nAfter thinking about it for a while, I observed that the magnitude of a negative length wasn't important, the essential point is to guard the algorithm from processing negative numbers, so I refactored to make the guard operation more evident and eliminate the need for an signed integer variable.\r\n\r\n@jeromecoutant, this is related to https://github.com/ARMmbed/mbed-os/pull/6599\r\n\r\n### Pull request type\r\n\r\n[X ] Fix  \r\n[ ] Refactor  \r\n[ ] New target  \r\n[ ] Feature  \r\n[ ] Breaking change\r\n","created_at":"2018-04-11T21:57:26Z","updated_at":"2018-04-11T21:57:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ARMmbed/mbed-os/pulls/6609/commits","review_comments_url":"https://api.github.com/repos/ARMmbed/mbed-os/pulls/6609/comments","review_comment_url":"https://api.github.com/repos/ARMmbed/mbed-os/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6609/comments","statuses_url":"https://api.github.com/repos/ARMmbed/mbed-os/statuses/dcd1a3ed2a756a02c7ac8acf2984d280e7f0b9fc","head":{"label":"pauluap:compiler_warning_pcd_unsigned_signed","ref":"compiler_warning_pcd_unsigned_signed","sha":"dcd1a3ed2a756a02c7ac8acf2984d280e7f0b9fc","user":{"login":"pauluap","id":573966,"avatar_url":"https://avatars3.githubusercontent.com/u/573966?v=4","gravatar_id":"","url":"https://api.github.com/users/pauluap","html_url":"https://github.com/pauluap","followers_url":"https://api.github.com/users/pauluap/followers","following_url":"https://api.github.com/users/pauluap/following{/other_user}","gists_url":"https://api.github.com/users/pauluap/gists{/gist_id}","starred_url":"https://api.github.com/users/pauluap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pauluap/subscriptions","organizations_url":"https://api.github.com/users/pauluap/orgs","repos_url":"https://api.github.com/users/pauluap/repos","events_url":"https://api.github.com/users/pauluap/events{/privacy}","received_events_url":"https://api.github.com/users/pauluap/received_events","type":"User","site_admin":false},"repo":{"id":123317870,"name":"mbed-os","full_name":"pauluap/mbed-os","owner":{"login":"pauluap","id":573966,"avatar_url":"https://avatars3.githubusercontent.com/u/573966?v=4","gravatar_id":"","url":"https://api.github.com/users/pauluap","html_url":"https://github.com/pauluap","followers_url":"https://api.github.com/users/pauluap/followers","following_url":"https://api.github.com/users/pauluap/following{/other_user}","gists_url":"https://api.github.com/users/pauluap/gists{/gist_id}","starred_url":"https://api.github.com/users/pauluap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pauluap/subscriptions","organizations_url":"https://api.github.com/users/pauluap/orgs","repos_url":"https://api.github.com/users/pauluap/repos","events_url":"https://api.github.com/users/pauluap/events{/privacy}","received_events_url":"https://api.github.com/users/pauluap/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pauluap/mbed-os","description":"ARM Mbed OS is a platform operating system designed for the internet of things","fork":true,"url":"https://api.github.com/repos/pauluap/mbed-os","forks_url":"https://api.github.com/repos/pauluap/mbed-os/forks","keys_url":"https://api.github.com/repos/pauluap/mbed-os/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pauluap/mbed-os/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pauluap/mbed-os/teams","hooks_url":"https://api.github.com/repos/pauluap/mbed-os/hooks","issue_events_url":"https://api.github.com/repos/pauluap/mbed-os/issues/events{/number}","events_url":"https://api.github.com/repos/pauluap/mbed-os/events","assignees_url":"https://api.github.com/repos/pauluap/mbed-os/assignees{/user}","branches_url":"https://api.github.com/repos/pauluap/mbed-os/branches{/branch}","tags_url":"https://api.github.com/repos/pauluap/mbed-os/tags","blobs_url":"https://api.github.com/repos/pauluap/mbed-os/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pauluap/mbed-os/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pauluap/mbed-os/git/refs{/sha}","trees_url":"https://api.github.com/repos/pauluap/mbed-os/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pauluap/mbed-os/statuses/{sha}","languages_url":"https://api.github.com/repos/pauluap/mbed-os/languages","stargazers_url":"https://api.github.com/repos/pauluap/mbed-os/stargazers","contributors_url":"https://api.github.com/repos/pauluap/mbed-os/contributors","subscribers_url":"https://api.github.com/repos/pauluap/mbed-os/subscribers","subscription_url":"https://api.github.com/repos/pauluap/mbed-os/subscription","commits_url":"https://api.github.com/repos/pauluap/mbed-os/commits{/sha}","git_commits_url":"https://api.github.com/repos/pauluap/mbed-os/git/commits{/sha}","comments_url":"https://api.github.com/repos/pauluap/mbed-os/comments{/number}","issue_comment_url":"https://api.github.com/repos/pauluap/mbed-os/issues/comments{/number}","contents_url":"https://api.github.com/repos/pauluap/mbed-os/contents/{+path}","compare_url":"https://api.github.com/repos/pauluap/mbed-os/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pauluap/mbed-os/merges","archive_url":"https://api.github.com/repos/pauluap/mbed-os/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pauluap/mbed-os/downloads","issues_url":"https://api.github.com/repos/pauluap/mbed-os/issues{/number}","pulls_url":"https://api.github.com/repos/pauluap/mbed-os/pulls{/number}","milestones_url":"https://api.github.com/repos/pauluap/mbed-os/milestones{/number}","notifications_url":"https://api.github.com/repos/pauluap/mbed-os/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pauluap/mbed-os/labels{/name}","releases_url":"https://api.github.com/repos/pauluap/mbed-os/releases{/id}","deployments_url":"https://api.github.com/repos/pauluap/mbed-os/deployments","created_at":"2018-02-28T17:24:30Z","updated_at":"2018-02-28T17:26:00Z","pushed_at":"2018-04-11T21:41:57Z","git_url":"git://github.com/pauluap/mbed-os.git","ssh_url":"git@github.com:pauluap/mbed-os.git","clone_url":"https://github.com/pauluap/mbed-os.git","svn_url":"https://github.com/pauluap/mbed-os","homepage":"https://mbed.com","size":201458,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ARMmbed:mbed-os-5.8","ref":"mbed-os-5.8","sha":"f9ee4e849f8cbd64f1ec5fdd4ad256585a208360","user":{"login":"ARMmbed","id":8916057,"avatar_url":"https://avatars3.githubusercontent.com/u/8916057?v=4","gravatar_id":"","url":"https://api.github.com/users/ARMmbed","html_url":"https://github.com/ARMmbed","followers_url":"https://api.github.com/users/ARMmbed/followers","following_url":"https://api.github.com/users/ARMmbed/following{/other_user}","gists_url":"https://api.github.com/users/ARMmbed/gists{/gist_id}","starred_url":"https://api.github.com/users/ARMmbed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARMmbed/subscriptions","organizations_url":"https://api.github.com/users/ARMmbed/orgs","repos_url":"https://api.github.com/users/ARMmbed/repos","events_url":"https://api.github.com/users/ARMmbed/events{/privacy}","received_events_url":"https://api.github.com/users/ARMmbed/received_events","type":"Organization","site_admin":false},"repo":{"id":8270972,"name":"mbed-os","full_name":"ARMmbed/mbed-os","owner":{"login":"ARMmbed","id":8916057,"avatar_url":"https://avatars3.githubusercontent.com/u/8916057?v=4","gravatar_id":"","url":"https://api.github.com/users/ARMmbed","html_url":"https://github.com/ARMmbed","followers_url":"https://api.github.com/users/ARMmbed/followers","following_url":"https://api.github.com/users/ARMmbed/following{/other_user}","gists_url":"https://api.github.com/users/ARMmbed/gists{/gist_id}","starred_url":"https://api.github.com/users/ARMmbed/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ARMmbed/subscriptions","organizations_url":"https://api.github.com/users/ARMmbed/orgs","repos_url":"https://api.github.com/users/ARMmbed/repos","events_url":"https://api.github.com/users/ARMmbed/events{/privacy}","received_events_url":"https://api.github.com/users/ARMmbed/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ARMmbed/mbed-os","description":"ARM Mbed OS is a platform operating system designed for the internet of things","fork":false,"url":"https://api.github.com/repos/ARMmbed/mbed-os","forks_url":"https://api.github.com/repos/ARMmbed/mbed-os/forks","keys_url":"https://api.github.com/repos/ARMmbed/mbed-os/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ARMmbed/mbed-os/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ARMmbed/mbed-os/teams","hooks_url":"https://api.github.com/repos/ARMmbed/mbed-os/hooks","issue_events_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/events{/number}","events_url":"https://api.github.com/repos/ARMmbed/mbed-os/events","assignees_url":"https://api.github.com/repos/ARMmbed/mbed-os/assignees{/user}","branches_url":"https://api.github.com/repos/ARMmbed/mbed-os/branches{/branch}","tags_url":"https://api.github.com/repos/ARMmbed/mbed-os/tags","blobs_url":"https://api.github.com/repos/ARMmbed/mbed-os/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ARMmbed/mbed-os/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ARMmbed/mbed-os/git/refs{/sha}","trees_url":"https://api.github.com/repos/ARMmbed/mbed-os/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ARMmbed/mbed-os/statuses/{sha}","languages_url":"https://api.github.com/repos/ARMmbed/mbed-os/languages","stargazers_url":"https://api.github.com/repos/ARMmbed/mbed-os/stargazers","contributors_url":"https://api.github.com/repos/ARMmbed/mbed-os/contributors","subscribers_url":"https://api.github.com/repos/ARMmbed/mbed-os/subscribers","subscription_url":"https://api.github.com/repos/ARMmbed/mbed-os/subscription","commits_url":"https://api.github.com/repos/ARMmbed/mbed-os/commits{/sha}","git_commits_url":"https://api.github.com/repos/ARMmbed/mbed-os/git/commits{/sha}","comments_url":"https://api.github.com/repos/ARMmbed/mbed-os/comments{/number}","issue_comment_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/comments{/number}","contents_url":"https://api.github.com/repos/ARMmbed/mbed-os/contents/{+path}","compare_url":"https://api.github.com/repos/ARMmbed/mbed-os/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ARMmbed/mbed-os/merges","archive_url":"https://api.github.com/repos/ARMmbed/mbed-os/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ARMmbed/mbed-os/downloads","issues_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues{/number}","pulls_url":"https://api.github.com/repos/ARMmbed/mbed-os/pulls{/number}","milestones_url":"https://api.github.com/repos/ARMmbed/mbed-os/milestones{/number}","notifications_url":"https://api.github.com/repos/ARMmbed/mbed-os/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ARMmbed/mbed-os/labels{/name}","releases_url":"https://api.github.com/repos/ARMmbed/mbed-os/releases{/id}","deployments_url":"https://api.github.com/repos/ARMmbed/mbed-os/deployments","created_at":"2013-02-18T15:23:11Z","updated_at":"2018-04-11T18:33:42Z","pushed_at":"2018-04-11T21:20:57Z","git_url":"git://github.com/ARMmbed/mbed-os.git","ssh_url":"git@github.com:ARMmbed/mbed-os.git","clone_url":"https://github.com/ARMmbed/mbed-os.git","svn_url":"https://github.com/ARMmbed/mbed-os","homepage":"https://mbed.com","size":204578,"stargazers_count":1593,"watchers_count":1593,"language":"C","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1404,"mirror_url":null,"archived":false,"open_issues_count":446,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":1404,"open_issues":446,"watchers":1593,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ARMmbed/mbed-os/pulls/6609"},"html":{"href":"https://github.com/ARMmbed/mbed-os/pull/6609"},"issue":{"href":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6609"},"comments":{"href":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6609/comments"},"review_comments":{"href":"https://api.github.com/repos/ARMmbed/mbed-os/pulls/6609/comments"},"review_comment":{"href":"https://api.github.com/repos/ARMmbed/mbed-os/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ARMmbed/mbed-os/pulls/6609/commits"},"statuses":{"href":"https://api.github.com/repos/ARMmbed/mbed-os/statuses/dcd1a3ed2a756a02c7ac8acf2984d280e7f0b9fc"}},"author_association":"NONE","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":1,"additions":42,"deletions":36,"changed_files":1}}
{"actor":{"display_login":"pauluap"}}