Xavier de Gaye wrote: > 2010/12/14 Dominique Pellé wrote: > > > > clang static analyzer complains with the following warning: > > > > netbeans.c:329:6: warning: Value stored to 'sd' is never read > > sd = mch_open(hostname, O_RDONLY, 0); > > ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > .... > > > > File descriptor sd is leaked at line 329. > > Why is this file being opened at line 329 without being used? > > Shouldn't line 326 to 331 be removed? > > > > > Hi Dominique, > > There is possibly a confusion between 'hostname' the parameter, and > the file from where this parameter may be read (:help > netbeans-parameters). Maybe the author wanted initially to print the > file content as a debugging help while he was writting this function ? > I agree with you that these lines should be removed. > > Another problem is that 'sd' is mostly never closed in case of error. > > I don't know also what is the purpose of reopening a new socket, after > the first connect has failed with ECONNREFUSED. This does not seem > useful.
Using hostname as a file name was apparently used for debugging. I don't see how you can do much with this, and since the file descriptor is assigned to "sd" instead of "nbsock" it doesn't actually work. Let's remove these lines. Not leaking when there is an error somewhere would also be good. Also, there is a "sleep(5)" that doesn't look right. Can one get out of that loop by pressing CTRL-C? I would prefer someone who can verify the proper working to propose a patch for this. -- I have a drinking problem -- I don't have a drink! /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
