Also ensure filename is a sufficiently long string to hold any possible output from the format. On Jul 12, 2024, at 6: 53 AM, Matthew Knepley <knepley@ gmail. com> wrote: ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍ ‍
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
 
ZjQcmQRYFpfptBannerEnd

   Also ensure filename is a sufficiently long string to hold any possible output from the format.



On Jul 12, 2024, at 6:53 AM, Matthew Knepley <knepley@gmail.com> wrote:

This Message Is From an External Sender
This message came from outside your organization.
On Fri, Jul 12, 2024 at 2:26 AM Ivan Luthfi <ivanluthfi5@gmail.com> wrote:
This Message Is From an External Sender
This message came from outside your organization.
 
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
 
-- 
Best regards,
--


-- 
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener