{"action":"created","comment":{"url":"https://api.github.com/repos/baidu/bfs/pulls/comments/96115649","pull_request_review_id":16693931,"id":96115649,"diff_hunk":"@@ -125,29 +125,37 @@ int BfsCat(baidu::bfs::FS* fs, int argc, char* argv[]) {\n         return 1;\n     }\n     int64_t bytes = 0;\n-    int32_t len;\n+    int32_t len_read;\n+    int32_t len_write;\n     for (int i = 0; i < argc; i++) {\n         baidu::bfs::File* file;\n         if (fs->OpenFile(argv[i], O_RDONLY, &file, baidu::bfs::ReadOptions()) != 0) {\n             fprintf(stderr, \"Can't Open bfs file %s\\n\", argv[i]);\n             return 1;\n         }\n         char buf[10240];\n-        len = 0;\n+        len_read = 0;\n+        len_write = 0;\n         while (1) {\n-            len = file->Read(buf, sizeof(buf));\n-            if (len <= 0) {\n-                if (len < 0) {\n+            len_read = file->Read(buf, sizeof(buf));\n+            if (len_read <= 0) {\n+                if (len_read < 0) {\n                     fprintf(stderr, \"Read from %s fail.\\n\", argv[i]);\n                 }\n                 break;\n             }\n-            bytes += len;\n-            write(1, buf, len);\n+            bytes += len_read;\n+            len_write = write(1, buf, len_read);\n+            if (len_write <= 0) {","path":"src/client/bfs_client.cc","position":32,"original_position":32,"commit_id":"aa1dc9375a415f431a9e45948fa144a01fbe03d4","original_commit_id":"271743b2cf267858498da06a795ebe8fe7bf449d","user":{"login":"ToWorld","id":10758120,"avatar_url":"https://avatars.githubusercontent.com/u/10758120?v=3","gravatar_id":"","url":"https://api.github.com/users/ToWorld","html_url":"https://github.com/ToWorld","followers_url":"https://api.github.com/users/ToWorld/followers","following_url":"https://api.github.com/users/ToWorld/following{/other_user}","gists_url":"https://api.github.com/users/ToWorld/gists{/gist_id}","starred_url":"https://api.github.com/users/ToWorld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ToWorld/subscriptions","organizations_url":"https://api.github.com/users/ToWorld/orgs","repos_url":"https://api.github.com/users/ToWorld/repos","events_url":"https://api.github.com/users/ToWorld/events{/privacy}","received_events_url":"https://api.github.com/users/ToWorld/received_events","type":"User","site_admin":false},"body":"感觉这个函数中的in64_t bytes这个变量好像可有可无？ 还是返回值应该是bytes而不是len_read,下面有几个函数有类似的问题。","created_at":"2017-01-14T13:25:26Z","updated_at":"2017-01-14T13:25:26Z","html_url":"https://github.com/baidu/bfs/pull/799#discussion_r96115649","pull_request_url":"https://api.github.com/repos/baidu/bfs/pulls/799","_links":{"self":{"href":"https://api.github.com/repos/baidu/bfs/pulls/comments/96115649"},"html":{"href":"https://github.com/baidu/bfs/pull/799#discussion_r96115649"},"pull_request":{"href":"https://api.github.com/repos/baidu/bfs/pulls/799"}}},"pull_request":{"url":"https://api.github.com/repos/baidu/bfs/pulls/799","id":101553866,"html_url":"https://github.com/baidu/bfs/pull/799","diff_url":"https://github.com/baidu/bfs/pull/799.diff","patch_url":"https://github.com/baidu/bfs/pull/799.patch","issue_url":"https://api.github.com/repos/baidu/bfs/issues/799","number":799,"state":"open","locked":false,"title":"check the return value of write function","user":{"login":"ToWorld","id":10758120,"avatar_url":"https://avatars.githubusercontent.com/u/10758120?v=3","gravatar_id":"","url":"https://api.github.com/users/ToWorld","html_url":"https://github.com/ToWorld","followers_url":"https://api.github.com/users/ToWorld/followers","following_url":"https://api.github.com/users/ToWorld/following{/other_user}","gists_url":"https://api.github.com/users/ToWorld/gists{/gist_id}","starred_url":"https://api.github.com/users/ToWorld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ToWorld/subscriptions","organizations_url":"https://api.github.com/users/ToWorld/orgs","repos_url":"https://api.github.com/users/ToWorld/repos","events_url":"https://api.github.com/users/ToWorld/events{/privacy}","received_events_url":"https://api.github.com/users/ToWorld/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-01-14T07:41:25Z","updated_at":"2017-01-14T13:25:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"579277d70ea54017c636a0a8bd06e7a06c49ee08","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/baidu/bfs/pulls/799/commits","review_comments_url":"https://api.github.com/repos/baidu/bfs/pulls/799/comments","review_comment_url":"https://api.github.com/repos/baidu/bfs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/baidu/bfs/issues/799/comments","statuses_url":"https://api.github.com/repos/baidu/bfs/statuses/aa1dc9375a415f431a9e45948fa144a01fbe03d4","head":{"label":"ToWorld:patch-1","ref":"patch-1","sha":"aa1dc9375a415f431a9e45948fa144a01fbe03d4","user":{"login":"ToWorld","id":10758120,"avatar_url":"https://avatars.githubusercontent.com/u/10758120?v=3","gravatar_id":"","url":"https://api.github.com/users/ToWorld","html_url":"https://github.com/ToWorld","followers_url":"https://api.github.com/users/ToWorld/followers","following_url":"https://api.github.com/users/ToWorld/following{/other_user}","gists_url":"https://api.github.com/users/ToWorld/gists{/gist_id}","starred_url":"https://api.github.com/users/ToWorld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ToWorld/subscriptions","organizations_url":"https://api.github.com/users/ToWorld/orgs","repos_url":"https://api.github.com/users/ToWorld/repos","events_url":"https://api.github.com/users/ToWorld/events{/privacy}","received_events_url":"https://api.github.com/users/ToWorld/received_events","type":"User","site_admin":false},"repo":{"id":78000751,"name":"bfs","full_name":"ToWorld/bfs","owner":{"login":"ToWorld","id":10758120,"avatar_url":"https://avatars.githubusercontent.com/u/10758120?v=3","gravatar_id":"","url":"https://api.github.com/users/ToWorld","html_url":"https://github.com/ToWorld","followers_url":"https://api.github.com/users/ToWorld/followers","following_url":"https://api.github.com/users/ToWorld/following{/other_user}","gists_url":"https://api.github.com/users/ToWorld/gists{/gist_id}","starred_url":"https://api.github.com/users/ToWorld/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ToWorld/subscriptions","organizations_url":"https://api.github.com/users/ToWorld/orgs","repos_url":"https://api.github.com/users/ToWorld/repos","events_url":"https://api.github.com/users/ToWorld/events{/privacy}","received_events_url":"https://api.github.com/users/ToWorld/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ToWorld/bfs","description":"The Baidu File System.","fork":true,"url":"https://api.github.com/repos/ToWorld/bfs","forks_url":"https://api.github.com/repos/ToWorld/bfs/forks","keys_url":"https://api.github.com/repos/ToWorld/bfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ToWorld/bfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ToWorld/bfs/teams","hooks_url":"https://api.github.com/repos/ToWorld/bfs/hooks","issue_events_url":"https://api.github.com/repos/ToWorld/bfs/issues/events{/number}","events_url":"https://api.github.com/repos/ToWorld/bfs/events","assignees_url":"https://api.github.com/repos/ToWorld/bfs/assignees{/user}","branches_url":"https://api.github.com/repos/ToWorld/bfs/branches{/branch}","tags_url":"https://api.github.com/repos/ToWorld/bfs/tags","blobs_url":"https://api.github.com/repos/ToWorld/bfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ToWorld/bfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ToWorld/bfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/ToWorld/bfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ToWorld/bfs/statuses/{sha}","languages_url":"https://api.github.com/repos/ToWorld/bfs/languages","stargazers_url":"https://api.github.com/repos/ToWorld/bfs/stargazers","contributors_url":"https://api.github.com/repos/ToWorld/bfs/contributors","subscribers_url":"https://api.github.com/repos/ToWorld/bfs/subscribers","subscription_url":"https://api.github.com/repos/ToWorld/bfs/subscription","commits_url":"https://api.github.com/repos/ToWorld/bfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/ToWorld/bfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/ToWorld/bfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/ToWorld/bfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/ToWorld/bfs/contents/{+path}","compare_url":"https://api.github.com/repos/ToWorld/bfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ToWorld/bfs/merges","archive_url":"https://api.github.com/repos/ToWorld/bfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ToWorld/bfs/downloads","issues_url":"https://api.github.com/repos/ToWorld/bfs/issues{/number}","pulls_url":"https://api.github.com/repos/ToWorld/bfs/pulls{/number}","milestones_url":"https://api.github.com/repos/ToWorld/bfs/milestones{/number}","notifications_url":"https://api.github.com/repos/ToWorld/bfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ToWorld/bfs/labels{/name}","releases_url":"https://api.github.com/repos/ToWorld/bfs/releases{/id}","deployments_url":"https://api.github.com/repos/ToWorld/bfs/deployments","created_at":"2017-01-04T09:23:02Z","updated_at":"2017-01-04T09:23:06Z","pushed_at":"2017-01-14T13:23:28Z","git_url":"git://github.com/ToWorld/bfs.git","ssh_url":"git@github.com:ToWorld/bfs.git","clone_url":"https://github.com/ToWorld/bfs.git","svn_url":"https://github.com/ToWorld/bfs","homepage":"","size":11523,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"baidu:master","ref":"master","sha":"ad8b89f72b05088b60d3325308d5d24d97ddfcf2","user":{"login":"baidu","id":13245940,"avatar_url":"https://avatars.githubusercontent.com/u/13245940?v=3","gravatar_id":"","url":"https://api.github.com/users/baidu","html_url":"https://github.com/baidu","followers_url":"https://api.github.com/users/baidu/followers","following_url":"https://api.github.com/users/baidu/following{/other_user}","gists_url":"https://api.github.com/users/baidu/gists{/gist_id}","starred_url":"https://api.github.com/users/baidu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baidu/subscriptions","organizations_url":"https://api.github.com/users/baidu/orgs","repos_url":"https://api.github.com/users/baidu/repos","events_url":"https://api.github.com/users/baidu/events{/privacy}","received_events_url":"https://api.github.com/users/baidu/received_events","type":"Organization","site_admin":false},"repo":{"id":26562172,"name":"bfs","full_name":"baidu/bfs","owner":{"login":"baidu","id":13245940,"avatar_url":"https://avatars.githubusercontent.com/u/13245940?v=3","gravatar_id":"","url":"https://api.github.com/users/baidu","html_url":"https://github.com/baidu","followers_url":"https://api.github.com/users/baidu/followers","following_url":"https://api.github.com/users/baidu/following{/other_user}","gists_url":"https://api.github.com/users/baidu/gists{/gist_id}","starred_url":"https://api.github.com/users/baidu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baidu/subscriptions","organizations_url":"https://api.github.com/users/baidu/orgs","repos_url":"https://api.github.com/users/baidu/repos","events_url":"https://api.github.com/users/baidu/events{/privacy}","received_events_url":"https://api.github.com/users/baidu/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/baidu/bfs","description":"The Baidu File System.","fork":false,"url":"https://api.github.com/repos/baidu/bfs","forks_url":"https://api.github.com/repos/baidu/bfs/forks","keys_url":"https://api.github.com/repos/baidu/bfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/baidu/bfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/baidu/bfs/teams","hooks_url":"https://api.github.com/repos/baidu/bfs/hooks","issue_events_url":"https://api.github.com/repos/baidu/bfs/issues/events{/number}","events_url":"https://api.github.com/repos/baidu/bfs/events","assignees_url":"https://api.github.com/repos/baidu/bfs/assignees{/user}","branches_url":"https://api.github.com/repos/baidu/bfs/branches{/branch}","tags_url":"https://api.github.com/repos/baidu/bfs/tags","blobs_url":"https://api.github.com/repos/baidu/bfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/baidu/bfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/baidu/bfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/baidu/bfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/baidu/bfs/statuses/{sha}","languages_url":"https://api.github.com/repos/baidu/bfs/languages","stargazers_url":"https://api.github.com/repos/baidu/bfs/stargazers","contributors_url":"https://api.github.com/repos/baidu/bfs/contributors","subscribers_url":"https://api.github.com/repos/baidu/bfs/subscribers","subscription_url":"https://api.github.com/repos/baidu/bfs/subscription","commits_url":"https://api.github.com/repos/baidu/bfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/baidu/bfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/baidu/bfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/baidu/bfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/baidu/bfs/contents/{+path}","compare_url":"https://api.github.com/repos/baidu/bfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/baidu/bfs/merges","archive_url":"https://api.github.com/repos/baidu/bfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/baidu/bfs/downloads","issues_url":"https://api.github.com/repos/baidu/bfs/issues{/number}","pulls_url":"https://api.github.com/repos/baidu/bfs/pulls{/number}","milestones_url":"https://api.github.com/repos/baidu/bfs/milestones{/number}","notifications_url":"https://api.github.com/repos/baidu/bfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/baidu/bfs/labels{/name}","releases_url":"https://api.github.com/repos/baidu/bfs/releases{/id}","deployments_url":"https://api.github.com/repos/baidu/bfs/deployments","created_at":"2014-11-13T00:00:29Z","updated_at":"2017-01-13T09:43:16Z","pushed_at":"2017-01-14T13:23:28Z","git_url":"git://github.com/baidu/bfs.git","ssh_url":"git@github.com:baidu/bfs.git","clone_url":"https://github.com/baidu/bfs.git","svn_url":"https://github.com/baidu/bfs","homepage":"","size":11521,"stargazers_count":1801,"watchers_count":1801,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":296,"mirror_url":null,"open_issues_count":87,"forks":296,"open_issues":87,"watchers":1801,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/baidu/bfs/pulls/799"},"html":{"href":"https://github.com/baidu/bfs/pull/799"},"issue":{"href":"https://api.github.com/repos/baidu/bfs/issues/799"},"comments":{"href":"https://api.github.com/repos/baidu/bfs/issues/799/comments"},"review_comments":{"href":"https://api.github.com/repos/baidu/bfs/pulls/799/comments"},"review_comment":{"href":"https://api.github.com/repos/baidu/bfs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/baidu/bfs/pulls/799/commits"},"statuses":{"href":"https://api.github.com/repos/baidu/bfs/statuses/aa1dc9375a415f431a9e45948fa144a01fbe03d4"}}}}
{"actor":{"display_login":"ToWorld"}}