RE: [PATCH] infiniband-diags: add rdma-ndd daemon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> > How about the following?
> >
> > @@ -155,8 +156,8 @@ int read_and_set_hostname(int fd)
> >   {
> >          int rc;
> >          char buf[128];
> > -       if (read(fd, buf, 65) >= 0) {
> > -               buf[65] = '\0';
> > +       memset(buf, 0, sizeof(buf));
> > +       if (read(fd, buf, 64) >= 0) {
> >                  newline_to_null(buf);
> >                  strip_domain(buf);
> >                  syslog(LOG_INFO, "new hostname detected: %s", buf);
> 
> This change looks fine to me. A possible alternative is to use dup() +
> fdopen() + fgets() + fclose(). fgets() namely automatically appends a
> terminating '\0'.

Agreed.  But I'd like to avoid creating additional fd's.

Thanks for the review,
Ira

> 
> Bart.
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body
> of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at
> http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux