rv = ioctl (sockfd, FIONBIO, &one);
if (rv < 0)
{
+ close (sockfd);
return clib_error_return_unix (0, "FIONBIO");
}
rv = setsockopt (sockfd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof (one));
if (rv < 0)
{
+ close (sockfd);
return clib_error_return_unix (0, "SO_REUSEADDR");
}
if (isatty (UNIX_CLI_STDIN_FD) && um->cli_line_mode == 0)
{
/* Capture terminal resize events */
+ memset (&sa, 0, sizeof(sa));
sa.sa_handler = unix_cli_resize_interrupt;
- sa.sa_flags = 0;
if (sigaction (SIGWINCH, &sa, 0) < 0)
clib_panic ("sigaction");
t->sw_if_index = vnet_buffer(b0)->sw_if_index[VLIB_RX];
t->next_index = next0;
t->table_index = t0 ? t0 - vcm->tables : ~0;
- t->offset = e0 ? vnet_classify_get_offset (t0, e0): ~0;
+ t->offset = (e0 && t0) ? vnet_classify_get_offset (t0, e0): ~0;
}
/* verify speculative enqueue, maybe switch current next frame */
b0, sizeof (*tr));
if (b0->error != node->errors[UDP_ERROR_LENGTH_ERROR])
{
- tr->src_port = h0->src_port;
- tr->dst_port = h0->dst_port;
+ tr->src_port = h0 ? h0->src_port : 0;
+ tr->dst_port = h0 ? h0->dst_port : 0;
tr->bound = (next0 != UDP_INPUT_NEXT_ICMP4_ERROR &&
next0 != UDP_INPUT_NEXT_ICMP6_ERROR);
}
b1, sizeof (*tr));
if (b1->error != node->errors[UDP_ERROR_LENGTH_ERROR])
{
- tr->src_port = h1->src_port;
- tr->dst_port = h1->dst_port;
+ tr->src_port = h1 ? h1->src_port : 0;
+ tr->dst_port = h1 ? h1->dst_port : 0;
tr->bound = (next1 != UDP_INPUT_NEXT_ICMP4_ERROR &&
next1 != UDP_INPUT_NEXT_ICMP6_ERROR);
}
tx_fib_index_or_output_swif_index = tx_fib_id;
}
- key = ((u64)rx_fib_index<<32) | ((u64) (label_host_byte_order<<12))
+ key = ((u64) rx_fib_index<<32) | ((u64) label_host_byte_order<<12)
| ((u64) s_bit<<8);
p = hash_get (mm->mpls_decap_by_rx_fib_and_label, key);
vec_foreach (s, records)
{
- key = ((u64)fib_index <<32) | ((u64)(s->dest<<12)) |
- ((u64)s->s_bit);
+ key = ((u64) fib_index <<32) | ((u64) s->dest<<12) |
+ ((u64) s->s_bit);
hash_unset (mm->mpls_decap_by_rx_fib_and_label, key);
pool_put_index (mm->decaps, s->entry_index);
t->sw_if_index = vnet_buffer(b0)->sw_if_index[VLIB_RX];
t->next_index = next0;
t->table_index = t0 ? t0 - vcm->tables : ~0;
- t->offset = e0 ? vnet_classify_get_offset (t0, e0): ~0;
+ t->offset = (e0 && t0) ? vnet_classify_get_offset (t0, e0): ~0;
t->policer_index = e0 ? e0->next_index: ~0;
}
&exp, &hi_mant);
}
- denom = (1 << exp);
+ denom = (1ULL << exp);
if (hi_rate == eir_hw) {
hw->peak_rate_man = (uint16_t)hi_mant;
rc = sse2_qos_pol_round((uint64_t)cir_hw, denom, &rnd_value,
ASSERT (hc->set_rewrite);
n_rw_tmp = hc->set_rewrite (vnm, sw_if_index, packet_type, dst_address, rw_tmp, max_rewrite_bytes);
- ASSERT (n_rw_tmp >= 0 && n_rw_tmp < max_rewrite_bytes);
+ ASSERT (n_rw_tmp < max_rewrite_bytes);
vnet_rewrite_set_data_internal (rw, max_rewrite_bytes, rw_tmp, n_rw_tmp);
}
for (i = 0; i < vec_len (sm->hmac_keys); i++)
{
if (sm->hmac_keys[i].shared_secret == 0)
- key = sm->hmac_keys + i;
- goto found;
+ {
+ key = sm->hmac_keys + i;
+ goto found;
+ }
}
vec_validate (sm->hmac_keys, i);
key = sm->hmac_keys + i;
memset(&adj, 0, sizeof (adj));
/* Create an adjacency and add to v6 fib */
- adj.lookup_next_index = IP_LOOKUP_NEXT_REWRITE;
adj.lookup_next_index = sm->ip6_lookup_sr_next_index;
adj.explicit_fib_index = ~0;
p=hash_get_mem (sm->policy_index_by_policy_name, a->policy_name);
}
vec_add1 (pt->tunnel_indices, t - sm->tunnels);
- t->policy_index = p[0]; /* equiv. to (pt - sm->policies) */
+ if (p == 0)
+ clib_warning ("p is NULL!");
+ t->policy_index = p ? p[0] : ~0; /* equiv. to (pt - sm->policies) */
}
if (a->name)
sr_replicate_trace_t *tr = vlib_add_trace (vm, node,
b0, sizeof (*tr));
tr->tunnel_index = t0 - sm->tunnels;
+ tr->length = 0;
if (hdr_ip0)
{
memcpy (tr->src.as_u8, hdr_ip0->src_address.as_u8,
sizeof (tr->src.as_u8));
memcpy (tr->dst.as_u8, hdr_ip0->dst_address.as_u8,
sizeof (tr->dst.as_u8));
+ if (hdr_ip0->payload_length)
+ tr->length = clib_net_to_host_u16
+ (hdr_ip0->payload_length);
}
- if (hdr_ip0->payload_length)
- tr->length = clib_net_to_host_u16(hdr_ip0->payload_length);
- else
- tr->length = 0;
tr->next_index = next_index;
memcpy (tr->sr, hdr_sr0, sizeof (tr->sr));
}
error:
close (dev_net_tun_fd);
- close (dev_tap_fd);
+ if (dev_tap_fd >= 0)
+ close (dev_tap_fd);
return rv;
}
if (ioctl (tm->dev_net_tun_fd, TUNSETPERSIST, 0) < 0)
clib_unix_warning ("TUNSETPERSIST");
close(tm->dev_tap_fd);
- close(tm->dev_net_tun_fd);
+ if (tm->dev_net_tun_fd >= 0)
+ close(tm->dev_net_tun_fd);
close (sfd);
return 0;
if (ioctl (sockfd, SIOCDIFADDR, &ifr6) < 0)
clib_unix_warning ("del address");
- close (sockfd);
+ if (sockfd >= 0)
+ close (sockfd);
mhash_unset (&tm->subif_mhash, &subif_addr, 0 /* old value ptr */);
pool_put (tm->subifs, ap);
u32 cpu_index = os_get_cpu_number ();
u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
- memset (&last_key4, 0xff, sizeof(last_key4));
+ if (is_ip4)
+ memset (&last_key4, 0xff, sizeof(last_key4));
+ else
+ memset (&last_key6, 0xff, sizeof(last_key6));
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
u32 cpu_index = os_get_cpu_number();
u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
- last_key4.as_u64 = ~0;
+ if (is_ip4)
+ last_key4.as_u64 = ~0;
+ else
+ memset (&last_key6, 0xff, sizeof (last_key6));
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
ip_adjacency_t adj;
u32 adj_index;
+ memset(&adj, 0, sizeof(adj));
adj.lookup_next_index = IP_LOOKUP_NEXT_REWRITE;
vnet_rewrite_for_sw_interface
}
else {
fclose (ifp);
- fclose (ofp);
+ if (ofp)
+ fclose (ofp);
if (ofile) {
printf ("Removing %s\n", ofile);
unlink (ofile);
static char namebuf [MAXNAME];
+static inline char
+getc_char (FILE *ifp)
+{
+ return ((char)(getc(ifp) & 0x7f));
+}
+
/*
* yylex (well, yylex_1: The real yylex below does crc-hackery)
*/
{
int nameidx=0;
char c;
- int at_bol=1;
enum { LP_INITIAL_WHITESPACE, LP_LINE_NUMBER,
LP_PRE_FILENAME_WHITESPACE, LP_FILENAME,
LP_POST_FILENAME,
* START state -- looking for something interesting
*/
case START_STATE:
- c = getc (ifp);
+ c = getc_char (ifp);
if (feof (ifp))
return (EOF);
switch (c) {
case '\n':
the_lexer_linenumber++;
- at_bol=1;
goto again;
case '#':
- if (!at_bol) {
- fprintf (stderr, "unknown token /%c at line %d\n",
- c, the_lexer_linenumber);
- return (BARF);
- }
-
the_lexer_state = LINE_PRAGMA_STATE;
lp_substate = LP_INITIAL_WHITESPACE;
goto again;
goto again;
case '/':
- c = getc (ifp);
+ c = getc_char (ifp);
if (feof (ifp))
return (EOF);
}
case '\\':
- c = getc (ifp);
+ c = getc_char (ifp);
if (feof (ifp))
return (EOF);
* NAME state -- eat the rest of a name
*/
case NAME_STATE:
- c = getc (ifp);
+ c = getc_char (ifp);
if (feof (ifp))
return (EOF);
* NUMBER state -- eat the rest of a number
*/
case NUMBER_STATE:
- c = getc (ifp);
+ c = getc_char (ifp);
if (feof (ifp))
return (EOF);
* C_COMMENT state -- eat a peach
*/
case C_COMMENT_STATE:
- c = getc (ifp);
+ c = getc_char (ifp);
if (feof (ifp))
return (EOF);
if (c == '*') {
- c = getc (ifp);
+ c = getc_char (ifp);
if (feof (ifp))
return (EOF);
if (c == '/') {
*/
case CPP_COMMENT_STATE:
- c = getc (ifp);
+ c = getc_char (ifp);
if (feof (ifp))
return (EOF);
if (c == '\n') {
goto again;
case STRING_STATE:
- c = getc (ifp);
+ c = getc_char (ifp);
if (feof (ifp))
return (EOF);
switch (c) {
case '\\':
- c = getc (ifp);
+ c = getc_char (ifp);
if (feof (ifp))
return (EOF);
namebuf[nameidx++] = c;
break;
case HELPER_STATE:
- c = getc (ifp);
+ c = getc_char (ifp);
if (feof (ifp))
return (EOF);
switch (c) {
case '\\':
- c = getc (ifp);
+ c = getc_char (ifp);
if (feof (ifp))
return (EOF);
namebuf[nameidx] = c;
switch (lp_substate) {
case LP_INITIAL_WHITESPACE: /* no number seen yet */
- c = getc(ifp);
+ c = getc_char(ifp);
if (feof(ifp))
return(EOF);
if (c >= '0' && c <= '9') {
goto again;
case LP_LINE_NUMBER: /* eating linenumber */
- c = getc(ifp);
+ c = getc_char(ifp);
if (feof(ifp))
return(EOF);
if (c >= '0' && c <= '9') {
goto again;
case LP_PRE_FILENAME_WHITESPACE: /* awaiting filename */
- c = getc(ifp);
+ c = getc_char(ifp);
if (feof(ifp))
return(EOF);
goto again;
case LP_FILENAME: /* eating filename */
- c = getc(ifp);
+ c = getc_char(ifp);
if (feof(ifp))
return(EOF);
case LP_POST_FILENAME: /* ignoring rest of line */
case LP_OTHER:
- c = getc(ifp);
+ c = getc_char(ifp);
if (feof(ifp))
return(EOF);
}
lp_end_of_line:
the_lexer_state = START_STATE;
- at_bol = 1;
nameidx = 0;
}
goto again;
char *rv;
rv = (char *) malloc (len+1);
+ if (rv == 0) {
+ fprintf(stderr, "Out of memory...");
+ exit (1);
+ }
+
strcpy (rv, s);
return (rv);
}
if (*cp == '/')
cp++;
- strcpy (tmpbuf, cp);
+ strncpy (tmpbuf, cp, sizeof(tmpbuf)-1);
cp = tmpbuf;
}
done:
- if (mmap_length > 0)
+ if (mmap_length > 0 && idp)
munmap (idp, mmap_length);
- close (ifd);
- close (ofd);
+ if (ifd >= 0)
+ close (ifd);
+ if (ofd >= 0)
+ close (ofd);
return error;
}
}
if (! tm->input_file)
- clib_error ("no input file");
+ {
+ error = clib_error_return (0, "no input file");
+ goto done;
+ }
/* Do the typical case a stone-simple way... */
if (tm->quiet && tm->set_interpreter && tm->set_rpath && tm->output_file)
{
default:
ASSERT (0);
+ break;
case 'x':
ASSERT (reg < 16);
/* Memory or reg field from modrm byte. */
case 'M':
ASSERT (p->flags & X86_INSN_IS_ADDRESS);
+ /* FALLTHROUGH */
case 'E':
if (p->flags & X86_INSN_IS_ADDRESS)
s = format (s, "%U", format_x86_mem_operand, p);
case 'I':
{
u32 l = x86_insn_log2_immediate_bytes (p, insn);
- i64 mask = pow2_mask (8 << l);
+ i64 mask = pow2_mask (8ULL << l);
s = format (s, "$0x%Lx", p->immediate & mask);
}
break;
uword i0, i1, result;
uword l = vec_len (bitmap);
- ASSERT (n_bits >= 0 && n_bits <= BITS (result));
+ ASSERT (n_bits <= BITS (result));
i0 = i / BITS (bitmap[0]);
i1 = i % BITS (bitmap[0]);
{
uword i0, i1, l, t, m;
- ASSERT (n_bits >= 0 && n_bits <= BITS (value));
+ ASSERT (n_bits <= BITS (value));
i0 = i / BITS (bitmap[0]);
i1 = i % BITS (bitmap[0]);
s = format (s, "\nSections %d at file offset 0x%Lx-0x%Lx:\n",
fh->section_header_count,
fh->section_header_file_offset,
- fh->section_header_file_offset + fh->section_header_count * fh->section_header_size);
+ fh->section_header_file_offset +
+ (u64) fh->section_header_count * fh->section_header_size);
s = format (s, "%U\n", format_elf_section, em, 0);
vec_foreach (h, copy)
s = format (s, "%U\n", format_elf_section, em, h);
fh->section_header_file_offset = file_offset;
fh->section_header_count = vec_len (em->sections) - n_deleted_sections;
- file_offset += fh->section_header_count * fh->section_header_size;
+ file_offset += (u64) fh->section_header_count * fh->section_header_size;
}
{
continue;
if (fseek (f, s->header.file_offset, SEEK_SET) < 0)
- return clib_error_return_unix (0, "fseek 0x%Lx", s->header.file_offset);
+ {
+ fclose(f);
+ return clib_error_return_unix (0, "fseek 0x%Lx",
+ s->header.file_offset);
+ }
if (s->header.type == ELF_SECTION_NO_BITS)
/* don't write for .bss sections */;
if (file[0] == '.' || file[0] == '/')
return file;
+ if (getenv("PATH") == 0)
+ return file;
+
ps.path = split_string (getenv ("PATH"), ':');
for (i = 0; i < vec_len (ps.path); i++)
name = path_search (cem->exec_path);
if (! name)
- clib_error ("failed to find %s on PATH", cem->exec_path);
+ {
+ clib_error ("failed to find %s on PATH", cem->exec_path);
+ return 0;
+ }
addr = 0;
}
elog_track_t newt;
int i;
+ memset(&newt, 0, sizeof (newt));
+
elog_get_events (src);
elog_get_events (dst);