Skip to content

Commit

Permalink
bring back old pci_dev config format
Browse files Browse the repository at this point in the history
previously "0000:03:00.0" was equal to "0:03:00.0" because it got
converted. so bring that back to avoid breaking existing configs.
  • Loading branch information
17314642 authored and flightlessmango committed Dec 30, 2024
1 parent c515999 commit 5ffc524
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/overlay_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,29 @@ static void set_param_defaults(struct overlay_params *params){
params->text_outline_thickness = 1.5;
}

static std::string verify_pci_dev(std::string pci_dev) {
uint32_t domain, bus, slot, func;

if (
sscanf(
pci_dev.c_str(), "%04x:%02x:%02x.%x",
&domain, &bus, &slot, &func
) != 4) {
SPDLOG_ERROR("Failed to parse PCI device ID: '{}'", pci_dev);
return pci_dev;
}

std::stringstream ss;
ss << std::hex
<< std::setw(4) << std::setfill('0') << domain << ":"
<< std::setw(2) << bus << ":"
<< std::setw(2) << slot << "."
<< std::setw(1) << func;

SPDLOG_DEBUG("pci_dev = {}", ss.str());
return ss.str();
}

void
parse_overlay_config(struct overlay_params *params,
const char *env, bool use_existing_preset)
Expand Down Expand Up @@ -1000,6 +1023,9 @@ parse_overlay_config(struct overlay_params *params,
);
}

if (!params->pci_dev.empty())
params->pci_dev = verify_pci_dev(params->pci_dev);

{
std::lock_guard<std::mutex> lock(config_mtx);
config_ready = true;
Expand Down

0 comments on commit 5ffc524

Please sign in to comment.