missing read calls in get_char function

S Kalyanasundaram skalyanasundaram at novell.com
Tue Aug 26 12:59:23 UTC 2008


Hi, just some curious question. I have been working in dhcp-3.0.3
earlier. Now when i moved to the latter version i saw a patch in
get_char function, I could not understand why the read call has been
removed. Are we sure we read the whole buffer in one time and not
necessary to read incase of remaining configuration? Please help me to
understand. Or the code is moved to somewhere else?


 static int get_char (cfile)
        struct parse *cfile;
 {
        /* My kingdom for WITH... */
        int c;
 
-       if (cfile -> bufix == cfile -> buflen) {
-               if (cfile -> file != -1) {
-                       cfile -> buflen =
-                               read (cfile -> file,
-                                     cfile -> inbuf, cfile -> bufsiz);
-                       if (cfile -> buflen == 0) {
-                               c = EOF;
-                               cfile -> bufix = 0;
-                       } else if (cfile -> buflen < 0) {
-                               c = EOF;
-                               cfile -> bufix = cfile -> buflen = 0;
-                       } else {
-                               c = cfile -> inbuf [0];
-                               cfile -> bufix = 1;
-                       }
-               } else
-                       c = EOF;
-       } else {
-               c = cfile -> inbuf [cfile -> bufix];
-               cfile -> bufix++;
+       if (cfile->bufix == cfile->buflen)
+               c = EOF;
+       else {
+               c = cfile->inbuf [cfile->bufix];
+               cfile->bufix++;
        }


Thanks in advance,
  -Kalyan




More information about the dhcp-hackers mailing list