Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1610275

RE: [PATCH 2/3] tools lib api fs: Add sysfs__write_int function

From "Elliott, Robert (Persistent Memory)" <elliott@hpe.com>
Newsgroups linux.kernel
Subject RE: [PATCH 2/3] tools lib api fs: Add sysfs__write_int function
Date 2017-03-28 05:40 +0200
Message-ID <tpQ9b-1CM-3@gated-at.bofh.it> (permalink)
References <tofOp-6a9-23@gated-at.bofh.it> <tofOp-6a9-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-
> owner@vger.kernel.org] On Behalf Of kan.liang@intel.com
> Sent: Thursday, March 23, 2017 1:26 PM
> Subject: [PATCH 2/3] tools lib api fs: Add sysfs__write_int function
...
> diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
...
> +
> +int sysfs__write_int(const char *entry, int value)
> +{
> +	char path[PATH_MAX];
> +	const char *sysfs = sysfs__mountpoint();
> +
> +	if (!sysfs)
> +		return -1;
> +
> +	snprintf(path, sizeof(path), "%s/%s", sysfs, entry);
> +
> +	return filename__write_int(path, value);

In the unlikely event of an overflow, it would be safer to confirm that
the string fit into the path array (by using scnprintf()?) before trying
to open that path.

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 2/3] tools lib api fs: Add sysfs__write_int function kan.liang@intel.com - 2017-03-23 19:40 +0100
  RE: [PATCH 2/3] tools lib api fs: Add sysfs__write_int function "Elliott, Robert (Persistent Memory)" <elliott@hpe.com> - 2017-03-28 05:40 +0200

csiph-web