From f5feb17306918069dd27861147b31ac3da37abf5 Mon Sep 17 00:00:00 2001 From: Miao Xie Date: Wed, 6 Feb 2008 01:36:53 -0800 Subject: [PATCH] --- yaml --- r: 83412 b: refs/heads/master c: 5e2cb1018a8a583b83d56c80f46507da6f3f2b57 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/kernel/time/clocksource.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/[refs] b/[refs] index 669c1853a2aa..b60665ef7f2a 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: be6c28e62e3a304b74013afab029af2021e1f50d +refs/heads/master: 5e2cb1018a8a583b83d56c80f46507da6f3f2b57 diff --git a/trunk/kernel/time/clocksource.c b/trunk/kernel/time/clocksource.c index 6e9259a5d501..81afb3927ecc 100644 --- a/trunk/kernel/time/clocksource.c +++ b/trunk/kernel/time/clocksource.c @@ -363,15 +363,13 @@ void clocksource_unregister(struct clocksource *cs) static ssize_t sysfs_show_current_clocksources(struct sys_device *dev, char *buf) { - char *curr = buf; + ssize_t count = 0; spin_lock_irq(&clocksource_lock); - curr += sprintf(curr, "%s ", curr_clocksource->name); + count = snprintf(buf, PAGE_SIZE, "%s\n", curr_clocksource->name); spin_unlock_irq(&clocksource_lock); - curr += sprintf(curr, "\n"); - - return curr - buf; + return count; } /** @@ -439,17 +437,20 @@ static ssize_t sysfs_show_available_clocksources(struct sys_device *dev, char *buf) { struct clocksource *src; - char *curr = buf; + ssize_t count = 0; spin_lock_irq(&clocksource_lock); list_for_each_entry(src, &clocksource_list, list) { - curr += sprintf(curr, "%s ", src->name); + count += snprintf(buf + count, + max((ssize_t)PAGE_SIZE - count, (ssize_t)0), + "%s ", src->name); } spin_unlock_irq(&clocksource_lock); - curr += sprintf(curr, "\n"); + count += snprintf(buf + count, + max((ssize_t)PAGE_SIZE - count, (ssize_t)0), "\n"); - return curr - buf; + return count; } /*