Skip to content

Commit c6a77cc

Browse files
committed
Clean up some compiler warnings
`gcc-13 -Wall ...` found a few places we were possibly overrunning arrays
1 parent 21831c9 commit c6a77cc

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

darshan-runtime/lib/darshan-core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ static void darshan_get_exe_and_mounts(struct darshan_core_runtime *core,
11201120
static int darshan_should_instrument_app(struct darshan_core_runtime *core)
11211121
{
11221122
char *tmp_str;
1123-
char *app_name;
1123+
char *app_name=NULL;
11241124
struct darshan_core_regex *app_regex;
11251125
int app_excluded = 0, app_included = 0;
11261126

@@ -2064,7 +2064,8 @@ void darshan_log_finalize(char *logfile_name, double start_log_time)
20642064
if(new_logfile_name)
20652065
{
20662066
/* copy partial log file name over to new string */
2067-
strncpy(new_logfile_name, logfile_name, __DARSHAN_PATH_MAX);
2067+
strncpy(new_logfile_name, logfile_name, __DARSHAN_PATH_MAX-1);
2068+
new_logfile_name[__DARSHAN_PATH_MAX-1] = '\0';
20682069
/* retrieve current time stamp */
20692070
end_log_time = darshan_core_wtime_absolute();
20702071
/* find location of .darshan_partial extension */

darshan-util/darshan-diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int main(int argc, char *argv[])
6161
struct darshan_mod_record_ref *mod_rec1, *mod_rec2;
6262
void *mod_buf1, *mod_buf2;
6363
struct darshan_base_record *base_rec1, *base_rec2;
64-
char *file_name1, *file_name2;
64+
char *file_name1=NULL, *file_name2=NULL;
6565
int i;
6666
int ret;
6767

darshan-util/darshan-hdf5-logutils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ static void darshan_log_agg_hdf5_files(void *rec, void *agg_rec, int init_flag)
653653
break;
654654
case H5F_F_META_TIME:
655655
/* sum */
656-
agg_hdf5_rec->counters[i] += hdf5_rec->counters[i];
656+
agg_hdf5_rec->fcounters[i] += hdf5_rec->fcounters[i];
657657
break;
658658
default:
659659
agg_hdf5_rec->fcounters[i] = -1;

darshan-util/darshan-logutils.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ darshan_fd darshan_log_open(const char *name)
163163
free(tmp_fd);
164164
return(NULL);
165165
}
166-
strncpy(tmp_fd->state->logfile_path, name, __DARSHAN_PATH_MAX);
166+
strncpy(tmp_fd->state->logfile_path, name, __DARSHAN_PATH_MAX-1);
167+
tmp_fd->state->logfile_path[__DARSHAN_PATH_MAX-1] = '\0';
167168

168169
/* read the header from the log file to init fd data structures */
169170
ret = darshan_log_get_header(tmp_fd);
@@ -229,7 +230,8 @@ darshan_fd darshan_log_create(const char *name, enum darshan_comp_type comp_type
229230
}
230231
tmp_fd->state->creat_flag = 1;
231232
tmp_fd->partial_flag = partial_flag;
232-
strncpy(tmp_fd->state->logfile_path, name, __DARSHAN_PATH_MAX);
233+
strncpy(tmp_fd->state->logfile_path, name, __DARSHAN_PATH_MAX-1);
234+
tmp_fd->state->logfile_path[__DARSHAN_PATH_MAX-1] = '\0';
233235

234236
/* position file pointer to prealloc space for the log file header
235237
* NOTE: the header is written at close time, after all internal data

0 commit comments

Comments
 (0)