From 441440101d67b28532e2198b59c827a3affc9c11 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 20 Aug 2018 16:28:43 +0200 Subject: [PATCH] util/StringStrip: add more "nonnull" attributes --- src/util/StringStrip.cxx | 2 +- src/util/StringStrip.hxx | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/util/StringStrip.cxx b/src/util/StringStrip.cxx index 295f4ef1c..27b2b567f 100644 --- a/src/util/StringStrip.cxx +++ b/src/util/StringStrip.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2017 Max Kellermann + * Copyright 2009-2018 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/src/util/StringStrip.hxx b/src/util/StringStrip.hxx index 033c1a05a..b56e06eaf 100644 --- a/src/util/StringStrip.hxx +++ b/src/util/StringStrip.hxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2017 Max Kellermann + * Copyright 2009-2018 Max Kellermann * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -38,32 +38,32 @@ * Returns a pointer to the first non-whitespace character in the * string, or to the end of the string. */ -gcc_pure +gcc_pure gcc_returns_nonnull gcc_nonnull_all const char * StripLeft(const char *p) noexcept; -gcc_pure +gcc_pure gcc_returns_nonnull gcc_nonnull_all static inline char * StripLeft(char *p) noexcept { return const_cast(StripLeft((const char *)p)); } -gcc_pure +gcc_pure gcc_returns_nonnull gcc_nonnull_all const char * StripLeft(const char *p, const char *end) noexcept; /** * Determine the string's end as if it was stripped on the right side. */ -gcc_pure +gcc_pure gcc_returns_nonnull gcc_nonnull_all const char * StripRight(const char *p, const char *end) noexcept; /** * Determine the string's end as if it was stripped on the right side. */ -gcc_pure +gcc_pure gcc_returns_nonnull gcc_nonnull_all static inline char * StripRight(char *p, char *end) noexcept { @@ -75,13 +75,14 @@ StripRight(char *p, char *end) noexcept * Determine the string's length as if it was stripped on the right * side. */ -gcc_pure +gcc_pure gcc_nonnull_all size_t StripRight(const char *p, size_t length) noexcept; /** * Strip trailing whitespace by null-terminating the string. */ +gcc_nonnull_all void StripRight(char *p) noexcept; @@ -89,6 +90,7 @@ StripRight(char *p) noexcept; * Skip whitespace at the beginning and terminate the string after the * last non-whitespace character. */ +gcc_returns_nonnull gcc_nonnull_all char * Strip(char *p) noexcept;