You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by "Fred Preston (JIRA)" <ax...@ws.apache.org> on 2004/12/09 14:02:26 UTC

[jira] Created: (AXISCPP-318) Checking that pointers are valid before using

Checking that pointers are valid before using
---------------------------------------------

         Key: AXISCPP-318
         URL: http://nagoya.apache.org/jira/browse/AXISCPP-318
     Project: Axis-C++
        Type: Improvement
  Components: Basic Architecture  
    Versions: 1.5 Alpha    
 Environment: n/a
    Reporter: Fred Preston


Pointer Improvements
--------------------
I would like the following pointer improvements.  This is mainly to do with ensuring that a pointer will always be valid if it is not NULL.

Rule1
=====
On creation, unless a pointer is assigned a value it must be set to NULL.

example:
Test * pTest = NULL;
or
Test * pTest = new Test();

Rule2
=====
Before using a pointer, it is tested to check that it is not NULL.

example:
if( pTest != NULL)
{
  bool bResult = pTest->method1( iValue);
}
or
if( pTest != NULL)
{
  bool bResult = pTest->method1( iValue);

  if( bResult == true)
  {
    pTest->method2( sValue);
  }
}

Rule3
=====
On deletion, the pointer is set to NULL.

example:
if( pTest != NULL)
{
  delete pTest;

  pTest = NULL;
}


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-318) Checking that pointers are valid before using

Posted by "John Hawkins (JIRA)" <ax...@ws.apache.org>.
    [ http://issues.apache.org/jira/browse/AXISCPP-318?page=comments#action_12315911 ] 

John Hawkins commented on AXISCPP-318:
--------------------------------------

Is this still an issue - looks like we've done a code-trawl?

> Checking that pointers are valid before using
> ---------------------------------------------
>
>          Key: AXISCPP-318
>          URL: http://issues.apache.org/jira/browse/AXISCPP-318
>      Project: Axis-C++
>         Type: Improvement
>   Components: Basic Architecture
>     Versions: 1.5 Alpha
>  Environment: n/a
>     Reporter: Fred Preston

>
> Pointer Improvements
> --------------------
> I would like the following pointer improvements.  This is mainly to do with ensuring that a pointer will always be valid if it is not NULL.
> Rule1
> =====
> On creation, unless a pointer is assigned a value it must be set to NULL.
> example:
> Test * pTest = NULL;
> or
> Test * pTest = new Test();
> Rule2
> =====
> Before using a pointer, it is tested to check that it is not NULL.
> example:
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
> }
> or
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
>   if( bResult == true)
>   {
>     pTest->method2( sValue);
>   }
> }
> Rule3
> =====
> On deletion, the pointer is set to NULL.
> example:
> if( pTest != NULL)
> {
>   delete pTest;
>   pTest = NULL;
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-318) Checking that pointers are valid before using

Posted by "Samisa Abeysinghe (JIRA)" <ax...@ws.apache.org>.
     [ http://nagoya.apache.org/jira/browse/AXISCPP-318?page=comments#action_56485 ]
     
Samisa Abeysinghe commented on AXISCPP-318:
-------------------------------------------

Can we use a set of globle macros for this?

> Checking that pointers are valid before using
> ---------------------------------------------
>
>          Key: AXISCPP-318
>          URL: http://nagoya.apache.org/jira/browse/AXISCPP-318
>      Project: Axis-C++
>         Type: Improvement
>   Components: Basic Architecture
>     Versions: 1.5 Alpha
>  Environment: n/a
>     Reporter: Fred Preston

>
> Pointer Improvements
> --------------------
> I would like the following pointer improvements.  This is mainly to do with ensuring that a pointer will always be valid if it is not NULL.
> Rule1
> =====
> On creation, unless a pointer is assigned a value it must be set to NULL.
> example:
> Test * pTest = NULL;
> or
> Test * pTest = new Test();
> Rule2
> =====
> Before using a pointer, it is tested to check that it is not NULL.
> example:
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
> }
> or
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
>   if( bResult == true)
>   {
>     pTest->method2( sValue);
>   }
> }
> Rule3
> =====
> On deletion, the pointer is set to NULL.
> example:
> if( pTest != NULL)
> {
>   delete pTest;
>   pTest = NULL;
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-318) Checking that pointers are valid before using

Posted by "Samisa Abeysinghe (JIRA)" <ax...@ws.apache.org>.
     [ http://nagoya.apache.org/jira/browse/AXISCPP-318?page=comments#action_56571 ]
     
Samisa Abeysinghe commented on AXISCPP-318:
-------------------------------------------

If we are to use macros to help with this task, I propose the use of following:

//for delete
#define DELETE(X) if (X) {delete X; X = NULL;}
//for delete[]
#define DELETEA(X) if (X) {delete [] X; X = NULL;}

//for new
#define NEW(X, TYPE) if (X) {delete X; X = new TYPE;}
//for new[]
#define NEWA(X, TYPE, SIZE) if (X) {delete [] X; X = new TYPE[SIZE];}

However, I am not a big fan of macros - they do *reduce* code redability.
So, shall we say we should write the proper code rather than use macros?


> Checking that pointers are valid before using
> ---------------------------------------------
>
>          Key: AXISCPP-318
>          URL: http://nagoya.apache.org/jira/browse/AXISCPP-318
>      Project: Axis-C++
>         Type: Improvement
>   Components: Basic Architecture
>     Versions: 1.5 Alpha
>  Environment: n/a
>     Reporter: Fred Preston

>
> Pointer Improvements
> --------------------
> I would like the following pointer improvements.  This is mainly to do with ensuring that a pointer will always be valid if it is not NULL.
> Rule1
> =====
> On creation, unless a pointer is assigned a value it must be set to NULL.
> example:
> Test * pTest = NULL;
> or
> Test * pTest = new Test();
> Rule2
> =====
> Before using a pointer, it is tested to check that it is not NULL.
> example:
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
> }
> or
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
>   if( bResult == true)
>   {
>     pTest->method2( sValue);
>   }
> }
> Rule3
> =====
> On deletion, the pointer is set to NULL.
> example:
> if( pTest != NULL)
> {
>   delete pTest;
>   pTest = NULL;
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-318) Checking that pointers are valid before using

Posted by "Chinthana Danapala (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-318?page=comments#action_61180 ]
     
Chinthana Danapala commented on AXISCPP-318:
--------------------------------------------

Me and Dushshantha has gone through the full code base some time before and found some little problems. And we able fixed some as well.

> Checking that pointers are valid before using
> ---------------------------------------------
>
>          Key: AXISCPP-318
>          URL: http://issues.apache.org/jira/browse/AXISCPP-318
>      Project: Axis-C++
>         Type: Improvement
>   Components: Basic Architecture
>     Versions: 1.5 Alpha
>  Environment: n/a
>     Reporter: Fred Preston

>
> Pointer Improvements
> --------------------
> I would like the following pointer improvements.  This is mainly to do with ensuring that a pointer will always be valid if it is not NULL.
> Rule1
> =====
> On creation, unless a pointer is assigned a value it must be set to NULL.
> example:
> Test * pTest = NULL;
> or
> Test * pTest = new Test();
> Rule2
> =====
> Before using a pointer, it is tested to check that it is not NULL.
> example:
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
> }
> or
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
>   if( bResult == true)
>   {
>     pTest->method2( sValue);
>   }
> }
> Rule3
> =====
> On deletion, the pointer is set to NULL.
> example:
> if( pTest != NULL)
> {
>   delete pTest;
>   pTest = NULL;
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Closed: (AXISCPP-318) Checking that pointers are valid before using

Posted by "Samisa Abeysinghe (JIRA)" <ax...@ws.apache.org>.
     [ http://issues.apache.org/jira/browse/AXISCPP-318?page=all ]
     
Samisa Abeysinghe closed AXISCPP-318:
-------------------------------------

    Fix Version: 1.6 Alpha
     Resolution: Fixed

This does not seem to be an issue any more. However these rules must be kept in mind when doing future development .

> Checking that pointers are valid before using
> ---------------------------------------------
>
>          Key: AXISCPP-318
>          URL: http://issues.apache.org/jira/browse/AXISCPP-318
>      Project: Axis-C++
>         Type: Improvement
>   Components: Basic Architecture
>     Versions: 1.5 Alpha
>  Environment: n/a
>     Reporter: Fred Preston
>      Fix For: 1.6 Alpha

>
> Pointer Improvements
> --------------------
> I would like the following pointer improvements.  This is mainly to do with ensuring that a pointer will always be valid if it is not NULL.
> Rule1
> =====
> On creation, unless a pointer is assigned a value it must be set to NULL.
> example:
> Test * pTest = NULL;
> or
> Test * pTest = new Test();
> Rule2
> =====
> Before using a pointer, it is tested to check that it is not NULL.
> example:
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
> }
> or
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
>   if( bResult == true)
>   {
>     pTest->method2( sValue);
>   }
> }
> Rule3
> =====
> On deletion, the pointer is set to NULL.
> example:
> if( pTest != NULL)
> {
>   delete pTest;
>   pTest = NULL;
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-318) Checking that pointers are valid before using

Posted by "Samisa Abeysinghe (JIRA)" <ax...@ws.apache.org>.
     [ http://nagoya.apache.org/jira/browse/AXISCPP-318?page=comments#action_56572 ]
     
Samisa Abeysinghe commented on AXISCPP-318:
-------------------------------------------

Are these rules suggestions for future code, or are we going to fix the existing code as well?
I propose fix the existing code as much as possible.

I could help by fixing some sections.

> Checking that pointers are valid before using
> ---------------------------------------------
>
>          Key: AXISCPP-318
>          URL: http://nagoya.apache.org/jira/browse/AXISCPP-318
>      Project: Axis-C++
>         Type: Improvement
>   Components: Basic Architecture
>     Versions: 1.5 Alpha
>  Environment: n/a
>     Reporter: Fred Preston

>
> Pointer Improvements
> --------------------
> I would like the following pointer improvements.  This is mainly to do with ensuring that a pointer will always be valid if it is not NULL.
> Rule1
> =====
> On creation, unless a pointer is assigned a value it must be set to NULL.
> example:
> Test * pTest = NULL;
> or
> Test * pTest = new Test();
> Rule2
> =====
> Before using a pointer, it is tested to check that it is not NULL.
> example:
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
> }
> or
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
>   if( bResult == true)
>   {
>     pTest->method2( sValue);
>   }
> }
> Rule3
> =====
> On deletion, the pointer is set to NULL.
> example:
> if( pTest != NULL)
> {
>   delete pTest;
>   pTest = NULL;
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (AXISCPP-318) Checking that pointers are valid before using

Posted by "Nadir Amra (JIRA)" <ax...@ws.apache.org>.
     [ http://nagoya.apache.org/jira/browse/AXISCPP-318?page=comments#action_56486 ]
     
Nadir Amra commented on AXISCPP-318:
------------------------------------

Just to make sure I understand, you are saying that:

When code dynamically instantiates an object via new or mallocs storage via malloc, it needs to ensure that it was allocated and return some sort of error if it has not.  

And when dynamic storage is reclaimed via delete or free, it needs to set the pointer to NULL.

And I agree that this can be done via macros, and maybe in the future calls a AXIS C++ memory manager?

> Checking that pointers are valid before using
> ---------------------------------------------
>
>          Key: AXISCPP-318
>          URL: http://nagoya.apache.org/jira/browse/AXISCPP-318
>      Project: Axis-C++
>         Type: Improvement
>   Components: Basic Architecture
>     Versions: 1.5 Alpha
>  Environment: n/a
>     Reporter: Fred Preston

>
> Pointer Improvements
> --------------------
> I would like the following pointer improvements.  This is mainly to do with ensuring that a pointer will always be valid if it is not NULL.
> Rule1
> =====
> On creation, unless a pointer is assigned a value it must be set to NULL.
> example:
> Test * pTest = NULL;
> or
> Test * pTest = new Test();
> Rule2
> =====
> Before using a pointer, it is tested to check that it is not NULL.
> example:
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
> }
> or
> if( pTest != NULL)
> {
>   bool bResult = pTest->method1( iValue);
>   if( bResult == true)
>   {
>     pTest->method2( sValue);
>   }
> }
> Rule3
> =====
> On deletion, the pointer is set to NULL.
> example:
> if( pTest != NULL)
> {
>   delete pTest;
>   pTest = NULL;
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira