mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
samples(va): fix build warnings, use cv::format()
This commit is contained in:
parent
3dd55d284d
commit
a40d308d6a
@ -10,6 +10,8 @@
|
||||
#include <va/va.h>
|
||||
# include <va/va_drm.h>
|
||||
|
||||
#include "opencv2/core.hpp" // cv::format()
|
||||
|
||||
namespace va {
|
||||
|
||||
bool openDisplay();
|
||||
@ -70,10 +72,9 @@ static unsigned readId(const char* devName, const char* idName)
|
||||
{
|
||||
long int id = 0;
|
||||
|
||||
char fileName[256];
|
||||
snprintf(fileName, sizeof(fileName), "%s/%s/%s", VA_INTEL_PCI_DIR, devName, idName);
|
||||
std::string fileName = cv::format("%s/%s/%s", VA_INTEL_PCI_DIR, devName, idName);
|
||||
|
||||
FILE* file = fopen(fileName, "r");
|
||||
FILE* file = fopen(fileName.c_str(), "r");
|
||||
if (file)
|
||||
{
|
||||
char str[16] = "";
|
||||
@ -100,9 +101,8 @@ static int findAdapter(unsigned desiredVendorId)
|
||||
unsigned vendorId = readId(name, "vendor");
|
||||
if (vendorId == desiredVendorId)
|
||||
{
|
||||
char subdirName[256];
|
||||
snprintf(subdirName, sizeof(subdirName), "%s/%s/%s", VA_INTEL_PCI_DIR, name, "drm");
|
||||
Directory subdir(subdirName);
|
||||
std::string subdirName = cv::format("%s/%s/%s", VA_INTEL_PCI_DIR, name, "drm");
|
||||
Directory subdir(subdirName.c_str());
|
||||
for (int j = 0; j < subdir.count(); ++j)
|
||||
{
|
||||
if (!strncmp(subdir[j]->d_name, "card", 4))
|
||||
@ -130,18 +130,12 @@ public:
|
||||
numbers[1] = adapterIndex;
|
||||
for (int i = 0; i < NUM_NODES; ++i)
|
||||
{
|
||||
int sz = sizeof(VA_INTEL_DRI_DIR) + strlen(names[i]) + 3;
|
||||
paths[i] = new char [sz];
|
||||
snprintf(paths[i], sz, "%s%s%d", VA_INTEL_DRI_DIR, names[i], numbers[i]);
|
||||
paths[i] = cv::format("%s%s%d", VA_INTEL_DRI_DIR, names[i], numbers[i]);
|
||||
}
|
||||
}
|
||||
~NodeInfo()
|
||||
{
|
||||
for (int i = 0; i < NUM_NODES; ++i)
|
||||
{
|
||||
delete paths[i];
|
||||
paths[i] = 0;
|
||||
}
|
||||
// nothing
|
||||
}
|
||||
int count() const
|
||||
{
|
||||
@ -149,10 +143,10 @@ public:
|
||||
}
|
||||
const char* path(int index) const
|
||||
{
|
||||
return ((index >= 0) && (index < NUM_NODES)) ? paths[index] : 0;
|
||||
return ((index >= 0) && (index < NUM_NODES)) ? paths[index].c_str() : 0;
|
||||
}
|
||||
private:
|
||||
char* paths[NUM_NODES];
|
||||
std::string paths[NUM_NODES];
|
||||
};
|
||||
|
||||
static bool openDeviceIntel();
|
||||
|
Loading…
Reference in New Issue
Block a user