Skip to content

Commit 748f678

Browse files
committed
ROCm 7.x fix error and warnings
1 parent e214eaf commit 748f678

3 files changed

Lines changed: 26 additions & 13 deletions

File tree

src/access-daemon/appDaemon.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ static void prepare_ldpreload()
8484
bconchar(new_bldpre, ':');
8585
}
8686
}
87-
setenv("LD_PRELOAD", bdata(new_bldpre), 1);
87+
char* new_bldpre_c = NULL;
88+
if (bdata(new_bldpre) != NULL) {
89+
new_bldpre_c = bdata(new_bldpre);
90+
}
91+
setenv("LD_PRELOAD", new_bldpre_c, 1);
8892
bstrListDestroy(liblist);
8993
bdestroy(new_bldpre);
9094
bdestroy(bldpre);

src/rocmon.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,8 @@ static rocprofiler_tool_configure_result_t *rocprofiler_configure_private(
218218
id->name = "LIKWID rocmon";
219219

220220
const uint32_t major = version / 10000;
221-
const uint32_t minor = (version % 10000) / 100;
222-
const uint32_t patch = version % 100;
223221

224222
assert(major == 1);
225-
assert(minor == 0);
226-
assert(patch == 0);
227223

228224
static rocprofiler_tool_configure_result_t cfg = {
229225
sizeof(cfg),
@@ -454,7 +450,7 @@ static int smi_event_add_impl(const char *name, RocmonSmiEventType type, const c
454450
list->numEntries = newNumEntries;
455451
list->entries = newEntries;
456452

457-
snprintf(newEvent->name, sizeof(newEvent->name), "%s", name);
453+
snprintf(newEvent->name, sizeof(newEvent->name)-1, "%s", name);
458454
newEvent->type = type;
459455
newEvent->variant = variant;
460456
newEvent->subvariant = subvariant;
@@ -491,8 +487,14 @@ static int smi_events_add_avail(RocmonDevice *device, RocmonSmiEventType type, c
491487

492488
if (type == ROCMON_SMI_EVENT_TYPE_INSTANCES) {
493489
// For instanced events (like sensor lists), create a list of events
494-
snprintf(
495-
availEvent->name, sizeof(availEvent->name), "%s[%zu]", implEvent->name, subvariant);
490+
int len = snprintf(availEvent->name,
491+
sizeof(availEvent->name),
492+
"%s[%zu]",
493+
implEvent->name, subvariant);
494+
if (len < 0) {
495+
ERROR_PRINT("Failed to add subvariant %zu to event %s\n", subvariant, implEvent->name);
496+
continue;
497+
};
496498
availEvent->subvariant = subvariant;
497499
} else {
498500
assert(subvariant == implEvent->subvariant);

src/rocmon_marker.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,13 @@ static int gpulist_from_str(const char *gpustring, size_t *numGpus, int **gpus)
131131
*numGpus = gpustrings->qty;
132132
*gpus = newGpus;
133133

134-
for (int i = 0; i < gpustrings->qty; i++)
135-
newGpus[i] = atoi(bdata(gpustrings->entry[i]));
134+
for (int i = 0; i < gpustrings->qty; i++) {
135+
char* s = NULL;
136+
if (bdata(gpustrings->entry[i]) != NULL) {
137+
s = bdata(gpustrings->entry[i]);
138+
}
139+
newGpus[i] = atoi(s);
140+
}
136141

137142
cleanup:
138143
if (err < 0)
@@ -291,7 +296,7 @@ int rocmon_markerInit(void)
291296
perfmon_setVerbosity(atoi(debugStr));
292297

293298
int *gpuIds = NULL;
294-
size_t numGpuIds;
299+
size_t numGpuIds = 0;
295300
err = gpulist_from_str(gpuStr, &numGpuIds, &gpuIds);
296301
if (err < 0)
297302
goto unlock_err;
@@ -1034,6 +1039,7 @@ int rocmon_markerWriteFile(const char *markerfile)
10341039

10351040
int rocmon_markerInitResultsFromFile(const char *markerfile)
10361041
{
1042+
FILE *fp = NULL;
10371043
pthread_mutex_lock(&rocmarker_init_mutex);
10381044

10391045
int err = 0;
@@ -1056,7 +1062,7 @@ int rocmon_markerInitResultsFromFile(const char *markerfile)
10561062

10571063
rocmarker_ctx->main_tid = DUMMY_TID;
10581064

1059-
FILE *fp = fopen(markerfile, "r");
1065+
fp = fopen(markerfile, "r");
10601066
if (!fp) {
10611067
err = -errno;
10621068
goto unlock_err;
@@ -1148,7 +1154,8 @@ int rocmon_markerInitResultsFromFile(const char *markerfile)
11481154
}
11491155
}
11501156

1151-
fscanf(fp, "\n");
1157+
int d = fscanf(fp, "\n");
1158+
d++;
11521159
}
11531160

11541161
// Read regions: 'regionIdx groupId regionTag'

0 commit comments

Comments
 (0)