[petsc-dev] Should MatRestoreRow zeroes cols and vals?

Jed Brown jedbrown at mcs.anl.gov
Fri Apr 19 13:06:14 CDT 2013


Patrick Lacasse <patrick.m.lacasse at gmail.com> writes:

> Hi,
>
>    For some types of matrices,
> MatRestoreRow zeroes pointer cols and vals (MatRestoreRow_SeqBAIJ),
> and for other not (MatRestoreRow_SeqAIJ).
> Should it always put them to NULL ?
> It would help us prevent misuses.

Yes, thanks for pointing this out.  We had a few questionable constructs
ourselves.  These are in 'next' now.

commit 4b4408bbb6af7ebe4b0bfb87714e390b6edcba7c
Author: Jed Brown <jed at 59A2.org>
Date:   Fri Apr 19 10:52:20 2013 -0500

    MatRestoreRow: zero arguments after restore to catch accidental misuse
    
    Explicitly pass NULL when we are intentionally using the number of
    columns after restoring the row.

 src/dm/impls/composite/packm.c | 2 +-
 src/ksp/pc/impls/asa/asa.c     | 2 +-
 src/mat/interface/matrix.c     | 3 +++
 3 files changed, 5 insertions(+), 2 deletions(-)

commit 9383aa0518031aa36d3d785a7263101f32ea5006
Author: Jed Brown <jed at 59A2.org>
Date:   Fri Apr 19 10:55:56 2013 -0500

    MatRestoreRowIJ/ColumnIJ: zero pointers to catch accidental misuse
    
    Only zero in case where the operation is "done" so that user's
    uninitialized arguments are not overwritten.  I don't know if it's
    best, but this is consistent with done=FALSE meaning that the arguments
    are not changed.
    
    Explicitly pass NULL when intentionally using the number of rows after
    restoring.

 src/dm/impls/da/hypre/mhyp.c  |  2 +-
 src/mat/color/color.c         | 12 ++++++------
 src/mat/examples/tests/ex22.c |  2 +-
 src/mat/interface/matrix.c    |  6 ++++++
 src/mat/order/amd/amd.c       |  2 +-
 src/mat/order/sorder.c        |  4 ++--
 src/mat/order/sp1wd.c         |  2 +-
 src/mat/order/spnd.c          |  2 +-
 src/mat/order/spqmd.c         |  2 +-
 src/mat/order/sprcm.c         |  2 +-
 10 files changed, 21 insertions(+), 15 deletions(-)



More information about the petsc-dev mailing list