some coverity fixes

This commit is contained in:
Timothy Stack 2015-09-15 00:24:56 -07:00
parent c3a26ceb6f
commit d298f45fe0
2 changed files with 14 additions and 3 deletions

View File

@ -41,6 +41,7 @@
#include "pcrecpp.h"
#include "auto_fd.hh"
#include "lnav_log.hh"
#include "auto_mem.hh"
#include "auto_pid.hh"
@ -171,7 +172,7 @@ static struct json_path_handler format_handlers[] = {
void install_extra_formats()
{
string config_root = dotlnav_path("remote-config");
int fd;
auto_fd fd;
if (access(config_root.c_str(), R_OK) == 0) {
char pull_cmd[1024];

View File

@ -37,23 +37,23 @@ class plain_text_source
: public text_sub_source {
public:
plain_text_source(std::string text)
: tds_longest_line(0)
{
size_t start = 0, end;
while ((end = text.find('\n', start)) != std::string::npos) {
size_t len = (end - start);
this->tds_lines.push_back(text.substr(start, len));
this->tds_longest_line = std::max(this->tds_longest_line, len);
start = end + 1;
}
if (start < text.length()) {
this->tds_lines.push_back(text.substr(start));
}
this->tds_longest_line = this->compute_longest_line();
};
plain_text_source(const std::vector<std::string> &text_lines) {
this->tds_lines = text_lines;
this->tds_longest_line = this->compute_longest_line();
};
size_t text_line_count()
@ -78,6 +78,16 @@ public:
};
private:
size_t compute_longest_line() {
size_t retval = 0;
for (std::vector<std::string>::iterator iter = this->tds_lines.begin();
iter != this->tds_lines.end();
++iter) {
retval = std::max(retval, iter->length());
}
return retval;
};
std::vector<std::string> tds_lines;
size_t tds_longest_line;
};