Module Name: src Committed By: christos Date: Sun Oct 30 18:40:06 UTC 2011
Modified Files: src/sbin/iscsictl: iscsic_daemonif.c iscsic_driverif.c iscsic_globals.h iscsic_main.c iscsic_parse.c Log Message: remove some lint To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sbin/iscsictl/iscsic_daemonif.c \ src/sbin/iscsictl/iscsic_driverif.c src/sbin/iscsictl/iscsic_parse.c cvs rdiff -u -r1.2 -r1.3 src/sbin/iscsictl/iscsic_globals.h \ src/sbin/iscsictl/iscsic_main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/iscsictl/iscsic_daemonif.c diff -u src/sbin/iscsictl/iscsic_daemonif.c:1.1 src/sbin/iscsictl/iscsic_daemonif.c:1.2 --- src/sbin/iscsictl/iscsic_daemonif.c:1.1 Sun Oct 23 17:11:23 2011 +++ src/sbin/iscsictl/iscsic_daemonif.c Sun Oct 30 14:40:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsic_daemonif.c,v 1.1 2011/10/23 21:11:23 agc Exp $ */ +/* $NetBSD: iscsic_daemonif.c,v 1.2 2011/10/30 18:40:06 christos Exp $ */ /*- * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ do_add_target(int argc, char **argv, isc if (rsp->status) { status_error(rsp->status); } - res = (iscsid_add_target_rsp_t *) rsp->parameter; + res = (iscsid_add_target_rsp_t *)(void *)rsp->parameter; tid = res->target_id; if (kind == SEND_TARGETS_LIST) { @@ -269,6 +269,7 @@ remove_target(int argc, char **argv) */ int +/*ARGSUSED*/ slp_find_targets(int argc, char **argv) { printf("Not implemented\n"); @@ -324,7 +325,7 @@ add_portal(int argc, char **argv) if (rsp->status) { status_error(rsp->status); } - res = (iscsid_add_portal_rsp_t *) rsp->parameter; + res = (iscsid_add_portal_rsp_t *)(void *)rsp->parameter; printf("Added Portal %d to Target %d\n", res->portal_id.id, res->target_id.id); @@ -361,7 +362,7 @@ show_target(uint32_t id, iscsid_list_kin if (trsp->status) { status_error(trsp->status); } - targ = (iscsid_get_target_rsp_t *) trsp->parameter; + targ = (iscsid_get_target_rsp_t *)(void *)trsp->parameter; /* display basic target info */ printf("%6d", targ->target_id.id); @@ -382,7 +383,7 @@ show_target(uint32_t id, iscsid_list_kin if (prsp->status) { status_error(prsp->status); } - port = (iscsid_get_portal_rsp_t *) prsp->parameter; + port = (iscsid_get_portal_rsp_t *)(void *)prsp->parameter; printf(" %6d", port->portal_id.id); if (port->portal_id.name[0]) { @@ -427,7 +428,7 @@ do_list_targets(int argc, char **argv, i if (rsp->status) { status_error(rsp->status); } - list = (iscsid_get_list_rsp_t *) rsp->parameter; + list = (iscsid_get_list_rsp_t *)(void *)rsp->parameter; /* display all targets */ for (i = 0; i < list->num_entries; i++) { @@ -530,7 +531,7 @@ add_isns_server(int argc, char **argv) if (rsp->status) { status_error(rsp->status); } - res = (iscsid_add_isns_server_rsp_t *) rsp->parameter; + res = (iscsid_add_isns_server_rsp_t *)(void *)rsp->parameter; printf("Added iSNS Server ID %d\n", res->server_id); @@ -595,6 +596,7 @@ remove_isns_server(int argc, char **argv */ int +/*ARGSUSED*/ find_isns_servers(int argc, char **argv) { printf("Not implemented\n"); @@ -631,7 +633,7 @@ list_isns_servers(int argc, char **argv) if (rsp->status) { status_error(rsp->status); } - list = (iscsid_get_list_rsp_t *) rsp->parameter; + list = (iscsid_get_list_rsp_t *)(void *)rsp->parameter; /* display all servers */ for (i = 0; i < list->num_entries; i++) { @@ -641,7 +643,7 @@ list_isns_servers(int argc, char **argv) if (prsp->status) status_error(prsp->status); - isns = (iscsid_get_isns_server_rsp_t *) prsp->parameter; + isns = (iscsid_get_isns_server_rsp_t *)(void *)prsp->parameter; printf("%6d: %s\n", list->id[i], isns->address); free_response(prsp); } @@ -694,7 +696,7 @@ add_initiator(int argc, char **argv) if (rsp->status) { status_error(rsp->status); } - res = (iscsid_add_initiator_rsp_t *) rsp->parameter; + res = (iscsid_add_initiator_rsp_t *)(void *)rsp->parameter; printf("Added Initiator Portal %d\n", res->portal_id); free_response(rsp); @@ -763,7 +765,7 @@ list_initiators(int argc, char **argv) if (rsp->status) { status_error(rsp->status); } - list = (iscsid_get_list_rsp_t *) rsp->parameter; + list = (iscsid_get_list_rsp_t *)(void *)rsp->parameter; /* display all servers */ for (i = 0; i < list->num_entries; i++) { @@ -773,7 +775,7 @@ list_initiators(int argc, char **argv) if (prsp->status) { status_error(prsp->status); } - init = (iscsid_get_initiator_rsp_t *) prsp->parameter; + init = (iscsid_get_initiator_rsp_t *)(void *)prsp->parameter; printf("%6d", init->portal_id.id); if (init->portal_id.name[0]) { printf("[%s]", init->portal_id.name); @@ -908,7 +910,7 @@ login(int argc, char **argv) if (rsp->status) { status_error(rsp->status); } - res = (iscsid_login_rsp_t *) rsp->parameter; + res = (iscsid_login_rsp_t *)(void *)rsp->parameter; printf("Created Session %d, Connection %d\n", res->session_id.id, res->connection_id.id); @@ -1057,7 +1059,7 @@ list_sessions(int argc, char **argv) if (lrsp->status) { status_error(lrsp->status); } - list = (iscsid_get_session_list_rsp_t *) lrsp->parameter; + list = (iscsid_get_session_list_rsp_t *)(void *)lrsp->parameter; for (i = 0, ent = list->session; i < list->num_entries; i++, ent++) { creq.session_id.id = ent->session_id.id; @@ -1066,7 +1068,7 @@ list_sessions(int argc, char **argv) if (rsp->status) { status_error(rsp->status); } - info = (iscsid_get_connection_info_rsp_t *) rsp->parameter; + info = (iscsid_get_connection_info_rsp_t *)(void *)rsp->parameter; printf("Session %d", info->session_id.id); if (info->session_id.name[0]) { @@ -1085,7 +1087,7 @@ list_sessions(int argc, char **argv) if (rsp->status) { status_error(rsp->status); } - clinfo = (iscsid_get_connection_list_rsp_t *) rsp->parameter; + clinfo = (iscsid_get_connection_list_rsp_t *)(void *)rsp->parameter; for (j = 0, clent = clinfo->connection; j < clinfo->num_connections; j++, clent++) { @@ -1152,6 +1154,7 @@ set_node_name(int argc, char **argv) */ int +/*ARGSUSED*/ get_version(int argc, char **argv) { iscsid_response_t *rsp; @@ -1162,7 +1165,7 @@ get_version(int argc, char **argv) if (rsp->status) { status_error(rsp->status); } - ver = (iscsid_get_version_rsp_t *)rsp->parameter; + ver = (iscsid_get_version_rsp_t *)(void *)rsp->parameter; printf("%s\n%s\n%s\n", VERSION_STRING, ver->version_string, ver->driver_version_string); Index: src/sbin/iscsictl/iscsic_driverif.c diff -u src/sbin/iscsictl/iscsic_driverif.c:1.1 src/sbin/iscsictl/iscsic_driverif.c:1.2 --- src/sbin/iscsictl/iscsic_driverif.c:1.1 Sun Oct 23 17:11:23 2011 +++ src/sbin/iscsictl/iscsic_driverif.c Sun Oct 30 14:40:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsic_driverif.c,v 1.1 2011/10/23 21:11:23 agc Exp $ */ +/* $NetBSD: iscsic_driverif.c,v 1.2 2011/10/30 18:40:06 christos Exp $ */ /*- * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc. @@ -286,10 +286,10 @@ get_sessid(int argc, char **argv, int op */ void -dump_data(const char *title, void *buffer, int len) +dump_data(const char *title, const void *buffer, size_t len) { - uint8_t *bp = (uint8_t *) buffer; - int i, nelem; + const uint8_t *bp = buffer; + size_t i, nelem; printf("%s\n", title); @@ -581,7 +581,7 @@ report_luns(int argc, char **argv) { iscsi_iocommand_parameters_t io; int rc; - uint32_t llen; + size_t llen; uint32_t n; uint16_t n2; uint64_t *lp; @@ -611,7 +611,7 @@ report_luns(int argc, char **argv) if (llen + 8 > sizeof(buf)) printf("Partial "); printf("LUN List:\n"); - lp = (uint64_t *) & buf[8]; + lp = (uint64_t *)(void *) &buf[8]; for (llen = min(llen, sizeof(buf) - 8) / 8; llen; llen--) { printf(" 0x%" PRIx64 "\n", ntohq(*lp)); Index: src/sbin/iscsictl/iscsic_parse.c diff -u src/sbin/iscsictl/iscsic_parse.c:1.1 src/sbin/iscsictl/iscsic_parse.c:1.2 --- src/sbin/iscsictl/iscsic_parse.c:1.1 Sun Oct 23 17:11:23 2011 +++ src/sbin/iscsictl/iscsic_parse.c Sun Oct 30 14:40:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsic_parse.c,v 1.1 2011/10/23 21:11:23 agc Exp $ */ +/* $NetBSD: iscsic_parse.c,v 1.2 2011/10/30 18:40:06 christos Exp $ */ /*- * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc. @@ -32,6 +32,7 @@ #include "iscsic_globals.h" #include <ctype.h> +#include <assert.h> /* * get_address: @@ -200,10 +201,11 @@ cl_get_target(iscsid_add_target_req_t ** { iscsid_add_target_req_t *targ; char *sp; - int num, i, len, name; + size_t num, len, name; + int i, p; /* count number of addreses first, so we know how much memory to allocate */ - for (i = num = name = 0; i < argc; i++) { + for (i = (int)(num = name = 0); i < argc; i++) { if (!argv[i] || argv[i][0] != '-') continue; if (argv[i][1] == 'a') @@ -219,10 +221,10 @@ cl_get_target(iscsid_add_target_req_t ** num * sizeof(iscsi_portal_address_t); if (NULL == (targ = calloc(1, len))) - gen_error("Can't allocate %d bytes of memory", len); + gen_error("Can't allocate %zu bytes of memory", len); *ptarg = targ; - num = -1; + p = -1; for (i = 0; i < argc; i++) { if (!argv[i] || argv[i][0] != '-') @@ -236,15 +238,17 @@ cl_get_target(iscsid_add_target_req_t ** break; case 'a': /* target address */ - get_address(&targ->portal[++num], sp, argv[i]); + get_address(&targ->portal[++p], sp, argv[i]); break; case 'p': /* port */ - targ->portal[num].port = get_short_int(sp, argv[i], "Port"); + assert(p >= 0); + targ->portal[p].port = get_short_int(sp, argv[i], "Port"); break; case 'g': /* group tag */ - targ->portal[num].group_tag = get_short_int(sp, argv[i], + assert(p >= 0); + targ->portal[p].group_tag = get_short_int(sp, argv[i], "Group tag"); break; @@ -256,10 +260,10 @@ cl_get_target(iscsid_add_target_req_t ** argv[i] = NULL; } - targ->num_portals = num + 1; + targ->num_portals = p + 1; - DEB(9, ("cl_get_target returns %d\n", len)); - return len; + DEB(9, ("cl_get_target returns %zu\n", len)); + return (int)len; } @@ -838,6 +842,7 @@ cl_get_int(char ident, int argc, char ** * Aborts app on bad parameter. */ +#if 0 int cl_get_uint(char ident, int argc, char **argv) { @@ -871,6 +876,7 @@ cl_get_uint(char ident, int argc, char * return val; } +#endif /* Index: src/sbin/iscsictl/iscsic_globals.h diff -u src/sbin/iscsictl/iscsic_globals.h:1.2 src/sbin/iscsictl/iscsic_globals.h:1.3 --- src/sbin/iscsictl/iscsic_globals.h:1.2 Sun Oct 23 19:41:56 2011 +++ src/sbin/iscsictl/iscsic_globals.h Sun Oct 30 14:40:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsic_globals.h,v 1.2 2011/10/23 23:41:56 christos Exp $ */ +/* $NetBSD: iscsic_globals.h,v 1.3 2011/10/30 18:40:06 christos Exp $ */ /*- * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc. @@ -106,7 +106,7 @@ static __inline void hton6(uint8_t * d, uint64_t x) { #if BYTE_ORDER == LITTLE_ENDIAN - uint8_t *s = ((uint8_t *) & x) + 5; + uint8_t *s = ((uint8_t *)(void *)&x) + 5; *d++ = *s--; *d++ = *s--; *d++ = *s--; @@ -125,7 +125,7 @@ static __inline uint64_t ntohq(uint64_t x) { #if BYTE_ORDER == LITTLE_ENDIAN - uint8_t *s = (uint8_t *) & x; + uint8_t *s = (uint8_t *)(void *)&x; return (uint64_t) ((uint64_t) s[0] << 56 | (uint64_t) s[1] << 48 | (uint64_t) s[2] << 40 | (uint64_t) s[3] << 32 | @@ -160,7 +160,7 @@ void check_extra_args(int, char **); void status_error(unsigned); void status_error_slist(unsigned); -void send_request(unsigned, unsigned par_len, void *); +void send_request(unsigned, size_t, void *); iscsid_response_t *get_response(int); void free_response(iscsid_response_t *); @@ -196,7 +196,7 @@ int kill_daemon(int, char **); /* iscsic_driverif.c */ uint32_t get_sessid(int, char **, int); -void dump_data(const char *, void *, int); +void dump_data(const char *, const void *, size_t); int do_ioctl(iscsi_iocommand_parameters_t *, int); int set_node_name(int, char **); int inquiry(int, char **); Index: src/sbin/iscsictl/iscsic_main.c diff -u src/sbin/iscsictl/iscsic_main.c:1.2 src/sbin/iscsictl/iscsic_main.c:1.3 --- src/sbin/iscsictl/iscsic_main.c:1.2 Sun Oct 23 19:41:56 2011 +++ src/sbin/iscsictl/iscsic_main.c Sun Oct 30 14:40:06 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsic_main.c,v 1.2 2011/10/23 23:41:56 christos Exp $ */ +/* $NetBSD: iscsic_main.c,v 1.3 2011/10/30 18:40:06 christos Exp $ */ /*- * Copyright (c) 2005,2006,2011 The NetBSD Foundation, Inc. @@ -414,18 +414,19 @@ status_error_slist(unsigned n) iscsid_response_t * get_response(int temp) { - int ret, len; + ssize_t ret; + size_t len; iscsid_response_t *rsp; int *pbuf; - pbuf = (int *) buf; - rsp = (iscsid_response_t *) & pbuf[1]; + pbuf = (int *)(void *)buf; + rsp = (iscsid_response_t *)(void *)&pbuf[1]; *pbuf = 0; /* get size of response */ len = sizeof(iscsid_response_t); ret = recv(sock, rsp, len, MSG_PEEK | MSG_WAITALL); - if (ret != len) + if ((size_t)ret != len) io_error("Receiving daemon data"); DEB(9, ("Status %d, parlen %d\n", rsp->status, rsp->parameter_length)); @@ -444,13 +445,13 @@ get_response(int temp) gen_error("Can't allocate response buffer (%zu bytes)", len + sizeof(int)); - rsp = (iscsid_response_t *) & pbuf[1]; + rsp = (iscsid_response_t *)(void *)&pbuf[1]; *pbuf = 1; } /* get the complete response */ ret = recv(sock, rsp, len, MSG_WAITALL); - if (ret != len) + if ((size_t)ret != len) io_error("Receiving daemon data"); return rsp; @@ -472,7 +473,7 @@ free_response(iscsid_response_t * rsp) { int *pbuf; - pbuf = ((int *) rsp) - 1; + pbuf = ((int *)(void *)rsp) - 1; if (*pbuf) free(pbuf); } @@ -489,33 +490,35 @@ free_response(iscsid_response_t * rsp) */ void -send_request(unsigned request, unsigned par_len, void *par) +send_request(unsigned request, size_t par_len, void *par) { iscsid_request_t *req; - int len, ret, req_temp; + size_t len; + ssize_t ret; + int req_temp; len = sizeof(iscsid_request_t) + par_len; /* alloc buffer if static one is too small to hold request */ - req_temp = len > (int)sizeof(buf); + req_temp = len > sizeof(buf); if (req_temp) { req = malloc(len); if (req == NULL) - gen_error("Out of memory allocating %d bytes\n", len); + gen_error("Out of memory allocating %zu bytes\n", len); } else - req = (iscsid_request_t *) buf; + req = (iscsid_request_t *)(void *)buf; /* setup request */ req->request = request; - req->parameter_length = par_len; + req->parameter_length = (uint32_t)par_len; if (par_len) memcpy(req->parameter, par, par_len); /* and send it out */ - ret = sendto(sock, req, len, 0, (struct sockaddr *) &daemon_name, - sizeof(struct sockaddr_un)); - if (ret != len) { + ret = sendto(sock, req, len, 0, (struct sockaddr *)(void *)&daemon_name, + (socklen_t)sizeof(struct sockaddr_un)); + if ((size_t)ret != len) { io_error("Sending daemon message"); } if (req_temp) @@ -584,7 +587,8 @@ main(int argc, char **argv) } myname.sun_family = AF_UNIX; (void) snprintf(myname.sun_path, sizeof(myname.sun_path), "%s/socket", sockdir); - if (bind(sock, (struct sockaddr *) &myname, sizeof(struct sockaddr_un)) < 0) { + if (bind(sock, (struct sockaddr *)(void *)&myname, + (socklen_t)sizeof(struct sockaddr_un)) < 0) { io_error("Binding name to datagram socket"); } daemon_name.sun_family = AF_UNIX;