Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 315369
b: refs/heads/master
c: e2dbd60
h: refs/heads/master
i:
  315367: 72b151a
v: v3
  • Loading branch information
Erik Hugne authored and Paul Gortmaker committed Jul 13, 2012
1 parent f6011ce commit 02e6ee8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 43 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5deedde9fa65c494c9747dd66b1721be90991b64
refs/heads/master: e2dbd601346aeb64b1b387168b217fd5c301644e
52 changes: 10 additions & 42 deletions trunk/net/tipc/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,11 @@ struct print_buf *const TIPC_LOG = &log_buf;
* on the caller to prevent simultaneous use of the print buffer(s) being
* manipulated.
*/
static char print_string[TIPC_PB_MAX_STR];
static DEFINE_SPINLOCK(print_lock);

static void tipc_printbuf_move(struct print_buf *pb_to,
struct print_buf *pb_from);

#define FORMAT(PTR, LEN, FMT) \
{\
va_list args;\
va_start(args, FMT);\
LEN = vsprintf(PTR, FMT, args);\
va_end(args);\
*(PTR + LEN) = '\0';\
}

/**
* tipc_printbuf_init - initialize print buffer to empty
* @pb: pointer to print buffer structure
Expand Down Expand Up @@ -220,39 +210,17 @@ static void tipc_printbuf_move(struct print_buf *pb_to,
*/
void tipc_printf(struct print_buf *pb, const char *fmt, ...)
{
int chars_to_add;
int chars_left;
char save_char;

spin_lock_bh(&print_lock);

FORMAT(print_string, chars_to_add, fmt);
if (chars_to_add >= TIPC_PB_MAX_STR)
strcpy(print_string, "*** PRINT BUFFER STRING TOO LONG ***");

if (pb->buf) {
chars_left = pb->buf + pb->size - pb->crs - 1;
if (chars_to_add <= chars_left) {
strcpy(pb->crs, print_string);
pb->crs += chars_to_add;
} else if (chars_to_add >= (pb->size - 1)) {
strcpy(pb->buf, print_string + chars_to_add + 1
- pb->size);
pb->crs = pb->buf + pb->size - 1;
} else {
strcpy(pb->buf, print_string + chars_left);
save_char = print_string[chars_left];
print_string[chars_left] = 0;
strcpy(pb->crs, print_string);
print_string[chars_left] = save_char;
pb->crs = pb->buf + chars_to_add - chars_left;
}
}

if (pb->echo)
printk("%s", print_string);
int i;
va_list args;
char *buf;
int len;

spin_unlock_bh(&print_lock);
buf = pb->crs;
len = pb->buf + pb->size - pb->crs;
va_start(args, fmt);
i = vscnprintf(buf, len, fmt, args);
va_end(args);
pb->crs += i;
}

/**
Expand Down

0 comments on commit 02e6ee8

Please sign in to comment.