mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-23 21:51:27 +00:00
iscsi-scstd: Insert a blank line after declarations
Additionally, surround complex values with parentheses, declare static char arrays const and change C++ comments into C comments. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6849 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -575,7 +575,7 @@ static int chap_target_auth_create_response(struct connection *conn)
|
||||
response_len = 2 * digest_len;
|
||||
else
|
||||
response_len = ((digest_len - 1) / 3 + 1) * 4;
|
||||
//"0x" / "0b" and "\0":
|
||||
/* "0x" / "0b" and "\0": */
|
||||
response_len += 3;
|
||||
|
||||
if (!(digest = malloc(digest_len))) {
|
||||
|
||||
@@ -514,6 +514,7 @@ int __config_account_add(struct target *target, int dir, char *name, char *pass,
|
||||
|
||||
if (dir == ISCSI_USER_DIR_OUTGOING) {
|
||||
struct iscsi_attr *old;
|
||||
|
||||
list_for_each_entry(old, list, ulist) {
|
||||
log_warning("Only one outgoing %s account is "
|
||||
"supported. Replacing the old one.\n",
|
||||
@@ -1061,6 +1062,7 @@ static int config_isns_load(const char *config)
|
||||
isns_server = strdup(config_sep_string(&q));
|
||||
} else if (!strcasecmp(p, ISCSI_ISNS_ACCESS_CONTROL_ATTR_NAME)) {
|
||||
char *str = config_sep_string(&q);
|
||||
|
||||
if (!strcasecmp(str, "No"))
|
||||
isns_access_control = 0;
|
||||
else
|
||||
@@ -1139,6 +1141,7 @@ int config_load(const char *config_name)
|
||||
err = config_isns_load(buf);
|
||||
if ((err == 0) && (isns_server != NULL)) {
|
||||
int rc = isns_init();
|
||||
|
||||
if (rc != 0) {
|
||||
log_error("iSNS server %s init failed: %d", isns_server, rc);
|
||||
isns_exit();
|
||||
|
||||
@@ -105,6 +105,7 @@ static int strncasecmp_numwild(const char *name, const char *mask)
|
||||
|
||||
if (!strncasecmp(name, mask, strlen(name))) {
|
||||
int j;
|
||||
|
||||
if (strlen(name) > strlen(mask))
|
||||
goto out;
|
||||
for (j = strlen(name); j < strlen(mask); j++) {
|
||||
@@ -430,6 +431,7 @@ static int handle_e_mgmt_cmd(int fd, const struct iscsi_kern_event *event)
|
||||
res = handle_add_attr(NULL, p, event->cookie);
|
||||
} else if (strcasecmp("add_target_attribute", pp) == 0) {
|
||||
struct target *target;
|
||||
|
||||
pp = config_sep_string(&p);
|
||||
target = target_find_by_name(pp);
|
||||
if (target == NULL) {
|
||||
@@ -442,6 +444,7 @@ static int handle_e_mgmt_cmd(int fd, const struct iscsi_kern_event *event)
|
||||
res = handle_del_attr(NULL, p, event->cookie);
|
||||
} else if (strcasecmp("del_target_attribute", pp) == 0) {
|
||||
struct target *target;
|
||||
|
||||
pp = config_sep_string(&p);
|
||||
target = target_find_by_name(pp);
|
||||
if (target == NULL) {
|
||||
@@ -465,6 +468,7 @@ out:
|
||||
static void add_key_mark(char *res_str, int res_str_len, int new_line)
|
||||
{
|
||||
int offs = strlen(res_str);
|
||||
|
||||
snprintf(&res_str[offs], res_str_len - offs, "%s%s\n",
|
||||
new_line ? "\n" : "", SCST_SYSFS_KEY_MARK);
|
||||
return;
|
||||
@@ -702,6 +706,7 @@ static int handle_target_redirect(struct target *target, char *p)
|
||||
|
||||
if (inet_pton(AF_INET, addr, &ia) != 1) {
|
||||
char tmp[sizeof(target->redirect.addr)];
|
||||
|
||||
if (*addr == '[')
|
||||
t = addr+1;
|
||||
else
|
||||
|
||||
@@ -46,10 +46,9 @@ enum iscsi_adm_op {
|
||||
OP_SHOW,
|
||||
};
|
||||
|
||||
static char program_name[] = "iscsi-scst-adm";
|
||||
static const char program_name[] = "iscsi-scst-adm";
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
static struct option const long_options[] = {
|
||||
{"op", required_argument, NULL, 'o'},
|
||||
{"tid", required_argument, NULL, 't'},
|
||||
{"sid", required_argument, NULL, 's'},
|
||||
@@ -278,6 +277,7 @@ static int parse_trgt_params(struct msg_trgt *msg, char *params)
|
||||
while ((p = strsep(¶ms, ",")) != NULL) {
|
||||
int idx;
|
||||
u32 val;
|
||||
|
||||
if (!*p)
|
||||
continue;
|
||||
if (!(q = strchr(p, '=')))
|
||||
|
||||
@@ -52,10 +52,9 @@ int conn_blocked;
|
||||
|
||||
struct iscsi_init_params iscsi_init_params;
|
||||
|
||||
static char program_name[] = "iscsi-scstd";
|
||||
static const char program_name[] = "iscsi-scstd";
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
static struct option const long_options[] = {
|
||||
{"config", required_argument, 0, 'c'},
|
||||
{"foreground", no_argument, 0, 'f'},
|
||||
{"debug", required_argument, 0, 'd'},
|
||||
@@ -209,6 +208,7 @@ out:
|
||||
static int transmit_iser(int fd, bool start)
|
||||
{
|
||||
int opt = start;
|
||||
|
||||
return ioctl(fd, RDMA_CORK, &opt, sizeof(opt));
|
||||
}
|
||||
|
||||
@@ -370,6 +370,7 @@ out_close:
|
||||
static int transmit_sock(int fd, bool start)
|
||||
{
|
||||
int opt = start;
|
||||
|
||||
return setsockopt(fd, SOL_TCP, TCP_CORK, &opt, sizeof(opt));
|
||||
}
|
||||
|
||||
@@ -744,6 +745,7 @@ static void event_loop(void)
|
||||
(conn->state == STATE_EXIT) ||
|
||||
(conn->state == STATE_DROP)) {
|
||||
struct session *sess = conn->sess;
|
||||
|
||||
log_debug(1, "closing conn %p", conn);
|
||||
conn_free_pdu(conn);
|
||||
close(pollfd->fd);
|
||||
@@ -928,6 +930,7 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
} else if (pid) {
|
||||
int res = -1;
|
||||
|
||||
close(init_report_pipe[1]);
|
||||
if (read(init_report_pipe[0], &res, sizeof(res)) < sizeof(res))
|
||||
exit(-1);
|
||||
|
||||
@@ -299,6 +299,7 @@ static int login_check_reinstatement(struct connection *conn)
|
||||
goto out;
|
||||
} else {
|
||||
struct connection *c = conn_find(session, conn->cid);
|
||||
|
||||
if (c != NULL) {
|
||||
/* Kernel will do connection reinstatement */
|
||||
log_debug(1, "Conn %x reinstatement "
|
||||
@@ -527,6 +528,7 @@ static void login_start(struct connection *conn)
|
||||
if (session_type) {
|
||||
if (!strcmp(session_type, "Discovery")) {
|
||||
int ret = conn->is_discovery(conn->fd);
|
||||
|
||||
if (ret) {
|
||||
login_rsp_tgt_err(conn, ISCSI_STATUS_MISSING_FIELDS);
|
||||
return;
|
||||
@@ -645,6 +647,7 @@ static int login_finish(struct connection *conn)
|
||||
if (conn->is_iser &&
|
||||
conn->session_params[key_target_recv_data_length].key_state == KEY_STATE_START) {
|
||||
char buf[32] = "\0";
|
||||
|
||||
params_val_to_str(session_keys, key_target_recv_data_length,
|
||||
session_keys[key_target_recv_data_length].local_def,
|
||||
buf, sizeof(buf));
|
||||
@@ -750,7 +753,7 @@ static void cmnd_exec_login(struct connection *conn)
|
||||
login_start(conn);
|
||||
if (rsp->status_class)
|
||||
return;
|
||||
//else fall through
|
||||
/* else fall through */
|
||||
case STATE_SECURITY:
|
||||
text_scan_security(conn);
|
||||
if (rsp->status_class)
|
||||
@@ -848,6 +851,7 @@ static void cmnd_exec_login(struct connection *conn)
|
||||
}
|
||||
if (!stay && !nsg_disagree) {
|
||||
int err;
|
||||
|
||||
text_check_params(conn);
|
||||
err = login_finish(conn);
|
||||
if (err != 0) {
|
||||
@@ -1081,7 +1085,7 @@ void cmnd_finish(struct connection *conn)
|
||||
conn->state = STATE_LOGIN;
|
||||
break;
|
||||
case STATE_SECURITY_FULL:
|
||||
//fall through
|
||||
/* fall through */
|
||||
case STATE_LOGIN_FULL:
|
||||
if (conn->session_type == SESSION_NORMAL)
|
||||
conn->state = STATE_KERNEL;
|
||||
|
||||
@@ -180,8 +180,8 @@ struct connection {
|
||||
#define ISCSI_USER_DIR_INCOMING 0
|
||||
#define ISCSI_USER_DIR_OUTGOING 1
|
||||
|
||||
#define ISCSI_USER_NAME(attr) (attr)->attr_key
|
||||
#define ISCSI_USER_PASS(attr) (attr)->attr_value
|
||||
#define ISCSI_USER_NAME(attr) ((attr)->attr_key)
|
||||
#define ISCSI_USER_PASS(attr) ((attr)->attr_value)
|
||||
|
||||
struct iscsi_attr {
|
||||
struct __qelem ulist;
|
||||
|
||||
@@ -551,6 +551,7 @@ int isns_target_register(char *name)
|
||||
|
||||
if (scn_listen_port) {
|
||||
uint32_t sport = htonl(scn_listen_port);
|
||||
|
||||
err = isns_tlv_set(&tlv, max_buf - length, ISNS_ATTR_SCN_PORT,
|
||||
sizeof(sport), &sport);
|
||||
if (err < 0)
|
||||
|
||||
@@ -37,6 +37,7 @@ static void dolog_nofunc(int prio, const char *fmt, va_list ap)
|
||||
if (log_daemon) {
|
||||
int len = strlen(fmt);
|
||||
char f[len+1+1];
|
||||
|
||||
if (fmt[len] != '\n')
|
||||
sprintf(f, "%s\n", fmt);
|
||||
else
|
||||
@@ -63,6 +64,7 @@ static void dolog(int prio, const char *func, int line, const char *fmt, va_list
|
||||
if (log_daemon) {
|
||||
int len = strlen(func) + strlen(fmt);
|
||||
char f[len+1+1];
|
||||
|
||||
if (fmt[len] != '\n')
|
||||
sprintf(f, "%s:%d: %s %s\n", func, line,
|
||||
(prio == LOG_ERR) ? "ERROR:" : "", fmt);
|
||||
@@ -83,13 +85,14 @@ static void dolog(int prio, const char *func, int line, const char *fmt, va_list
|
||||
|
||||
void __log(const char *func, int line, int prio, int level, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (level) {
|
||||
prio = LOG_DEBUG;
|
||||
if (log_level < level)
|
||||
return;
|
||||
}
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
dolog(prio, func, line, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
@@ -29,6 +29,7 @@ size_t strlcpy(char *dest, const char *src, size_t size)
|
||||
|
||||
if (size) {
|
||||
size_t len = (ret >= size) ? size - 1 : ret;
|
||||
|
||||
memcpy(dest, src, len);
|
||||
dest[len] = '\0';
|
||||
}
|
||||
@@ -56,6 +57,7 @@ int params_index_by_name_numwild(const char *name, const struct iscsi_key *keys)
|
||||
for (i = 0; keys[i].name; i++) {
|
||||
if (!strncasecmp(keys[i].name, name, strlen(keys[i].name))) {
|
||||
int j;
|
||||
|
||||
if (strlen(keys[i].name) > strlen(name))
|
||||
continue;
|
||||
for (j = strlen(keys[i].name); j < strlen(name); j++) {
|
||||
@@ -205,8 +207,8 @@ static int digest_str_to_val(const char *str, unsigned int *val)
|
||||
{
|
||||
int err = 0;
|
||||
const char *p, *q;
|
||||
p = str;
|
||||
|
||||
p = str;
|
||||
*val = 0;
|
||||
do {
|
||||
while ((*p != '\0') && isspace(*p))
|
||||
|
||||
@@ -164,6 +164,7 @@ static int mpt_target_show(struct seq_file *seq, void *v)
|
||||
if (ioc->bus_type == SPI) {
|
||||
#endif
|
||||
int i = 0;
|
||||
|
||||
seq_printf(seq, "Target ID :%d\n"
|
||||
"Capabilities :0x%x\n"
|
||||
"PhysicalInterface:0x%x\n",
|
||||
@@ -252,6 +253,7 @@ static ssize_t mpt_proc_target_write(struct file *file, const char __user *buf,
|
||||
if (strncmp("target_id:", tmp, strlen("target_id:")) == 0) {
|
||||
char *s = tmp + strlen("target_id:");
|
||||
int id = simple_strtoul(s, NULL, 0);
|
||||
|
||||
if (id < MPT_MAX_SCSI_DEVICES) {
|
||||
if (IsScsi(tgt->priv)) {
|
||||
TRACE_DBG("Changing target id to %d\n", id);
|
||||
|
||||
Reference in New Issue
Block a user