GIDForums  

Go Back   GIDForums > Computer Forums > Computer Software Forum - Linux
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 29-Jan-2008, 19:27
nasim751 nasim751 is offline
New Member
 
Join Date: Jan 2008
Posts: 12
nasim751 is on a distinguished road
Question

Warning: passing argument 3 of ‘pt_search_r’ from incompatible pointer type


int
pt_insert(struct pt_context *pt, struct tcp_connection *c)
{
struct pt_node *rn = NULL;
u_char key1[KEY_BYTES], key2[KEY_BYTES];
int b;

if (pt->head == NULL)
{
/* make a new head node */
pt->head = pt_new(MIN_KEY_BIT -1, NULL, NULL, c);
if (pt->head == NULL)
{
perror("pt_insert(): malloc(): ");
return (0);
}
else
{
/* increment node counter and return success */
pt->n++;
return (1);
}
}
else
{
memset(key1, NULL, KEY_BYTES);
pt_make_key(key1, c);

switch (pt_search_r(pt->head, key1, &*rn))
{
case 0:
memset(key2, NULL, KEY_BYTES);
pt_make_key(key2, rn->con);

/* find the first differing bit, and its value */
rn->bit = diff_bit(key1, key2, &b);

...2... if (((b ? rn->r : rn->l) == pt_new(MIN_KEY_BIT - 1, NULL, NULL, c)) == NULL)
{
return (0);
}

..3.. if (((b ? rn->l : rn->r) == pt_new(MIN_KEY_BIT - 1, NULL, NULL, rn->con)) == NULL)
{
free(b ? rn->r : rn->l);
return (0);
}
rn->con = NULL;

pt->n += 2;
return (1);
case 1:
return (2);
}
}
return (0);
}

these three red line i am getting warning like this.
1. warning: passing argument 3 of ‘pt_search_r’ from incompatible pointer type
2.comparison between pointer and integer
3.comparison between pointer and integer
how can i solve this problem?
  #2  
Old 29-Jan-2008, 22:01
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,693
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: warning: passing argument 3 of ‘pt_search_r’ from incompatible pointer type


Quote:
Originally Posted by nasim751
1. warning: passing argument 3 of ‘pt_search_r’ from incompatible pointer type
Well, did you look at it:

CPP / C++ / C Code:
        switch (pt_search_r(pt->head, key1, &*rn))
What the heck is &*rn?
You've got to be kidding, right? If the argument takes a pointer to pointer to pt_node and rn is a pointer to pt_node, then wouldn't you use &rn as the argument? I mean, really...
Quote:
Originally Posted by nasim751
if (((b ? rn->l : rn->r) == pt_new(MIN_KEY_BIT - 1, NULL, NULL, rn->con)) == NULL)
The message is about the last NULL (The arguments to the function take pointers, so the first twoNULLs are OK.)
NULL is a pointer, not an integer. (Converting NULL to an integer may give a value of zero, but if you want to see if the value of an expression is equal zero, use zero, not NULL. Unlike the first message, I think that the second and third are not fatal, but the idea is to get rid of the warnings by using the proper notation.


Regards,

Dave

Footnote: Since this is a continuation of your previous question (I assume it is the same program), the proper protocol is to continue on the same thread, not start at new one. Not a big deal, but think about it next time.
  #3  
Old 30-Jan-2008, 00:26
nasim751 nasim751 is offline
New Member
 
Join Date: Jan 2008
Posts: 12
nasim751 is on a distinguished road

Re: Warning: passing argument 3 of ‘pt_search_r’ from incompatible pointer type


Many thanks for feedback.
Nasim
 
 

Recent GIDBlogMeeting the local Iraqis by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
double concatenated dynamic list - different type assignment warning dlp C Programming Language 11 01-Jun-2007 07:59
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 13:12
Pointer Usage in C++: Beginner to Advanced varunhome C++ Forum 0 19-Aug-2005 09:25
C++ PhoneBook marita C++ Forum 46 12-Jun-2005 12:10
[Tutorial] Pointers in C (Part II) Stack Overflow C Programming Language 0 27-Apr-2005 17:36

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 19:12.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.