fprintf should return 2 including terminating character as well. formatting.
Some checks failed
Build on RHEL9 / build (push) Failing after 31s
Build on RHEL8 / build (push) Successful in 4m58s

This commit is contained in:
2026-01-06 09:53:55 +01:00
parent c154164eff
commit 66f9664bc4
6 changed files with 28 additions and 24 deletions

View File

@@ -1,5 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-other // SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
int XILINX_FMC_enable_all(char* error_message, int message_size); int XILINX_FMC_enable_all(char *error_message, int message_size);
int XILINX_FMC_disable_all(char* error_message, int message_size); int XILINX_FMC_disable_all(char *error_message, int message_size);

View File

@@ -27,24 +27,26 @@ static const char *fmc_files[] = {
#define FMC_NUM_FILES (sizeof(fmc_files) / sizeof(fmc_files[0])) #define FMC_NUM_FILES (sizeof(fmc_files) / sizeof(fmc_files[0]))
// clang-format on // clang-format on
int XILINX_FMC_enable_all(char* error_message, int message_size) { int XILINX_FMC_enable_all(char *error_message, int message_size) {
LOG(logINFOBLUE, ("enable FMC power\n")); LOG(logINFOBLUE, ("enable FMC power\n"));
#ifdef VIRTUAL #ifdef VIRTUAL
return; return;
#endif #endif
char full_path[64]; char full_path[64];
for (size_t i = 0; i < FMC_NUM_FILES; ++i) { for (size_t i = 0; i < FMC_NUM_FILES; ++i) {
const char* file = fmc_files[i]; const char *file = fmc_files[i];
snprintf(full_path, sizeof(full_path), "%s%s", FMC_BASE_PATH, file); snprintf(full_path, sizeof(full_path), "%s%s", FMC_BASE_PATH, file);
FILE *fp = fopen(full_path, "w"); FILE *fp = fopen(full_path, "w");
if (fp == NULL) { if (fp == NULL) {
snprintf(error_message, message_size, "XILINX_FMC: Couuld not enable.\n"); snprintf(error_message, message_size,
"XILINX_FMC: Couuld not enable.\n");
LOG(logERROR, (error_message)); LOG(logERROR, (error_message));
return 1; return 1;
} }
if (fprintf(fp, "1\n") != 1) { if (fprintf(fp, "1\n") != 2) {
snprintf(error_message, message_size, "XILINX_FMC: Could not write enable.\n"); snprintf(error_message, message_size,
"XILINX_FMC: Could not write enable.\n");
LOG(logERROR, (error_message)); LOG(logERROR, (error_message));
return 1; return 1;
} }
@@ -53,23 +55,25 @@ int XILINX_FMC_enable_all(char* error_message, int message_size) {
return 0; return 0;
} }
int XILINX_FMC_disable_all(char* error_message, int message_size) { int XILINX_FMC_disable_all(char *error_message, int message_size) {
LOG(logINFOBLUE, ("disable FMC power\n")); LOG(logINFOBLUE, ("disable FMC power\n"));
#ifdef VIRTUAL #ifdef VIRTUAL
return; return;
#endif #endif
char full_path[64]; char full_path[64];
for (size_t i = 0; i < FMC_NUM_FILES; ++i) { for (size_t i = 0; i < FMC_NUM_FILES; ++i) {
const char* file = fmc_files[i]; const char *file = fmc_files[i];
snprintf(full_path, sizeof(full_path), "%s%s", FMC_BASE_PATH, file); snprintf(full_path, sizeof(full_path), "%s%s", FMC_BASE_PATH, file);
FILE *fp = fopen(full_path, "w"); FILE *fp = fopen(full_path, "w");
if (fp == NULL) { if (fp == NULL) {
snprintf(error_message, message_size, "XILINX_FMC: Could not disable\n"); snprintf(error_message, message_size,
"XILINX_FMC: Could not disable\n");
LOG(logERROR, (error_message)); LOG(logERROR, (error_message));
return 1; return 1;
} }
if (fprintf(fp, "0\n") != 1) { if (fprintf(fp, "0\n") != 2) {
snprintf(error_message, message_size, "XILINX_FMC: Could not write disable.\n"); snprintf(error_message, message_size,
"XILINX_FMC: Could not write disable.\n");
LOG(logERROR, (error_message)); LOG(logERROR, (error_message));
return 1; return 1;
} }

View File

@@ -9,8 +9,8 @@
#include "sls/versionAPI.h" #include "sls/versionAPI.h"
#include "LTC2620_Driver.h" #include "LTC2620_Driver.h"
#include "XILINX_PLL.h"
#include "XILINX_FMC.h" #include "XILINX_FMC.h"
#include "XILINX_PLL.h"
#include "loadPattern.h" #include "loadPattern.h"
#ifdef VIRTUAL #ifdef VIRTUAL
#include "communication_funcs_UDP.h" #include "communication_funcs_UDP.h"
@@ -266,8 +266,8 @@ int testFixedFPGAPattern() {
return FAIL; return FAIL;
} }
#endif #endif
LOG(logINFO, LOG(logINFO, ("\tSuccessfully read FPGA Fixed Pattern (0x%x)\n",
("\tSuccessfully read FPGA Fixed Pattern (0x%x)\n", FIXEDPATTERNREG_PRESET)); FIXEDPATTERNREG_PRESET));
return OK; return OK;
} }
@@ -405,7 +405,7 @@ void setupDetector() {
LTC2620_D_SetDefines(DAC_MIN_MV, DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC, LTC2620_D_SetDefines(DAC_MIN_MV, DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC,
NPWR, DAC_POWERDOWN_DRIVER_FILE_NAME); NPWR, DAC_POWERDOWN_DRIVER_FILE_NAME);
// power LTC2620 before talking to it: // power LTC2620 before talking to it:
initError = XILINX_FMC_enable_all(initErrorMessage, MAX_STR_LENGTH); initError = XILINX_FMC_enable_all(initErrorMessage, MAX_STR_LENGTH);
if (initError == FAIL) { if (initError == FAIL) {

View File

@@ -804,7 +804,7 @@ typedef struct {
} }
sls_detector_module &operator=(const sls_detector_module &other) { sls_detector_module &operator=(const sls_detector_module &other) {
if(this == &other) if (this == &other)
return *this; return *this;
delete[] dacs; delete[] dacs;
delete[] chanregs; delete[] chanregs;

View File

@@ -7,6 +7,6 @@
#define APIGOTTHARD2 "0.0.0 0x250909" #define APIGOTTHARD2 "0.0.0 0x250909"
#define APIMOENCH "0.0.0 0x250909" #define APIMOENCH "0.0.0 0x250909"
#define APIEIGER "0.0.0 0x250909" #define APIEIGER "0.0.0 0x250909"
#define APIXILINXCTB "0.0.0 0x260105" #define APIXILINXCTB "0.0.0 0x260106"
#define APIJUNGFRAU "0.0.0 0x250909" #define APIJUNGFRAU "0.0.0 0x250909"
#define APIMYTHEN3 "0.0.0 0x250922" #define APIMYTHEN3 "0.0.0 0x250922"