Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 622d42ca authored by Paul Jackson's avatar Paul Jackson Committed by Linus Torvalds
Browse files

cgroup simplify space stripping



Simplify the space stripping code in cgroup file write.

[akpm@linux-foundation.org: s/BUG_ON/BUILD_BUG_ON/]
Signed-off-by: default avatarPaul Jackson <pj@sgi.com>
Acked-by: default avatarPaul Menage <menage@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e18f6318
Loading
Loading
Loading
Loading
+3 −14
Original line number Original line Diff line number Diff line
@@ -1326,6 +1326,7 @@ static ssize_t cgroup_common_file_write(struct cgroup *cgrp,
		goto out1;
		goto out1;
	}
	}
	buffer[nbytes] = 0;	/* nul-terminate */
	buffer[nbytes] = 0;	/* nul-terminate */
	strstrip(buffer);	/* strip -just- trailing whitespace */


	mutex_lock(&cgroup_mutex);
	mutex_lock(&cgroup_mutex);


@@ -1346,21 +1347,9 @@ static ssize_t cgroup_common_file_write(struct cgroup *cgrp,
			clear_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
			clear_bit(CGRP_NOTIFY_ON_RELEASE, &cgrp->flags);
		break;
		break;
	case FILE_RELEASE_AGENT:
	case FILE_RELEASE_AGENT:
	{
		BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX);
		struct cgroupfs_root *root = cgrp->root;
		strcpy(cgrp->root->release_agent_path, buffer);
		/* Strip trailing newline */
		if (nbytes && (buffer[nbytes-1] == '\n'))
			buffer[nbytes-1] = 0;

		/* We never write anything other than '\0'
		 * into the last char of release_agent_path,
		 * so it always remains a NUL-terminated
		 * string */
		strncpy(root->release_agent_path, buffer, nbytes);
		root->release_agent_path[nbytes] = 0;

		break;
		break;
	}
	default:
	default:
		retval = -EINVAL;
		retval = -EINVAL;
		goto out2;
		goto out2;