const ssize_t required = vsnprintf(s, length, format, args);
// Catch any errors
- if (required < 0)
+ if (unlikely(required < 0))
return -errno;
// Check if the entire string could be written
- if ((size_t)required >= length)
+ if (unlikely((size_t)required >= length))
return -ENOBUFS;
// Success
int __pakfire_string_set(char* s, const size_t length, const char* value) {
// If value is NULL or an empty, we will overwrite the buffer with just zeros
- if (!value) {
+ if (unlikely(!value)) {
*s = '\0';
return 0;
}
int __pakfire_string_setn(char* s, const size_t length, const char* value, const size_t l) {
// Fail if we don't have enough space
- if (l >= length)
+ if (unlikely(l >= length))
return -ENOBUFS;
// Copy the data
- else if (l > 0)
+ if (likely(l > 0))
memcpy(s, value, l);
// Terminate the result buffer