All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cgroup: do not use dprintf in cgroup_event_listener
@ 2010-02-25 10:24 Kirill A. Shutemov
  2010-02-26  9:07 ` Li Zefan
       [not found] ` <1267093447-2607-1-git-send-email-kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2010-02-25 10:24 UTC (permalink / raw)
  To: containers, Li Zefan
  Cc: Paul Menage, Andrew Morton, KAMEZAWA Hiroyuki, linux-kernel,
	Kirill A. Shutemov

glibc's dprintf(3) is buggy:
http://sourceware.org/bugzilla/show_bug.cgi?id=11319

Let's not to use it in the example.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
---
 Documentation/cgroups/cgroup_event_listener.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Documentation/cgroups/cgroup_event_listener.c b/Documentation/cgroups/cgroup_event_listener.c
index 8c2d7aa..8c2bfc4 100644
--- a/Documentation/cgroups/cgroup_event_listener.c
+++ b/Documentation/cgroups/cgroup_event_listener.c
@@ -23,6 +23,7 @@ int main(int argc, char **argv)
 	int cfd = -1;
 	int event_control = -1;
 	char event_control_path[PATH_MAX];
+	char line[LINE_MAX];
 	int ret;
 
 	if (argc != 3) {
@@ -39,7 +40,7 @@ int main(int argc, char **argv)
 
 	ret = snprintf(event_control_path, PATH_MAX, "%s/cgroup.event_control",
 			dirname(argv[1]));
-	if (ret > PATH_MAX) {
+	if (ret >= PATH_MAX) {
 		fputs("Path to cgroup.event_control is too long\n", stderr);
 		goto out;
 	}
@@ -57,7 +58,13 @@ int main(int argc, char **argv)
 		goto out;
 	}
 
-	ret = dprintf(event_control, "%d %d %s", efd, cfd, argv[2]);
+	ret = snprintf(line, LINE_MAX, "%d %d %s", efd, cfd, argv[2]);
+	if (ret >= LINE_MAX) {
+		fputs("Arguments string is too long\n", stderr);
+		goto out;
+	}
+
+	ret = write(event_control, line, strlen(line) + 1);
 	if (ret == -1) {
 		perror("Cannot write to cgroup.event_control");
 		goto out;
-- 
1.6.6.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] cgroup: do not use dprintf in cgroup_event_listener
@ 2010-02-25 10:24 Kirill A. Shutemov
  0 siblings, 0 replies; 4+ messages in thread
From: Kirill A. Shutemov @ 2010-02-25 10:24 UTC (permalink / raw)
  To: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Li Zefan
  Cc: Paul Menage, Andrew Morton, linux-kernel-u79uwXL29TY76Z2rM5mHXA

glibc's dprintf(3) is buggy:
http://sourceware.org/bugzilla/show_bug.cgi?id=11319

Let's not to use it in the example.

Signed-off-by: Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
---
 Documentation/cgroups/cgroup_event_listener.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Documentation/cgroups/cgroup_event_listener.c b/Documentation/cgroups/cgroup_event_listener.c
index 8c2d7aa..8c2bfc4 100644
--- a/Documentation/cgroups/cgroup_event_listener.c
+++ b/Documentation/cgroups/cgroup_event_listener.c
@@ -23,6 +23,7 @@ int main(int argc, char **argv)
 	int cfd = -1;
 	int event_control = -1;
 	char event_control_path[PATH_MAX];
+	char line[LINE_MAX];
 	int ret;
 
 	if (argc != 3) {
@@ -39,7 +40,7 @@ int main(int argc, char **argv)
 
 	ret = snprintf(event_control_path, PATH_MAX, "%s/cgroup.event_control",
 			dirname(argv[1]));
-	if (ret > PATH_MAX) {
+	if (ret >= PATH_MAX) {
 		fputs("Path to cgroup.event_control is too long\n", stderr);
 		goto out;
 	}
@@ -57,7 +58,13 @@ int main(int argc, char **argv)
 		goto out;
 	}
 
-	ret = dprintf(event_control, "%d %d %s", efd, cfd, argv[2]);
+	ret = snprintf(line, LINE_MAX, "%d %d %s", efd, cfd, argv[2]);
+	if (ret >= LINE_MAX) {
+		fputs("Arguments string is too long\n", stderr);
+		goto out;
+	}
+
+	ret = write(event_control, line, strlen(line) + 1);
 	if (ret == -1) {
 		perror("Cannot write to cgroup.event_control");
 		goto out;
-- 
1.6.6.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cgroup: do not use dprintf in cgroup_event_listener
       [not found] ` <1267093447-2607-1-git-send-email-kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
@ 2010-02-26  9:07   ` Li Zefan
  0 siblings, 0 replies; 4+ messages in thread
From: Li Zefan @ 2010-02-26  9:07 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Paul Menage, Andrew Morton, linux-kernel-u79uwXL29TY76Z2rM5mHXA

Kirill A. Shutemov wrote:
> glibc's dprintf(3) is buggy:
> http://sourceware.org/bugzilla/show_bug.cgi?id=11319
> 
> Let's not to use it in the example.
> 
> Signed-off-by: Kirill A. Shutemov <kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>

Reviewed-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cgroup: do not use dprintf in cgroup_event_listener
  2010-02-25 10:24 [PATCH] cgroup: do not use dprintf in cgroup_event_listener Kirill A. Shutemov
@ 2010-02-26  9:07 ` Li Zefan
       [not found] ` <1267093447-2607-1-git-send-email-kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Li Zefan @ 2010-02-26  9:07 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: containers, Paul Menage, Andrew Morton, KAMEZAWA Hiroyuki,
	linux-kernel

Kirill A. Shutemov wrote:
> glibc's dprintf(3) is buggy:
> http://sourceware.org/bugzilla/show_bug.cgi?id=11319
> 
> Let's not to use it in the example.
> 
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>

Reviewed-by: Li Zefan <lizf@cn.fujitsu.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-02-26  9:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-25 10:24 [PATCH] cgroup: do not use dprintf in cgroup_event_listener Kirill A. Shutemov
2010-02-26  9:07 ` Li Zefan
     [not found] ` <1267093447-2607-1-git-send-email-kirill-oKw7cIdHH8eLwutG50LtGA@public.gmane.org>
2010-02-26  9:07   ` Li Zefan
  -- strict thread matches above, loose matches on Subject: below --
2010-02-25 10:24 Kirill A. Shutemov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.