svn commit: r211398 - projects/sv/usr.sbin/netdumpsrv
Attilio Rao
attilio at FreeBSD.org
Mon Aug 16 15:51:42 UTC 2010
Author: attilio
Date: Mon Aug 16 15:51:41 2010
New Revision: 211398
URL: http://svn.freebsd.org/changeset/base/211398
Log:
Add some assertions in order to verify arguments passings.
Modified:
projects/sv/usr.sbin/netdumpsrv/netdump_server.c
Modified: projects/sv/usr.sbin/netdumpsrv/netdump_server.c
==============================================================================
--- projects/sv/usr.sbin/netdumpsrv/netdump_server.c Mon Aug 16 15:18:30 2010 (r211397)
+++ projects/sv/usr.sbin/netdumpsrv/netdump_server.c Mon Aug 16 15:51:41 2010 (r211398)
@@ -23,6 +23,7 @@
* SUCH DAMAGE.
*/
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -112,6 +113,8 @@ static struct netdump_client *alloc_clie
struct hostent *hp;
int i, fd, bufsz;
+ assert(ip != NULL);
+
client = calloc(1, sizeof(*client));
if (!client)
{
@@ -269,6 +272,9 @@ static struct netdump_client *alloc_clie
static void free_client(struct netdump_client *client)
{
+
+ assert(client != NULL);
+
/* Remove from the list */
SLIST_REMOVE(&clients, client, netdump_client, iter);
fclose(client->infofile);
@@ -279,8 +285,11 @@ static void free_client(struct netdump_c
static void exec_handler(struct netdump_client *client, const char *reason)
{
- int pid=fork();
+ int pid;
+
+ assert(client != NULL);
+ pid=fork();
if (pid == -1)
{
perror("fork");
@@ -304,6 +313,9 @@ static void exec_handler(struct netdump_
static void handle_timeout(struct netdump_client *client)
{
+
+ assert(client != NULL);
+
printf("Client %s timed out\n", client_ntoa(client));
fputs("Dump incomplete: client timed out\n", client->infofile);
exec_handler(client, "timeout");
@@ -337,6 +349,8 @@ static void send_ack(struct netdump_clie
struct netdump_ack ack;
int tryagain;
+ assert(client != NULL && msg != NULL);
+
bzero(&ack, sizeof(ack));
ack.seqno = htonl(msg->hdr.seqno);
@@ -366,6 +380,8 @@ static int handle_herald(struct sockaddr
{
int freed_client=0;
+ assert(from != NULL && msg != NULL);
+
if (client)
{
if (!client->any_data_rcvd)
@@ -401,19 +417,21 @@ static int handle_herald(struct sockaddr
static int handle_kdh(struct netdump_client *client, struct netdump_msg *msg)
{
- struct kerneldumpheader *h=(void *)msg->data;
+ struct kerneldumpheader *h;
uint64_t dumplen;
FILE *f;
time_t t;
int parity_check;
+ assert(msg != NULL);
+
if (!client)
{
return 0;
}
client->any_data_rcvd = 1;
-
+ h=(struct kerneldumpheader *)msg->data;
f = client->infofile;
if (msg->hdr.len < sizeof(struct kerneldumpheader))
@@ -460,6 +478,9 @@ static int handle_kdh(struct netdump_cli
static int handle_vmcore(struct netdump_client *client, struct netdump_msg *msg)
{
+
+ assert(msg != NULL);
+
if (!client)
{
return 0;
@@ -492,6 +513,9 @@ static int handle_vmcore(struct netdump_
static int handle_finish(struct netdump_client *client, struct netdump_msg *msg)
{
+
+ assert(msg != NULL);
+
if (!client)
{
return 0;
@@ -519,6 +543,8 @@ static int receive_message(int sock, str
socklen_t fromlen;
ssize_t len;
+ assert(from != NULL && fromstr != NULL && msg != NULL);
+
bzero(from, sizeof(*from));
from->sin_family = AF_INET;
from->sin_len = fromlen = sizeof(*from);
@@ -563,6 +589,8 @@ static int handle_packet(struct netdump_
{
int freed_client;
+ assert(from != NULL && fromstr != NULL && msg != NULL);
+
if (client)
{
client->last_msg = time(NULL);
More information about the svn-src-projects
mailing list