*: fix some solaris warnings

Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
David Lamparter 2018-08-28 10:59:02 +02:00
parent b45ac5f5c6
commit ae9eebcaeb
6 changed files with 21 additions and 22 deletions

View File

@ -289,7 +289,7 @@ static int _ptm_msg_read(struct stream *msg, int command,
{ {
uint32_t pid; uint32_t pid;
uint8_t ttl __attribute__((unused)); uint8_t ttl __attribute__((unused));
uint8_t ifnamelen; size_t ifnamelen;
/* /*
* Register/Deregister/Update Message format: * Register/Deregister/Update Message format:

View File

@ -619,7 +619,7 @@ DEFUN (no_interface_desc,
* if not: * if not:
* - no idea, just get the name in its entirety. * - no idea, just get the name in its entirety.
*/ */
static struct interface *if_sunwzebra_get(char *name, vrf_id_t vrf_id) static struct interface *if_sunwzebra_get(const char *name, vrf_id_t vrf_id)
{ {
struct interface *ifp; struct interface *ifp;
char *cp; char *cp;

View File

@ -96,7 +96,7 @@ class IP4Handler(IPBase):
code = Template('_fail = !inet_aton(argv[_i]->arg, &$varname);') code = Template('_fail = !inet_aton(argv[_i]->arg, &$varname);')
class IP6Handler(IPBase): class IP6Handler(IPBase):
argtype = 'struct in6_addr' argtype = 'struct in6_addr'
decl = Template('struct in6_addr $varname = IN6ADDR_ANY_INIT;') decl = Template('struct in6_addr $varname = {};')
code = Template('_fail = !inet_pton(AF_INET6, argv[_i]->arg, &$varname);') code = Template('_fail = !inet_pton(AF_INET6, argv[_i]->arg, &$varname);')
class IPGenHandler(IPBase): class IPGenHandler(IPBase):
argtype = 'const union sockunion *' argtype = 'const union sockunion *'

View File

@ -607,7 +607,7 @@ static int pid_is_exec(pid_t pid, const struct stat *esb)
struct stat sb; struct stat sb;
char buf[32]; char buf[32];
sprintf(buf, "/proc/%d/exe", pid); sprintf(buf, "/proc/%ld/exe", (long)pid);
if (stat(buf, &sb) != 0) if (stat(buf, &sb) != 0)
return 0; return 0;
return (sb.st_dev == esb->st_dev && sb.st_ino == esb->st_ino); return (sb.st_dev == esb->st_dev && sb.st_ino == esb->st_ino);
@ -619,7 +619,7 @@ static int pid_is_user(pid_t pid, uid_t uid)
struct stat sb; struct stat sb;
char buf[32]; char buf[32];
sprintf(buf, "/proc/%d", pid); sprintf(buf, "/proc/%ld", (long)pid);
if (stat(buf, &sb) != 0) if (stat(buf, &sb) != 0)
return 0; return 0;
return (sb.st_uid == uid); return (sb.st_uid == uid);
@ -632,7 +632,7 @@ static int pid_is_cmd(pid_t pid, const char *name)
FILE *f; FILE *f;
int c; int c;
sprintf(buf, "/proc/%d/stat", pid); sprintf(buf, "/proc/%ld/stat", (long)pid);
f = fopen(buf, "r"); f = fopen(buf, "r");
if (!f) if (!f)
return 0; return 0;
@ -664,12 +664,12 @@ static void check(pid_t pid)
static void do_pidfile(const char *name) static void do_pidfile(const char *name)
{ {
FILE *f; FILE *f;
pid_t pid; long pid;
f = fopen(name, "r"); f = fopen(name, "r");
if (f) { if (f) {
if (fscanf(f, "%d", &pid) == 1) if (fscanf(f, "%ld", &pid) == 1)
check(pid); check((pid_t)pid);
fclose(f); fclose(f);
} else if (errno != ENOENT) } else if (errno != ENOENT)
fatal("open pidfile %s: %s", name, strerror(errno)); fatal("open pidfile %s: %s", name, strerror(errno));
@ -682,7 +682,7 @@ static void do_procinit(void)
DIR *procdir; DIR *procdir;
struct dirent *entry; struct dirent *entry;
int foundany; int foundany;
pid_t pid; long pid;
procdir = opendir("/proc"); procdir = opendir("/proc");
if (!procdir) if (!procdir)
@ -690,10 +690,10 @@ static void do_procinit(void)
foundany = 0; foundany = 0;
while ((entry = readdir(procdir)) != NULL) { while ((entry = readdir(procdir)) != NULL) {
if (sscanf(entry->d_name, "%d", &pid) != 1) if (sscanf(entry->d_name, "%ld", &pid) != 1)
continue; continue;
foundany++; foundany++;
check(pid); check((pid_t)pid);
} }
closedir(procdir); closedir(procdir);
if (!foundany) if (!foundany)
@ -728,21 +728,21 @@ static void do_stop(int signal_nr, int quietmode, int *n_killed,
for (p = found; p; p = p->next) { for (p = found; p; p = p->next) {
if (testmode) if (testmode)
printf("Would send signal %d to %d.\n", signal_nr, printf("Would send signal %d to %ld.\n", signal_nr,
p->pid); (long)p->pid);
else if (kill(p->pid, signal_nr) == 0) { else if (kill(p->pid, signal_nr) == 0) {
push(&killed, p->pid); push(&killed, p->pid);
(*n_killed)++; (*n_killed)++;
} else { } else {
printf("%s: warning: failed to kill %d: %s\n", progname, printf("%s: warning: failed to kill %ld: %s\n",
p->pid, strerror(errno)); progname, (long)p->pid, strerror(errno));
(*n_notkilled)++; (*n_notkilled)++;
} }
} }
if (quietmode < 0 && killed) { if (quietmode < 0 && killed) {
printf("Stopped %s (pid", what_stop); printf("Stopped %s (pid", what_stop);
for (p = killed; p; p = p->next) for (p = killed; p; p = p->next)
printf(" %d", p->pid); printf(" %ld", (long)p->pid);
putchar(')'); putchar(')');
if (retry_nr > 0) if (retry_nr > 0)
printf(", retry #%d", retry_nr); printf(", retry #%d", retry_nr);
@ -1055,7 +1055,7 @@ int main(int argc, char **argv)
if (pidf == NULL) if (pidf == NULL)
fatal("Unable to open pidfile `%s' for writing: %s", fatal("Unable to open pidfile `%s' for writing: %s",
pidfile, strerror(errno)); pidfile, strerror(errno));
fprintf(pidf, "%d\n", pidt); fprintf(pidf, "%ld\n", (long)pidt);
fclose(pidf); fclose(pidf);
} }
set_namespaces(); set_namespaces();

View File

@ -39,6 +39,7 @@
#include "zebra/interface.h" #include "zebra/interface.h"
#include "zebra/ioctl_solaris.h" #include "zebra/ioctl_solaris.h"
#include "zebra/rib.h" #include "zebra/rib.h"
#include "zebra/rt.h"
static int if_get_addr(struct interface *, struct sockaddr *, const char *); static int if_get_addr(struct interface *, struct sockaddr *, const char *);
static void interface_info_ioctl(struct interface *); static void interface_info_ioctl(struct interface *);
@ -55,7 +56,6 @@ static int interface_list_ioctl(int af)
struct lifconf lifconf; struct lifconf lifconf;
struct interface *ifp; struct interface *ifp;
int n; int n;
int save_errno;
size_t needed, lastneeded = 0; size_t needed, lastneeded = 0;
char *buf = NULL; char *buf = NULL;
@ -76,13 +76,11 @@ calculate_lifc_len:
lifn.lifn_flags = LIFC_NOXMIT; lifn.lifn_flags = LIFC_NOXMIT;
/* we want NOXMIT interfaces too */ /* we want NOXMIT interfaces too */
ret = ioctl(sock, SIOCGLIFNUM, &lifn); ret = ioctl(sock, SIOCGLIFNUM, &lifn);
save_errno = errno;
} }
if (ret < 0) { if (ret < 0) {
zlog_warn("interface_list_ioctl: SIOCGLIFNUM failed %s", zlog_warn("interface_list_ioctl: SIOCGLIFNUM failed %s",
safe_strerror(save_errno)); safe_strerror(errno));
close(sock); close(sock);
return -1; return -1;
} }

View File

@ -31,6 +31,7 @@
#include "zebra/rib.h" #include "zebra/rib.h"
#include "zebra/rt.h" #include "zebra/rt.h"
#include "zebra/zebra_pbr.h"
/* Thank you, Solaris, for polluting application symbol namespace. */ /* Thank you, Solaris, for polluting application symbol namespace. */
#undef hook_register #undef hook_register