1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-02-14 18:06:32 +00:00

cleaned up stupid warnings. all is good.

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@15 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2005-07-25 01:54:01 +00:00
parent cea3453824
commit 19972a04ff
3 changed files with 15 additions and 14 deletions

6
ftp.c
View File

@ -399,7 +399,7 @@ int dataConnectFtp() {
unsigned char ad[6], *cur, *adp, *portp; unsigned char ad[6], *cur, *adp, *portp;
unsigned int temp[6]; unsigned int temp[6];
struct sockaddr_in dataAddr; struct sockaddr_in dataAddr;
size_t dataAddrLen; socklen_t dataAddrLen;
dataFd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); dataFd = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (dataFd < 0) { if (dataFd < 0) {
@ -752,7 +752,7 @@ int getFtpSocket(const char *filename) {
* closeFtpSocket * closeFtpSocket
*/ */
int closeFtpSocket(int socket) { int closeFtpSocket() {
return(dataConnectEndFtp()); return(dataConnectEndFtp());
} }
@ -808,7 +808,7 @@ int getFtp(ftpDataCallback callback, void *userData, const char *filename) {
callback(userData, buf, len); callback(userData, buf, len);
} while (len != 0); } while (len != 0);
return(closeFtpSocket(dataFd)); return(closeFtpSocket());
} }
/* /*

View File

@ -209,14 +209,13 @@ inline void update_net_stats()
ns->last_read_trans = t; ns->last_read_trans = t;
/*** ip addr patch ***/ /*** ip addr patch ***/
i = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
s = (char*)socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
conf.ifc_buf = malloc(sizeof(struct ifreq) * 16); conf.ifc_buf = malloc(sizeof(struct ifreq) * 16);
conf.ifc_len = sizeof(struct ifreq) * 16; conf.ifc_len = sizeof(struct ifreq) * 16;
ioctl((long)s, SIOCGIFCONF, &conf); ioctl((long)i, SIOCGIFCONF, &conf);
for (k=0; k < conf.ifc_len / sizeof(struct ifreq); k++) { for (k=0; k < conf.ifc_len / sizeof(struct ifreq); k++) {
struct net_stat *ns; struct net_stat *ns;
@ -224,7 +223,7 @@ inline void update_net_stats()
ns->addr = ((struct ifreq*)conf.ifc_buf)[k].ifr_ifru.ifru_addr; ns->addr = ((struct ifreq*)conf.ifc_buf)[k].ifr_ifru.ifru_addr;
} }
close((long)s); close((long)i);
free(conf.ifc_buf); free(conf.ifc_buf);

View File

@ -2,6 +2,7 @@
#include <string.h> #include <string.h>
#include "ftp.h" #include "ftp.h"
#include <math.h> #include <math.h>
#include <time.h>
#include <pthread.h> #include <pthread.h>
#include "metarinfo.h" #include "metarinfo.h"
@ -69,7 +70,7 @@ const char*calculateShortWindDirectionString(int degree){
void ftpData(void *userData, const char *data, int len) void ftpData(void *userData, const char *data, int len)
{ {
if(userData) {} // do nothing to make stupid warning go away
if (len <= 0) if (len <= 0)
return; return;
@ -78,6 +79,7 @@ void ftpData(void *userData, const char *data, int len)
} }
} }
extern unsigned int sleep(unsigned int);
void *fetch_ftp( ) { void *fetch_ftp( ) {
// try three times if it fails // try three times if it fails
@ -87,9 +89,10 @@ void *fetch_ftp( ) {
/* this happens too often, so i'll leave it commented fprintf(stderr, "METAR update failed for some reason, retry %i\n", tries); */ /* this happens too often, so i'll leave it commented fprintf(stderr, "METAR update failed for some reason, retry %i\n", tries); */
sleep(15); /* give it some time in case the server is busy or down */ sleep(15); /* give it some time in case the server is busy or down */
} }
tries++; tries++;
if ( strlen(metar_station) != 8 ){ if ( strlen(metar_station) != 8 ){
fprintf(stderr,"You didn't supply a valid station code\n"); ERR("You didn't supply a valid METAR station code\n");
return NULL; return NULL;
} }
if (metar_server == NULL) if (metar_server == NULL)
@ -101,22 +104,21 @@ void *fetch_ftp( ) {
initFtp(); initFtp();
res = connectFtp(metar_server, 0); res = connectFtp(metar_server, 0);
if (res < 0) { if (res < 0) {
fprintf(stderr, "Couldn't connect to %s\n", metar_server); ERR("Couldn't connect to %s\n", metar_server);
return NULL; return NULL;
} }
res = changeFtpDirectory(metar_path); res = changeFtpDirectory(metar_path);
if (res < 0) { if (res < 0) {
fprintf(stderr, "Metar update failed (couldn't CWD to %s)\n", metar_path); ERR("Metar update failed (couldn't CWD to %s)\n", metar_path);
disconnectFtp(); disconnectFtp();
return NULL; return NULL;
} }
if (res == 0) { if (res == 0) {
fprintf(stderr, ERR("Metar update failed\n");
"Metar update failed\n");
return NULL; return NULL;
} }
if (getFtp(ftpData, NULL, metar_station) < 0) { if (getFtp(ftpData, NULL, metar_station) < 0) {
fprintf(stderr, "Failed to get file %s\n", metar_station); ERR("Failed to get file %s\n", metar_station);
} }
disconnectFtp(); disconnectFtp();