?
Solved

Why it show when i complie this program with rpc function?

Posted on 2003-02-27
5
Medium Priority
?
336 Views
Last Modified: 2012-05-04
Somebody can help me!! :-)
Why it show when i complie this program with rpc function?
server.c:19: dereferencing pointer to incomplete type!!

server.c:
#include ....

bool_t
squareproc_2_svc(square_in *inp,square_out *outp,struct     svc_req *rqstp)
{
     printf("thread %ld started,arg=%ld,auth=%d\n",pr_thread_id(NULL),inp->arg1,rqstp->rq_cred.oa_flavor);
     
     if(rqstp->rq_cred.oa_flavor==AUTH_SYS)
     {
          struct     authsys_parms     *au;
         
          au=(struct authsys_parms *)rqstp->rq_clntcred;
//#line 19    
          printf("AUTH_SYS:host %s,uid %ld,gid %ld\n",au->aup_machname,au->aup_uid,au->aup_gid);
     }
     
     sleep(5);
     
     outp->res1=inp->arg1*inp->arg1;
     
     printf("thread %ld done\n",pr_thread_id(NULL));
     
     return(TRUE);
}

int    
square_prog_2_freeresult(SVCXPRT *transp,xdrproc_t xdr_result,caddr_t result)
{
     xdr_free(xdr_result,result);
     
     return(1);
}

mail:great_liudan@hotmail.com
0
Comment
Question by:liudan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:rfr1tz
ID: 8042923
So you think this is an easy problem? I think it's a homework problem.

However, assuming that line 19 is the printf statement, au is a pointer to an authsys_parms structure and then you point it at rqstp->rq_clntcred by type casting.

So au is pointing at rqstp->rq_clntcred.... (whatever that is.) But then you try to print out fields from au. But au is pointing at some junk (rqstp->rq_clntred) which I am sure is not a authsys_parms structure. So boom, you blow up.

By the way, I don't know who's picking your variable names (I know some are system names), but they are just awful - the code looks like it's encrypted.

0
 
LVL 5

Accepted Solution

by:
bryanh earned 200 total points
ID: 8045443
No, rfr1tz, that's not it.  This is a compilation failure.  The compiler has no way to know (and neither do you) that rqstp->rq_clntcred is not a struct authsys_parms.  The coder has explicitly said (via that type cast) that it is, and the compiler believes it.

The problem is that the compiler doesn't know what struct authsys_parms is.  So it can't access the "aup_machname" field of it.  The structure has not been declared.

It is presumably supposed to be declared in one of the elided (omitted) #include statements.  But the compiler is telling is that it isn't.
0
 
LVL 5

Expert Comment

by:bryanh
ID: 8045445
And by the way, I should mention that this is not a Linux programming question.  It's a C language question.
0
 
LVL 3

Expert Comment

by:rfr1tz
ID: 8056921
hmm, you're right bryanh, I'm wrong. As she mentions, it's a compile time problem. I was fooled by which line is line 19. I assumed it was the printf statement.
0
 

Author Comment

by:liudan
ID: 8076680
Thank you!!
I find the reason:gcc complier can't find struct authsys_parms.

struct authsys_parms {
         u_long aup_stamp;
         char *aup_machinename;
         uid_t aup_uid;
         gid_t aup_gid;
         u_int aup_len;
         gid_t *aup_gids;
      };

So i replace struct authsys_parms with struct authunix_parms in rpc/auth_unix.h.

/*
 * Unix style credentials.
 */
struct authunix_parms
  {
    u_long aup_time;
    char *aup_machname;
    __uid_t aup_uid;
    __gid_t aup_gid;
    u_int aup_len;
    __gid_t *aup_gids;
  };

This problem is solved~~~!!!
Thank bryanh & rfr1tz!!! Without your help,I can't do it!!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question