I have warning: FormatFunction. c: In function 'ComputeStiffnessMatrix': FormatFunction. c: 128: 46: warning: '%d' directive writing between 1 and 11 bytes into a region of size between 0 and 99 [-Wformat-overflow] (line128) sprintf(filename,
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
I have warning:
FormatFunction.c: In function 'ComputeStiffnessMatrix':
FormatFunction.c:128:46: warning: '%d' directive writing between 1 and 11 bytes into a region of size between 0 and 99 [-Wformat-overflow]
(line128) sprintf(filename, "%sc%d_N%dM%d_permeability.log", up->problem_description, up->problem_flag, up->Nx, up->Mx)
do you know why this warning appear? and how to fix it.
You are writing a PetscInt into the spot for an int. You can
1) Cast to int:
sprintf(filename, "%sc%d_N%dM%d_permeability.log", up->problem_description, up->problem_flag, (int)up->Nx, (int)up->Mx)
2) Use the custom format
sprintf(filename, "%sc%d_N%" PetscInt_FMT "M%" PetscInt_FMT "_permeability.log", up->problem_description, up->problem_flag, up->Nx, up->Mx)
Thanks,
Matt