[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] does it work corrretly?



they possibly could be bugs but i did not go over what you mentioned.
Dont expect ns to be a fully supported product!

If you are going over the mobile ad hoc code, you might also want to be
aware of the fact that some code is embedded in ASSERT() statements.
The compiler leaves out assert statements if -NODEBUG is specified in
the makefile. Hence this code does not get compiled at all!!!!
Embedding code in asserts is not a good idea.

We did run into a situation once when we removed -NODEBUG and got the
correct results.

Aman


On Tue, 22 May 2001, HE Jun wrote:

> Hi, everyone:
> 
> I'm reading the source code of NS. I'm really bewildered by some codes. Here is an example (from agent.cc)
> 
> Agent::~Agent()
> {
>          if (oldValueList_ != NULL) {
>                   OldValue *p;            // dynamic variable, not initialized
>                   while (oldValueList_ != NULL) {
>                        oldValueList_ = oldValueList_->next_;
>                        delete p;            // does it work for the first element??????
>                        p = oldValueList_; 
>                   }
>          }
> }
> 
> Obviously the intention of the destructior is to delete all the element in the list.  But the first element will never be deleted because p has not been initialized.  
> 
> Another example (from DSDV_agent):
> 
> int DSDV_Agent::command (int argc, const char *const *argv)
> {
>       if (argc == 2)
>         {
>               if (strcmp (argv[1], "start-dsdv") == 0)
>              {    
>                     ..........................
>              }
>              else if (strcmp (argv[1], "dumprtab") == 0)
>              {
>             .............................
>              }
>            
>               else if (strcasecmp (argv[1], "ll-queue") == 0)
>              {
>                          if (!(ll_queue = (PriQueue *) TclObject::lookup (argv[2])))                // ??????????????????
>                          {
>                                    fprintf (stderr, "DSDV_Agent: ll-queue lookup of %s failed\n", argv[2]);
>                                    return TCL_ERROR;
>                          }
>                        return TCL_OK;
>              }
> 
>     }
>   else if (argc == 3)
>    {
>         ..........................................
>     }
>   
>   return (Agent::command (argc, argv));
> }
> 
> 
> in the line
>                          if (!(ll_queue = (PriQueue *) TclObject::lookup (argv[2])))
> what is the vaule in argv[2] since it has only two arguments.  ??????????
> 
> 
> Are they bugs ?
> 
> HE  Jun
>