[net-next,v2,1/3] string_helpers: Move string_is_valid() to the header
Commit Message
Move string_is_valid() to the header for wider use.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
---
v2: added tag and updated subject (Simon)
include/linux/string_helpers.h | 5 +++++
net/tipc/netlink_compat.c | 6 +-----
2 files changed, 6 insertions(+), 5 deletions(-)
Comments
On Mon, 6 Feb 2023 18:13:12 +0200 Andy Shevchenko wrote:
> +static inline bool string_is_valid(const char *s, int len)
> +{
> + return memchr(s, '\0', len) ? true : false;
> +}
I was tempted to suggest adding a kdoc, but perhaps the function
doesn't have an obvious enough name? Maybe we should call the helper
string_is_terminated(), instead?
On Wed, Feb 8, 2023 at 6:29 AM Jakub Kicinski <kuba@kernel.org> wrote:
> On Mon, 6 Feb 2023 18:13:12 +0200 Andy Shevchenko wrote:
> > +static inline bool string_is_valid(const char *s, int len)
> > +{
> > + return memchr(s, '\0', len) ? true : false;
> > +}
>
> I was tempted to suggest adding a kdoc, but perhaps the function
> doesn't have an obvious enough name? Maybe we should call the helper
> string_is_terminated(), instead?
Sure.
@@ -12,6 +12,11 @@ struct device;
struct file;
struct task_struct;
+static inline bool string_is_valid(const char *s, int len)
+{
+ return memchr(s, '\0', len) ? true : false;
+}
+
/* Descriptions of the types of units to
* print in */
enum string_size_units {
@@ -39,6 +39,7 @@
#include "node.h"
#include "net.h"
#include <net/genetlink.h>
+#include <linux/string_helpers.h>
#include <linux/tipc_config.h>
/* The legacy API had an artificial message length limit called
@@ -173,11 +174,6 @@ static struct sk_buff *tipc_get_err_tlv(char *str)
return buf;
}
-static inline bool string_is_valid(char *s, int len)
-{
- return memchr(s, '\0', len) ? true : false;
-}
-
static int __tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
struct tipc_nl_compat_msg *msg,
struct sk_buff *arg)