On 3/7/2024 8:19 PM, Henry Wang wrote:
     len = min(strlen(str), ring->ring_size - 1);

This actually will fire below errors on my build env, hence I separated them with a different variable.

tools/include/xen-tools/common-macros.h:38:21: error: comparison of distinct pointer types lacks a cast [-Werror]
|    38 |         (void) (&_x == &_y); \
|       |                     ^~
| io.c:695:11: note: in expansion of macro 'min'
|   695 |     len = min(strlen(str), MAX_ERRSTR_LEN - 1);;
|       |           ^~~
| cc1: all warnings being treated as errors

     memcpy(ring->buffer, str, len);
     ((char *)ring->buffer)[len] = '\0';
     pthread_mutex_unlock(&mutex);

I will follow your style in V3 if you don't have any specific comment on the error that I posted above (plus also not strongly disagree with my approach in v2).

In fact I think
```
len = min(strlen(str), (size_t)(MAX_ERRSTR_LEN - 1));
```
is better.

Kind regards,
Henry

Kind regards,
Henry

Jan


Reply via email to