{"action":"created","issue":{"url":"https://api.github.com/repos/m-mizutani/libfluent/issues/9","repository_url":"https://api.github.com/repos/m-mizutani/libfluent","labels_url":"https://api.github.com/repos/m-mizutani/libfluent/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/m-mizutani/libfluent/issues/9/comments","events_url":"https://api.github.com/repos/m-mizutani/libfluent/issues/9/events","html_url":"https://github.com/m-mizutani/libfluent/issues/9","id":296784851,"number":9,"title":"Fix warnings: \"warning: 'rc' may be used uninitialized in this function\" and \"warning: comparison between signed and unsigned integer expressions\"","user":{"login":"flxflndy","id":22711313,"avatar_url":"https://avatars2.githubusercontent.com/u/22711313?v=4","gravatar_id":"","url":"https://api.github.com/users/flxflndy","html_url":"https://github.com/flxflndy","followers_url":"https://api.github.com/users/flxflndy/followers","following_url":"https://api.github.com/users/flxflndy/following{/other_user}","gists_url":"https://api.github.com/users/flxflndy/gists{/gist_id}","starred_url":"https://api.github.com/users/flxflndy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flxflndy/subscriptions","organizations_url":"https://api.github.com/users/flxflndy/orgs","repos_url":"https://api.github.com/users/flxflndy/repos","events_url":"https://api.github.com/users/flxflndy/events{/privacy}","received_events_url":"https://api.github.com/users/flxflndy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-13T15:46:57Z","updated_at":"2018-02-16T07:53:38Z","closed_at":null,"author_association":"NONE","body":"While compling libfluent with different compiler settings I got two warnings.\r\n\r\n`\r\n13-Feb-2018 15:42:09 | /data/Libraries/libfluent/src/emitter.cc: In member function 'virtual void fluent::FileEmitter::worker()':\r\n-- | --\r\n13-Feb-2018 15:42:09 | /data/Libraries/libfluent/src/emitter.cc:234:9: warning: 'rc' may be used uninitialized in this function [-Wmaybe-uninitialized]\r\n`\r\n\r\n`\r\n13-Feb-2018 15:42:16 | /data/Libraries/libfluent/tools/fluent-bench.cc: In function 'int main(int, char**)':\r\n-- | --\r\n13-Feb-2018 15:42:16 | /data/Libraries/libfluent/tools/fluent-bench.cc:68:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]\r\n13-Feb-2018 15:42:16 | int diff = (mps > msg_count) ? mps - msg_count : msg_count - mps;\r\n13-Feb-2018 15:42:16 | ^\r\n13-Feb-2018 15:42:16 | /data/Libraries/libfluent/tools/fluent-bench.cc:75:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]\r\n13-Feb-2018 15:42:16 | if (mps < msg_count) {\r\n13-Feb-2018 15:42:16 | ^\r\n13-Feb-2018 15:42:16 | /data/Libraries/libfluent/tools/fluent-bench.cc:77:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]\r\n13-Feb-2018 15:42:16 | } else if (mps > msg_count) {\r\n`\r\nThe following changes fixes the issues.\r\n\r\n```\r\ndiff --git a/Libraries/libfluent/src/emitter.cc b/Libraries/libfluent/src/emitter.cc\r\nindex 28fb5fb..e533b81 100644\r\n--- a/Libraries/libfluent/src/emitter.cc\r\n+++ b/Libraries/libfluent/src/emitter.cc\r\n@@ -212,7 +212,7 @@ namespace fluent {\r\n     Message *root;\r\n     while (nullptr != (root = this->queue_.bulk_pop())) {\r\n       for(Message *msg = root; msg; msg = msg->next()) {\r\n-        int rc;\r\n+        int rc = 0;\r\n         switch(this->format_) {\r\n           case MsgPack: {\r\n             msgpack::sbuffer buf;\r\n\r\n\r\ndiff --git a/Libraries/libfluent/tools/fluent-bench.cc b/Libraries/libfluent/tools/fluent-bench.cc\r\nindex dcc98c8..6ab8ef6 100644\r\n--- a/Libraries/libfluent/tools/fluent-bench.cc\r\n+++ b/Libraries/libfluent/tools/fluent-bench.cc\r\n@@ -46,7 +46,7 @@ int main(int argc, char *argv[]) {\r\n\r\n   int wait = 1000000 / mps;\r\n   time_t last_ts = time(nullptr);\r\n-  size_t msg_count = 0;\r\n+  int msg_count = 0;\r\n\r\n   std::cout << \"wait: \" << wait << \"usec\" << std::endl;\r\n```\r\n\r\nBest regards,"},"comment":{"url":"https://api.github.com/repos/m-mizutani/libfluent/issues/comments/366166413","html_url":"https://github.com/m-mizutani/libfluent/issues/9#issuecomment-366166413","issue_url":"https://api.github.com/repos/m-mizutani/libfluent/issues/9","id":366166413,"user":{"login":"m-mizutani","id":605953,"avatar_url":"https://avatars0.githubusercontent.com/u/605953?v=4","gravatar_id":"","url":"https://api.github.com/users/m-mizutani","html_url":"https://github.com/m-mizutani","followers_url":"https://api.github.com/users/m-mizutani/followers","following_url":"https://api.github.com/users/m-mizutani/following{/other_user}","gists_url":"https://api.github.com/users/m-mizutani/gists{/gist_id}","starred_url":"https://api.github.com/users/m-mizutani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-mizutani/subscriptions","organizations_url":"https://api.github.com/users/m-mizutani/orgs","repos_url":"https://api.github.com/users/m-mizutani/repos","events_url":"https://api.github.com/users/m-mizutani/events{/privacy}","received_events_url":"https://api.github.com/users/m-mizutani/received_events","type":"User","site_admin":false},"created_at":"2018-02-16T07:53:38Z","updated_at":"2018-02-16T07:53:38Z","author_association":"OWNER","body":"Thank you for reporting the issue. Let me check it and fix it in next weekend."}}
{"actor":{"display_login":"m-mizutani"}}