Github user selvaganesang commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/953#discussion_r100873849
  
    --- Diff: core/sql/cli/memorymonitor.cpp ---
    @@ -223,12 +229,12 @@ void MemoryMonitor::update(float &scale) {
        char * currPtr;
             bytesRead = fread(buffer, 1, 2048, fd_meminfo_);
             // Make sure there wasn't an error (next fseek will clear eof)
    -        if (!feof(fd_meminfo_))// Make sure there wasn't an error
    -        {
    -           scale = 6;
    -           pressure_ = 0;
    -           return;
    -        }
    +        if (ferror(fd_meminfo_))
    +           assert(false); 
    +        if (feof(fd_meminfo_))
    +           clearerr(fd_meminfo_); 
    +        else
    +           buffer[bytesRead] = '\0';
    --- End diff --
    
    fread cpp reference says the following:
    Number of objects read successfully, which may be less than count if an 
error or end-of-file condition occurs. 
    
    It looks like feof is treated like an error condition. 
    This code assumed that buffer is always big enough. I can change it to get 
rid of this assumption


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to