Skip to content

Commit

Permalink
Changed the sprintf() call to snprintf() and added an if-statement to…
Browse files Browse the repository at this point in the history
… check whether the number of characters intended to be written to the destination buffer exceed the size of the buffer. This prevents GCC 8.3.0 from warning that the destination buffer may not be large enough to store the contents of the source buffers. These changes were tested on the Intel Haswell architecture.
  • Loading branch information
dbarry9 committed Jun 10, 2019
1 parent 6355ef5 commit c181111
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ int main( int argc, char **argv ) {
/* Default domain should work */

/* Add our uncore event */
sprintf(uncore_event,"%s%d::%s",uncore_base,j,event_name);
retval = snprintf(uncore_event, BUFSIZ, "%s%d::%s",uncore_base,j,event_name);
if( retval >= BUFSIZ ){
fprintf(stderr,"Event full name \"%s%d::%s\" has been truncated to \"%s\"\n",uncore_base,j,event_name, uncore_event);
}
retval = PAPI_add_named_event(EventSet[j][i], uncore_event);
if (retval != PAPI_OK) {
max_cbox=j;
Expand Down

0 comments on commit c181111

Please sign in to comment.