]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/plugins/radius/buildreq.c
Fixing GCC warning with unused return value from ftruncate().
[ppp.git] / pppd / plugins / radius / buildreq.c
index 955b05234b8e408513a3d04eb4d04a28da900475..562790aa7887ea8d174021cce062a85abbcf843c 100644 (file)
@@ -94,7 +94,7 @@ unsigned char rc_get_seqnbr(void)
 {
        FILE *sf;
        int tries = 1;
-       int seq_nbr, pos;
+       int seq_nbr, pos, ret;
        char *seqfile = rc_conf_str("seqfile");
 
        if ((sf = fopen(seqfile, "a+")) == NULL)
@@ -135,7 +135,10 @@ unsigned char rc_get_seqnbr(void)
        }
 
        rewind(sf);
-       ftruncate(fileno(sf),0);
+       ret = ftruncate(fileno(sf),0);
+       if (ret != 0) {
+               error("rc_get_seqnbr: couldn't truncate sequence file, %m");
+       }
        fprintf(sf,"%d\n", (seq_nbr+1) & UCHAR_MAX);
 
        fflush(sf); /* fflush because a process may read it between the do_unlock and fclose */
@@ -293,7 +296,7 @@ int rc_acct_using_server(SERVER *acctserver,
        SEND_DATA       data;
        VALUE_PAIR      *adt_vp;
        int             result;
-       time_t          start_time, dtime;
+       struct timeval  start_time, dtime;
        char            msg[4096];
        int             i;
        int             timeout = rc_conf_int("radius_timeout");
@@ -320,11 +323,11 @@ int rc_acct_using_server(SERVER *acctserver,
         * Fill in Acct-Delay-Time
         */
 
-       dtime = 0;
-       if ((adt_vp = rc_avpair_add(&(data.send_pairs), PW_ACCT_DELAY_TIME, &dtime, 0, VENDOR_NONE)) == NULL)
+       dtime.tv_sec = 0;
+       if ((adt_vp = rc_avpair_add(&(data.send_pairs), PW_ACCT_DELAY_TIME, &dtime.tv_sec, 0, VENDOR_NONE)) == NULL)
                return (ERROR_RC);
 
-       start_time = time(NULL);
+       get_time(&start_time);
        result = ERROR_RC;
        for(i=0; (i<acctserver->max) && (result != OK_RC) && (result != BADRESP_RC)
                ; i++)
@@ -336,8 +339,9 @@ int rc_acct_using_server(SERVER *acctserver,
                rc_buildreq(&data, PW_ACCOUNTING_REQUEST, acctserver->name[i],
                            acctserver->port[i], timeout, retries);
 
-               dtime = time(NULL) - start_time;
-               rc_avpair_assign(adt_vp, &dtime, 0);
+               get_time(&dtime);
+               dtime.tv_sec -= start_time.tv_sec;
+               rc_avpair_assign(adt_vp, &dtime.tv_sec, 0);
 
                result = rc_send_server (&data, msg, NULL);
        }