mirror of
https://github.com/linux-can/can-utils.git
synced 2026-08-04 22:09:57 +02:00
can-utils: fix sign-compare warnings (#513)
Fixing several build issues reported by Gary Bisson when he was building can-utils with clang (AOSP14). URL: https://github.com/linux-can/can-utils/pull/512 Reported-by: Gary Bisson (https://github.com/gibsson) Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
This commit is contained in:
@@ -268,10 +268,10 @@ static int isobusfs_cli_rx_one(struct isobusfs_priv *priv, int sock)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int isobusfs_cli_handle_events(struct isobusfs_priv *priv, int nfds)
|
||||
static int isobusfs_cli_handle_events(struct isobusfs_priv *priv, unsigned int nfds)
|
||||
{
|
||||
int ret;
|
||||
int n;
|
||||
unsigned int n;
|
||||
|
||||
for (n = 0; n < nfds && n < priv->cmn.epoll_events_size; ++n) {
|
||||
struct epoll_event *ev = &priv->cmn.epoll_events[n];
|
||||
@@ -341,7 +341,7 @@ int isobusfs_cli_process_events_and_tasks(struct isobusfs_priv *priv)
|
||||
return ret;
|
||||
|
||||
if (nfds > 0) {
|
||||
ret = isobusfs_cli_handle_events(priv, nfds);
|
||||
ret = isobusfs_cli_handle_events(priv, (unsigned int)nfds);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -823,7 +823,7 @@ void isobusfs_cmn_dump_last_x_bytes(const uint8_t *buffer, size_t buffer_size,
|
||||
size_t start_offset = 0;
|
||||
char *output_ptr;
|
||||
unsigned char c;
|
||||
size_t remaining;
|
||||
int remaining;
|
||||
char output[80];
|
||||
int n, j;
|
||||
|
||||
@@ -832,7 +832,7 @@ void isobusfs_cmn_dump_last_x_bytes(const uint8_t *buffer, size_t buffer_size,
|
||||
|
||||
for (size_t i = start_offset; i < buffer_size; i += 8) {
|
||||
output_ptr = output;
|
||||
remaining = sizeof(output);
|
||||
remaining = (int)sizeof(output);
|
||||
|
||||
n = snprintf(output_ptr, remaining, "%08lx: ",
|
||||
(unsigned long)(start_offset + i));
|
||||
|
||||
@@ -201,10 +201,10 @@ done:
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static int isobusfs_srv_handle_events(struct isobusfs_srv_priv *priv, int nfds)
|
||||
static int isobusfs_srv_handle_events(struct isobusfs_srv_priv *priv, unsigned int nfds)
|
||||
{
|
||||
int ret;
|
||||
int n;
|
||||
unsigned int n;
|
||||
|
||||
for (n = 0; n < nfds && n < priv->cmn.epoll_events_size; ++n) {
|
||||
struct epoll_event *ev = &priv->cmn.epoll_events[n];
|
||||
|
||||
@@ -36,7 +36,7 @@ int isobusfs_srv_request_volume(struct isobusfs_srv_priv *priv,
|
||||
struct isobusfs_srv_client *client,
|
||||
struct isobusfs_srv_volume *volume)
|
||||
{
|
||||
int j;
|
||||
unsigned int j;
|
||||
|
||||
/* Check if the client already requested this volume */
|
||||
for (j = 0; j < ARRAY_SIZE(volume->clients); j++) {
|
||||
|
||||
@@ -110,7 +110,7 @@ int isobusfs_path_to_linux_path(struct isobusfs_srv_priv *priv,
|
||||
|
||||
ptr++;
|
||||
vol_end++;
|
||||
if (ptr - linux_path >= linux_path_size) {
|
||||
if (ptr - linux_path >= (long int)linux_path_size) {
|
||||
/* Ensure null termination */
|
||||
linux_path[linux_path_size - 1] = '\0';
|
||||
break;
|
||||
|
||||
+10
-10
@@ -16,7 +16,7 @@
|
||||
static struct isobusfs_srv_handles *
|
||||
isobusfs_srv_walk_handles(struct isobusfs_srv_priv *priv, const char *path)
|
||||
{
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(priv->handles); i++) {
|
||||
if (priv->handles[i].path == NULL)
|
||||
@@ -32,9 +32,9 @@ isobusfs_srv_walk_handles(struct isobusfs_srv_priv *priv, const char *path)
|
||||
static int isobusfs_srv_add_file(struct isobusfs_srv_priv *priv,
|
||||
const char *path, int fd, DIR *dir)
|
||||
{
|
||||
int j;
|
||||
unsigned int j;
|
||||
|
||||
if (priv->handles_count >= ARRAY_SIZE(priv->handles)) {
|
||||
if (priv->handles_count >= (int)ARRAY_SIZE(priv->handles)) {
|
||||
pr_err("too many handles");
|
||||
return -ENOSPC;
|
||||
}
|
||||
@@ -55,7 +55,7 @@ static int isobusfs_srv_add_file(struct isobusfs_srv_priv *priv,
|
||||
static int isobusfs_srv_add_client_to_file(struct isobusfs_srv_handles *file,
|
||||
struct isobusfs_srv_client *client)
|
||||
{
|
||||
int j;
|
||||
unsigned int j;
|
||||
|
||||
for (j = 0; j < ARRAY_SIZE(file->clients); j++) {
|
||||
if (file->clients[j] == client)
|
||||
@@ -102,7 +102,7 @@ static int isobusfs_srv_request_file(struct isobusfs_srv_priv *priv,
|
||||
static struct isobusfs_srv_handles *
|
||||
isobusfs_srv_get_handle(struct isobusfs_srv_priv *priv, int handle)
|
||||
{
|
||||
if (handle < 0 || handle >= ARRAY_SIZE(priv->handles))
|
||||
if (handle < 0 || handle >= (int)ARRAY_SIZE(priv->handles))
|
||||
return NULL;
|
||||
|
||||
return &priv->handles[handle];
|
||||
@@ -113,7 +113,7 @@ static int isobusfs_srv_release_handle(struct isobusfs_srv_priv *priv,
|
||||
int handle)
|
||||
{
|
||||
struct isobusfs_srv_handles *hdl = isobusfs_srv_get_handle(priv, handle);
|
||||
int client_index;
|
||||
unsigned int client_index;
|
||||
|
||||
if (!hdl) {
|
||||
pr_warn("%s: invalid handle %d", __func__, handle);
|
||||
@@ -152,8 +152,8 @@ static int isobusfs_srv_release_handle(struct isobusfs_srv_priv *priv,
|
||||
void isobusfs_srv_remove_client_from_handles(struct isobusfs_srv_priv *priv,
|
||||
struct isobusfs_srv_client *client)
|
||||
{
|
||||
int handle;
|
||||
int client_index;
|
||||
unsigned int handle;
|
||||
unsigned int client_index;
|
||||
|
||||
for (handle = 0; handle < ARRAY_SIZE(priv->handles); handle++) {
|
||||
struct isobusfs_srv_handles *hdl = &priv->handles[handle];
|
||||
@@ -488,7 +488,7 @@ static int check_access_with_base(const char *base_dir,
|
||||
char full_path[ISOBUSFS_SRV_MAX_PATH_LEN];
|
||||
|
||||
if (snprintf(full_path, sizeof(full_path), "%s/%s", base_dir,
|
||||
relative_path) >= sizeof(full_path)) {
|
||||
relative_path) >= (int)sizeof(full_path)) {
|
||||
return -ENAMETOOLONG;
|
||||
}
|
||||
|
||||
@@ -519,7 +519,7 @@ static int isobusfs_srv_read_directory(struct isobusfs_srv_handles *handle,
|
||||
* either returning an error or restarting from the beginning of the directory, depending
|
||||
* on the application's requirements.
|
||||
*/
|
||||
for (size_t i = 0; i < handle->dir_pos &&
|
||||
for (int i = 0; i < handle->dir_pos &&
|
||||
(entry = readdir(dir)) != NULL; i++) {
|
||||
/* Iterating to the desired position */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user