Skip to content

Commit

Permalink
[misc] fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tstack committed Jun 3, 2024
1 parent afcdad7 commit b084655
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverity2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: synopsys-sig/synopsys-action@v1.9.0
with:
### SCANNING: Required fields
coverity_url: https://scan.coverity.com/
coverity_url: https://scan.coverity.com
coverity_user: tstack
coverity_passphrase: ${{ secrets.COVERITY_PASSPHRASE }}

Expand Down
2 changes: 1 addition & 1 deletion src/base/intern_string.hh
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ struct string_fragment {
return retval;
}

std::optional<size_t> find(char ch) const
std::optional<int> find(char ch) const
{
for (int lpc = this->sf_begin; lpc < this->sf_end; lpc++) {
if (this->sf_string[lpc] == ch) {
Expand Down
16 changes: 11 additions & 5 deletions src/curl_looper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,22 @@ curl_request(std::string name)
long
curl_request::complete(CURLcode result)
{
double total_time = 0, download_size = 0, download_speed = 0;
double total_time = 0;
curl_off_t download_size = 0, download_speed = 0;

this->cr_completions += 1;
curl_easy_getinfo(this->cr_handle, CURLINFO_TOTAL_TIME, &total_time);
log_debug("%s: total_time=%f", this->cr_name.c_str(), total_time);
curl_easy_getinfo(this->cr_handle, CURLINFO_SIZE_DOWNLOAD, &download_size);
log_debug("%s: download_size=%f", this->cr_name.c_str(), download_size);
curl_easy_getinfo(
this->cr_handle, CURLINFO_SPEED_DOWNLOAD, &download_speed);
log_debug("%s: download_speed=%f", this->cr_name.c_str(), download_speed);
this->cr_handle, CURLINFO_SIZE_DOWNLOAD_T, &download_size);
log_debug("%s: download_size=%" CURL_FORMAT_CURL_OFF_T,
this->cr_name.c_str(),
download_size);
curl_easy_getinfo(
this->cr_handle, CURLINFO_SPEED_DOWNLOAD_T, &download_speed);
log_debug("%s: download_speed=%" CURL_FORMAT_CURL_OFF_T,
this->cr_name.c_str(),
download_speed);

return -1;
}
Expand Down
16 changes: 10 additions & 6 deletions src/lnav_commands.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3074,7 +3074,8 @@ com_open(exec_context& ec, std::string cmdline, std::vector<std::string>& args)

#ifdef HAVE_LIBCURL
if (startswith(fn, "file:")) {
auto* cu = curl_url();
auto_mem<CURLU> cu(curl_url_cleanup);
cu = curl_url();
auto set_rc = curl_url_set(cu, CURLUPART_URL, fn.c_str(), 0);
if (set_rc != CURLUE_OK) {
return Err(lnav::console::user_message::error(
Expand All @@ -3083,16 +3084,18 @@ com_open(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
.with_reason(curl_url_strerror(set_rc)));
}

char* path_part;
auto get_rc = curl_url_get(cu, CURLUPART_PATH, &path_part, 0);
auto_mem<char> path_part;
auto get_rc
= curl_url_get(cu, CURLUPART_PATH, path_part.out(), 0);
if (get_rc != CURLUE_OK) {
return Err(lnav::console::user_message::error(
attr_line_t("cannot get path from URL: ")
.append(lnav::roles::file(fn)))
.with_reason(curl_url_strerror(get_rc)));
}
char* frag_part = nullptr;
get_rc = curl_url_get(cu, CURLUPART_FRAGMENT, &frag_part, 0);
auto_mem<char> frag_part;
get_rc
= curl_url_get(cu, CURLUPART_FRAGMENT, frag_part.out(), 0);
if (get_rc != CURLUE_OK && get_rc != CURLUE_NO_FRAGMENT) {
return Err(lnav::console::user_message::error(
attr_line_t("cannot get fragment from URL: ")
Expand All @@ -3101,7 +3104,8 @@ com_open(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
}

if (frag_part != nullptr && frag_part[0]) {
fn = fmt::format(FMT_STRING("{}#{}"), path_part, frag_part);
fn = fmt::format(
FMT_STRING("{}#{}"), path_part.in(), frag_part.in());
} else {
fn = path_part;
}
Expand Down

0 comments on commit b084655

Please sign in to comment.