mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 23:13:13 +02:00
libnet: fix compil warning
This commit is contained in:
@@ -172,8 +172,8 @@ void netGetDefaultRoute( std::string &ip )
|
|||||||
fp = fopen("/proc/net/route","r");
|
fp = fopen("/proc/net/route","r");
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return;
|
return;
|
||||||
fgets(zeile,sizeof(zeile),fp); /* skip header */
|
char *fg = fgets(zeile,sizeof(zeile),fp); /* skip header */
|
||||||
while(fgets(zeile,sizeof(zeile),fp))
|
while(fg && (fg = fgets(zeile,sizeof(zeile),fp)))
|
||||||
{
|
{
|
||||||
destination = 1; /* in case sscanf fails */
|
destination = 1; /* in case sscanf fails */
|
||||||
sscanf(zeile,"%8s %x %x", interface, &destination, &gw);
|
sscanf(zeile,"%8s %x %x", interface, &destination, &gw);
|
||||||
@@ -218,15 +218,20 @@ void netGetHostname( std::string &host )
|
|||||||
|
|
||||||
void netSetHostname( std::string &host )
|
void netSetHostname( std::string &host )
|
||||||
{
|
{
|
||||||
FILE * fp;
|
if (sethostname(host.c_str(), host.length()) < 0)
|
||||||
|
{
|
||||||
sethostname(host.c_str(), host.length());
|
fprintf(stderr, "error set %s\n", host.c_str());
|
||||||
fp = fopen("/etc/hostname", "w");
|
}
|
||||||
if(fp != NULL) {
|
else
|
||||||
|
{
|
||||||
|
FILE * fp = fopen("/etc/hostname", "w");
|
||||||
|
if(fp != NULL)
|
||||||
|
{
|
||||||
fprintf(fp, "%s\n", host.c_str());
|
fprintf(fp, "%s\n", host.c_str());
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void netSetNameserver(std::string &ip)
|
void netSetNameserver(std::string &ip)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user