Minor output buffer size related fixes

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1257 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2009-10-23 11:52:32 +00:00
parent b08548b174
commit ac29495cee
3 changed files with 18 additions and 21 deletions

View File

@@ -23,47 +23,43 @@
#ifdef CONFIG_SCST_PROC
static void print_conn_state(char *p, size_t size, struct iscsi_conn *conn)
static int print_conn_state(char *p, size_t size, struct iscsi_conn *conn)
{
int printed = 0;
int pos = 0;
if (conn->closing) {
snprintf(p, size, "%s", "closing");
return;
pos += scnprintf(p, size, "%s", "closing");
goto out;
}
switch (conn->rd_state) {
case ISCSI_CONN_RD_STATE_PROCESSING:
size -= scnprintf(p, size, "%s", "read_processing ");
printed = 1;
pos += scnprintf(&p[pos], size - pos, "%s", "read_processing ");
break;
case ISCSI_CONN_RD_STATE_IN_LIST:
size -= scnprintf(p, size, "%s", "in_read_list ");
printed = 1;
pos += scnprintf(&p[pos], size - pos, "%s", "in_read_list ");
break;
}
switch (conn->wr_state) {
case ISCSI_CONN_WR_STATE_PROCESSING:
size -= scnprintf(p, size, "%s", "write_processing ");
printed = 1;
pos += scnprintf(&p[pos], size - pos, "%s", "write_processing ");
break;
case ISCSI_CONN_WR_STATE_IN_LIST:
size -= scnprintf(p, size, "%s", "in_write_list ");
printed = 1;
pos += scnprintf(&p[pos], size - pos, "%s", "in_write_list ");
break;
case ISCSI_CONN_WR_STATE_SPACE_WAIT:
size -= scnprintf(p, size, "%s", "space_waiting ");
printed = 1;
pos += scnprintf(&p[pos], size - pos, "%s", "space_waiting ");
break;
}
if (test_bit(ISCSI_CONN_REINSTATING, &conn->conn_aflags))
snprintf(p, size, "%s", "reinstating ");
else if (!printed)
snprintf(p, size, "%s", "established idle ");
pos += scnprintf(&p[pos], size - pos, "%s", "reinstating ");
else if (pos == 0)
pos += scnprintf(&p[pos], size - pos, "%s", "established idle ");
return;
out:
return pos;
}
static void print_digest_state(char *p, size_t size, unsigned long flags)

View File

@@ -339,6 +339,6 @@ enum scst_cmd_queue_type {
/*************************************************************
** Misc constants
*************************************************************/
#define SCST_SYSFS_BLOCK_SIZE (PAGE_SIZE - 64)
#define SCST_SYSFS_BLOCK_SIZE PAGE_SIZE
#endif /* __SCST_CONST_H */

View File

@@ -3411,9 +3411,10 @@ static ssize_t dev_user_sysfs_commands_show(struct kobject *kobj,
atomic_read(&ucmd->ucmd_ref),
ucmd->sent_to_user, ucmd->seen_by_user,
ucmd->aborted, ucmd->jammed, ucmd->cmd);
if (pos >= SCST_SYSFS_BLOCK_SIZE) {
scnprintf(&buf[ppos],
if (pos >= SCST_SYSFS_BLOCK_SIZE-1) {
ppos += scnprintf(&buf[ppos],
SCST_SYSFS_BLOCK_SIZE - ppos, "...\n");
pos = ppos;
break;
}
}