mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
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:
parent
1d07a5bf3c
commit
1a77b97c7f
@ -2630,6 +2630,7 @@ virStringSplitCount;
|
|||||||
virStringStripControlChars;
|
virStringStripControlChars;
|
||||||
virStringStripIPv6Brackets;
|
virStringStripIPv6Brackets;
|
||||||
virStringToUpper;
|
virStringToUpper;
|
||||||
|
virStringTrimOptionalNewline;
|
||||||
virStrncpy;
|
virStrncpy;
|
||||||
virStrndup;
|
virStrndup;
|
||||||
virStrToDouble;
|
virStrToDouble;
|
||||||
|
@ -1180,3 +1180,17 @@ virStringEncodeBase64(const uint8_t *buf, size_t buflen)
|
|||||||
|
|
||||||
return ret;
|
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';
|
||||||
|
}
|
||||||
|
@ -288,12 +288,6 @@ bool virStringBufferIsPrintable(const uint8_t *buf, size_t buflen);
|
|||||||
|
|
||||||
char *virStringEncodeBase64(const uint8_t *buf, size_t buflen);
|
char *virStringEncodeBase64(const uint8_t *buf, size_t buflen);
|
||||||
|
|
||||||
static inline void
|
void virStringTrimOptionalNewline(char *str);
|
||||||
virStringTrimOptionalNewline(char *str)
|
|
||||||
{
|
|
||||||
char *tmp = str + strlen(str) - 1;
|
|
||||||
if (*tmp == '\n')
|
|
||||||
*tmp = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* __VIR_STRING_H__ */
|
#endif /* __VIR_STRING_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user