You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/04/15 11:23:50 UTC

[GitHub] [incubator-nuttx-apps] saramonteiro opened a new pull request #685: examples/mqttc: Makes fd invalid when connect() fails.

saramonteiro opened a new pull request #685:
URL: https://github.com/apache/incubator-nuttx-apps/pull/685


   ## Summary
   This little MR intends to prevent a dump when the broker ip address is not valid.
   To achieve this purpose, we set fd to -1, so even if the socket function returns
   a valid fd, in case the connect function fails, fd will be invalidated preventing the 
   rest of the code to execute. Instead, it will print `ERROR! Couldn't create socket`
   and leave the program.
   
   ## Impact
   
   Target: MQTT users.
   Consequence: People will not have a dump when type a wrong broker ip address. 
   
   ## Testing
   
   I passed a wrong IP broker address. It showed the expected error message.
   I passed a valid IP broker address. It connected and published as expected.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx-apps] acassis merged pull request #685: examples/mqttc: Makes fd invalid when connect() fails.

Posted by GitBox <gi...@apache.org>.
acassis merged pull request #685:
URL: https://github.com/apache/incubator-nuttx-apps/pull/685


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx-apps] saramonteiro commented on a change in pull request #685: examples/mqttc: Makes fd invalid when connect() fails.

Posted by GitBox <gi...@apache.org>.
saramonteiro commented on a change in pull request #685:
URL: https://github.com/apache/incubator-nuttx-apps/pull/685#discussion_r613996883



##########
File path: examples/mqttc/mqttc_pub.c
##########
@@ -174,7 +174,9 @@ static int initserver(const FAR struct mqttc_cfg_s *cfg)
         }
 
       close(fd);
+      fd = -1;
     }
+
   while ((itr = itr->ai_next) != NULL);

Review comment:
       No, I just put back in place.
   It complained about the missing line after the right brace before `close(fd)` and I extended the idea to this one.
   But it is not the case since it's a "do while". 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx-apps] Ouss4 commented on a change in pull request #685: examples/mqttc: Makes fd invalid when connect() fails.

Posted by GitBox <gi...@apache.org>.
Ouss4 commented on a change in pull request #685:
URL: https://github.com/apache/incubator-nuttx-apps/pull/685#discussion_r613994331



##########
File path: examples/mqttc/mqttc_pub.c
##########
@@ -174,7 +174,9 @@ static int initserver(const FAR struct mqttc_cfg_s *cfg)
         }
 
       close(fd);
+      fd = -1;
     }
+
   while ((itr = itr->ai_next) != NULL);

Review comment:
       Did nxstyle complain about this?  AFAIK a new line isn't required here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org