Don't inline virStringTrimOptionalNewline

GCC complains that inlining virStringTrimOptionalNewline is not
likely on some platforms:

  cc1: warnings being treated as errors
  ../../src/util/virfile.c: In function 'virFileReadValueBitmap':
  ../../src/util/virstring.h:292: error: inlining failed in call to 'virStringTrimOptionalNewline': call is unlikely and code size would grow [-Winline]
  ../../src/util/virfile.c:3987: error: called from here [-Winline]

Inlining this function is not going to be a measurable performance
benefit either, since the time required to execute it is going to
be dominated by running of strlen() over the string, not by the
function call overhead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange 2017-05-10 09:16:11 +01:00
parent 1d07a5bf3c
commit 1a77b97c7f
3 changed files with 16 additions and 7 deletions

View File

@ -2630,6 +2630,7 @@ virStringSplitCount;
virStringStripControlChars;
virStringStripIPv6Brackets;
virStringToUpper;
virStringTrimOptionalNewline;
virStrncpy;
virStrndup;
virStrToDouble;

View File

@ -1180,3 +1180,17 @@ virStringEncodeBase64(const uint8_t *buf, size_t buflen)
return ret;
}
/**
* virStringTrimOptionalNewline:
* @str: the string to modify in-place
*
* Modify @str to remove a single '\n' character
* from its end, if one exists.
*/
void virStringTrimOptionalNewline(char *str)
{
char *tmp = str + strlen(str) - 1;
if (*tmp == '\n')
*tmp = '\0';
}

View File

@ -288,12 +288,6 @@ bool virStringBufferIsPrintable(const uint8_t *buf, size_t buflen);
char *virStringEncodeBase64(const uint8_t *buf, size_t buflen);
static inline void
virStringTrimOptionalNewline(char *str)
{
char *tmp = str + strlen(str) - 1;
if (*tmp == '\n')
*tmp = '\0';
}
void virStringTrimOptionalNewline(char *str);
#endif /* __VIR_STRING_H__ */