Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove/rework print macros #658

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/access-daemon/accessDaemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -2642,7 +2642,7 @@ kill_client(void)
{
if (connfd != -1)
{
CHECK_ERROR(close(connfd), socket close failed);
CHECK_ERROR(close(connfd), "socket close failed");
}

connfd = -1;
Expand All @@ -2655,7 +2655,7 @@ stop_daemon(void)

if (sockfd != -1)
{
CHECK_ERROR(close(sockfd), socket close sockfd failed);
CHECK_ERROR(close(sockfd), "socket close sockfd failed");
}

free(filepath);
Expand Down Expand Up @@ -3819,7 +3819,7 @@ int main(void)
/* Change the file mode mask so only the calling user has access
* and switch the user/gid with which the following socket creation runs. */
oldumask = umask(077);
CHECK_ERROR(setfsuid(getuid()), setfsuid failed);
CHECK_ERROR(setfsuid(getuid()), "setfsuid failed");

/* bind and listen on socket */
LOG_AND_EXIT_IF_ERROR(bind(sockfd, (SA*) &addr1, sizeof(addr1)), bind failed);
Expand Down Expand Up @@ -3851,16 +3851,16 @@ int main(void)
{
syslog(LOG_ERR, "accept() failed: %s", strerror(errno));
}
CHECK_ERROR(unlink(filepath), unlink of socket failed);
CHECK_ERROR(unlink(filepath), "unlink of socket failed");
exit(EXIT_FAILURE);
}

alarm(0);
CHECK_ERROR(unlink(filepath), unlink of socket failed);
CHECK_ERROR(unlink(filepath), "unlink of socket failed");

/* Restore the old umask and fs ids. */
(void) umask(oldumask);
CHECK_ERROR(setfsuid(geteuid()), setfsuid failed);
CHECK_ERROR(setfsuid(geteuid()), "setfsuid failed");

{
char* msr_file_name = (char*) malloc(MAX_PATH_LENGTH * sizeof(char));
Expand Down
32 changes: 16 additions & 16 deletions src/access-daemon/appDaemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static int appdaemon_setup_nvmon(char* gpuStr, char* eventStr)
ret = parse_gpustr(gpuStr, &nvmon_numgpus, &nvmon_gpulist);
if (ret < 0)
{
ERROR_PRINT(Failed to get nvmon gpulist from '%s', gpuStr);
ERROR_PRINT("Failed to get nvmon gpulist from '%s'", gpuStr);
goto appdaemon_setup_nvmon_cleanup;
}

Expand All @@ -175,15 +175,15 @@ static int appdaemon_setup_nvmon(char* gpuStr, char* eventStr)
nvmon_gids = malloc(nvmon_eventlist->qty * sizeof(int));
if (!nvmon_gids)
{
ERROR_PRINT(Failed to allocate space for nvmon group IDs);
ERROR_PRINT("Failed to allocate space for nvmon group IDs");
goto appdaemon_setup_nvmon_cleanup;
}

// Init nvmon
ret = nvmon_init(nvmon_numgpus, nvmon_gpulist);
if (ret < 0)
{
ERROR_PRINT(Failed to initialize nvmon);
ERROR_PRINT("Failed to initialize nvmon");
goto appdaemon_setup_nvmon_cleanup;
}
nvmon_initialized = 1;
Expand All @@ -194,30 +194,30 @@ static int appdaemon_setup_nvmon(char* gpuStr, char* eventStr)
ret = nvmon_addEventSet(bdata(nvmon_eventlist->entry[i]));
if (ret < 0)
{
ERROR_PRINT(Failed to add nvmon group: %s, bdata(nvmon_eventlist->entry[i]));
ERROR_PRINT("Failed to add nvmon group: %s", bdata(nvmon_eventlist->entry[i]));
continue;
}
nvmon_gids[nvmon_numgids++] = ret;
}
if (nvmon_numgids == 0)
{
ERROR_PRINT(Failed to add any events to nvmon);
ERROR_PRINT("Failed to add any events to nvmon");
goto appdaemon_setup_nvmon_cleanup;
}

// Setup counters
ret = nvmon_setupCounters(nvmon_gids[0]);
if (ret < 0)
{
ERROR_PRINT(Failed to setup nvmon);
ERROR_PRINT("Failed to setup nvmon");
goto appdaemon_setup_nvmon_cleanup;
}

// Start counters
ret = nvmon_startCounters();
if (ret < 0)
{
ERROR_PRINT(Failed to start nvmon);
ERROR_PRINT("Failed to start nvmon");
goto appdaemon_setup_nvmon_cleanup;
}
return 0;
Expand Down Expand Up @@ -253,7 +253,7 @@ static void appdaemon_close_nvmon(void)
int ret = nvmon_stopCounters();
if (ret < 0)
{
ERROR_PRINT(Failed to stop nvmon);
ERROR_PRINT("Failed to stop nvmon");
}

// Print results
Expand Down Expand Up @@ -335,7 +335,7 @@ static int appdaemon_setup_rocmon(char* gpuStr, char* eventStr)
ret = parse_gpustr(gpuStr, &rocmon_numgpus, &rocmon_gpulist);
if (ret < 0)
{
ERROR_PRINT(Failed to get rocmon gpulist from '%s', gpuStr);
ERROR_PRINT("Failed to get rocmon gpulist from '%s'", gpuStr);
goto appdaemon_setup_rocmon_cleanup;
}

Expand All @@ -346,15 +346,15 @@ static int appdaemon_setup_rocmon(char* gpuStr, char* eventStr)
rocmon_gids = malloc(rocmon_eventlist->qty * sizeof(int));
if (!rocmon_gids)
{
ERROR_PRINT(Failed to allocate space for rocmon group IDs);
ERROR_PRINT("Failed to allocate space for rocmon group IDs");
goto appdaemon_setup_rocmon_cleanup;
}

// Init rocmon
ret = rocmon_init(rocmon_numgpus, rocmon_gpulist);
if (ret < 0)
{
ERROR_PRINT(Failed to initialize rocmon);
ERROR_PRINT("Failed to initialize rocmon");
goto appdaemon_setup_rocmon_cleanup;
}
rocmon_initialized = 1;
Expand All @@ -365,28 +365,28 @@ static int appdaemon_setup_rocmon(char* gpuStr, char* eventStr)
ret = rocmon_addEventSet(bdata(rocmon_eventlist->entry[i]), &rocmon_gids[rocmon_numgids++]);
if (ret < 0)
{
ERROR_PRINT(Failed to add rocmon group: %s, bdata(rocmon_eventlist->entry[i]));
ERROR_PRINT("Failed to add rocmon group: %s", bdata(rocmon_eventlist->entry[i]));
}
}
if (rocmon_numgids == 0)
{
ERROR_PRINT(Failed to add any events to rocmon);
ERROR_PRINT("Failed to add any events to rocmon");
goto appdaemon_setup_rocmon_cleanup;
}

// Setup counters
ret = rocmon_setupCounters(rocmon_gids[0]);
if (ret < 0)
{
ERROR_PRINT(Failed to setup rocmon);
ERROR_PRINT("Failed to setup rocmon");
goto appdaemon_setup_rocmon_cleanup;
}

// Start counters
ret = rocmon_startCounters();
if (ret < 0)
{
ERROR_PRINT(Failed to start rocmon);
ERROR_PRINT("Failed to start rocmon");
goto appdaemon_setup_rocmon_cleanup;
}
return 0;
Expand Down Expand Up @@ -422,7 +422,7 @@ static void appdaemon_close_rocmon(void)
int ret = rocmon_stopCounters();
if (ret < 0)
{
ERROR_PRINT(Failed to stop rocmon);
ERROR_PRINT("Failed to stop rocmon");
}

// Print results
Expand Down
16 changes: 8 additions & 8 deletions src/access.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ HPMinit(void)
if (ret < 0)
{
errno = -ret;
ERROR_PRINT(Failed to initialize topology);
ERROR_PRINT("Failed to initialize topology");
return ret;
}
ret = init_configuration();
if (ret < 0)
{
errno = -ret;
ERROR_PRINT(Failed to initialize configuration);
ERROR_PRINT("Failed to initialize configuration");
return ret;
}
config = get_configuration();
Expand All @@ -110,7 +110,7 @@ HPMinit(void)
}
if (config->daemonMode == ACCESSMODE_DAEMON)
{
DEBUG_PLAIN_PRINT(DEBUGLEV_DEVELOP, Adjusting functions for x86 architecture in daemon mode);
DEBUG_PRINT(DEBUGLEV_DEVELOP, "Adjusting functions for x86 architecture in daemon mode");
access_init = &access_client_init;
access_read = &access_client_read;
access_write = &access_client_write;
Expand All @@ -119,7 +119,7 @@ HPMinit(void)
}
else if (config->daemonMode == ACCESSMODE_DIRECT)
{
DEBUG_PLAIN_PRINT(DEBUGLEV_DEVELOP, Adjusting functions for x86 architecture in direct mode);
DEBUG_PRINT(DEBUGLEV_DEVELOP, "Adjusting functions for x86 architecture in direct mode");
access_init = &access_x86_init;
access_read = &access_x86_read;
access_write = &access_x86_write;
Expand All @@ -128,7 +128,7 @@ HPMinit(void)
}
else
{
DEBUG_PLAIN_PRINT(DEBUGLEV_DEVELOP, HPMinit called in perf_event mode);
DEBUG_PRINT(DEBUGLEV_DEVELOP, "HPMinit called in perf_event mode");
}
#endif
}
Expand Down Expand Up @@ -159,7 +159,7 @@ HPMaddThread(int cpu_id)
ret = access_init(cpu_id);
if (ret == 0)
{
DEBUG_PRINT(DEBUGLEV_DETAIL, Adding CPU %d to access module, cpu_id);
DEBUG_PRINT(DEBUGLEV_DETAIL, "Adding CPU %d to access module", cpu_id);
registeredCpus++;
registeredCpuList[cpu_id] = 1;
}
Expand All @@ -186,7 +186,7 @@ HPMfinalize(void)
{
if (registeredCpuList[i] == 1)
{
DEBUG_PRINT(DEBUGLEV_DETAIL, Removing CPU %d from access module, i);
DEBUG_PRINT(DEBUGLEV_DETAIL, "Removing CPU %d from access module", i);
access_finalize(i);
registeredCpus--;
registeredCpuList[i] = 0;
Expand Down Expand Up @@ -242,7 +242,7 @@ HPMwrite(int cpu_id, PciDeviceIndex dev, uint32_t reg, uint64_t data)
}
if ((cpu_id < 0) || (cpu_id >= cpuid_topology.numHWThreads))
{
ERROR_PRINT(MSR WRITE C %d OUT OF RANGE, cpu_id);
ERROR_PRINT("MSR WRITE C %d OUT OF RANGE", cpu_id);
return -ERANGE;
}
if (registeredCpuList[cpu_id] == 0)
Expand Down
Loading
Loading