sk-unix: Use unsigned values for inodes

Submitted by Cyrill Gorcunov on March 27, 2018, 9:58 a.m.

Details

Message ID 20180327095815.24144-1-gorcunov@gmail.com
State Accepted
Series "sk-unix: Use unsigned values for inodes"
Headers show

Commit Message

Cyrill Gorcunov March 27, 2018, 9:58 a.m.
From: Cyrill Gorcunov <gorcunov@virtuozzo.com>

It is especially important when accessing a hash --
there must be no negative indices ever.

https://jira.sw.ru/browse/PSBM-82945

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
---
 criu/sk-unix.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 0b0fa699c826..a5bbe57653d0 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -101,7 +101,7 @@  struct unix_sk_listen_icon {
 
 static struct unix_sk_listen_icon *unix_listen_icons[SK_HASH_SIZE];
 
-static struct unix_sk_listen_icon *lookup_unix_listen_icons(int peer_ino)
+static struct unix_sk_listen_icon *lookup_unix_listen_icons(unsigned int peer_ino)
 {
 	struct unix_sk_listen_icon *ic;
 
@@ -702,8 +702,8 @@  static int unix_collect_one(const struct unix_diag_msg *m,
 	}
 
 	if (tb[UNIX_DIAG_ICONS]) {
-		int len = nla_len(tb[UNIX_DIAG_ICONS]);
-		int i;
+		unsigned int len = nla_len(tb[UNIX_DIAG_ICONS]);
+		unsigned int i;
 
 		d->icons = xmalloc(len);
 		if (!d->icons)
@@ -718,7 +718,7 @@  static int unix_collect_one(const struct unix_diag_msg *m,
 		 */
 		for (i = 0; i < d->nr_icons; i++) {
 			struct unix_sk_listen_icon *e, **chain;
-			int n;
+			unsigned int n;
 
 			e = xzalloc(sizeof(*e));
 			if (!e)

Comments

Cyrill Gorcunov Aug. 28, 2018, 12:38 p.m.
Ping? The patch is still needed!
Andrey Vagin Aug. 29, 2018, 12:03 p.m.
Applied, thanks!

On Tue, Mar 27, 2018 at 12:58:15PM +0300, Cyrill Gorcunov wrote:
> From: Cyrill Gorcunov <gorcunov@virtuozzo.com>
> 
> It is especially important when accessing a hash --
> there must be no negative indices ever.
> 
> https://jira.sw.ru/browse/PSBM-82945
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
> ---
>  criu/sk-unix.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/criu/sk-unix.c b/criu/sk-unix.c
> index 0b0fa699c826..a5bbe57653d0 100644
> --- a/criu/sk-unix.c
> +++ b/criu/sk-unix.c
> @@ -101,7 +101,7 @@ struct unix_sk_listen_icon {
>  
>  static struct unix_sk_listen_icon *unix_listen_icons[SK_HASH_SIZE];
>  
> -static struct unix_sk_listen_icon *lookup_unix_listen_icons(int peer_ino)
> +static struct unix_sk_listen_icon *lookup_unix_listen_icons(unsigned int peer_ino)
>  {
>  	struct unix_sk_listen_icon *ic;
>  
> @@ -702,8 +702,8 @@ static int unix_collect_one(const struct unix_diag_msg *m,
>  	}
>  
>  	if (tb[UNIX_DIAG_ICONS]) {
> -		int len = nla_len(tb[UNIX_DIAG_ICONS]);
> -		int i;
> +		unsigned int len = nla_len(tb[UNIX_DIAG_ICONS]);
> +		unsigned int i;
>  
>  		d->icons = xmalloc(len);
>  		if (!d->icons)
> @@ -718,7 +718,7 @@ static int unix_collect_one(const struct unix_diag_msg *m,
>  		 */
>  		for (i = 0; i < d->nr_icons; i++) {
>  			struct unix_sk_listen_icon *e, **chain;
> -			int n;
> +			unsigned int n;
>  
>  			e = xzalloc(sizeof(*e));
>  			if (!e)
> -- 
> 2.14.3
>