Skip to contentSkip to conversation

xen: Use 'unsigned int' instead of 'unsigned'

PATCH In review Yan Yankovskyi 3 participants 6 messages Feb 29, 2020 – Mar 3, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Use 'unsigned int' instead of 'unsigned'

Resolve the following warning, reported by checkpatch.pl:
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'

No functional change.

---
 drivers/xen/events/events_2l.c           | 18 ++---
 drivers/xen/events/events_base.c         | 92 ++++++++++++------------
 drivers/xen/events/events_fifo.c         | 52 +++++++-------
 drivers/xen/events/events_internal.h     | 46 ++++++------
 drivers/xen/evtchn.c                     |  7 +-
 drivers/xen/grant-table.c                | 12 ++--
 drivers/xen/mcelog.c                     |  6 +-
 drivers/xen/privcmd.c                    | 10 +--
 drivers/xen/xen-scsiback.c               |  8 +--
 drivers/xen/xenbus/xenbus_dev_frontend.c |  9 +--
 drivers/xen/xlate_mmu.c                  |  4 +-
 11 files changed, 133 insertions(+), 131 deletions(-)
drivers/xen/events/events_2l.c +9 -9
index 8edef51c92e5..38fa771fe3de 100644
@@ -42,48 +42,48 @@
 
 static DEFINE_PER_CPU(xen_ulong_t [EVTCHN_MASK_SIZE], cpu_evtchn_mask);
 
-static unsigned evtchn_2l_max_channels(void)
+static unsigned int evtchn_2l_max_channels(void)
 {
 	return EVTCHN_2L_NR_CHANNELS;
 }
 
-static void evtchn_2l_bind_to_cpu(struct irq_info *info, unsigned cpu)
+static void evtchn_2l_bind_to_cpu(struct irq_info *info, unsigned int cpu)
 {
 	clear_bit(info->evtchn, BM(per_cpu(cpu_evtchn_mask, info->cpu)));
 	set_bit(info->evtchn, BM(per_cpu(cpu_evtchn_mask, cpu)));
 }
 
-static void evtchn_2l_clear_pending(unsigned port)
+static void evtchn_2l_clear_pending(unsigned int port)
 {
 	struct shared_info *s = HYPERVISOR_shared_info;
 	sync_clear_bit(port, BM(&s->evtchn_pending[0]));
 }
 
-static void evtchn_2l_set_pending(unsigned port)
+static void evtchn_2l_set_pending(unsigned int port)
 {
 	struct shared_info *s = HYPERVISOR_shared_info;
 	sync_set_bit(port, BM(&s->evtchn_pending[0]));
 }
 
-static bool evtchn_2l_is_pending(unsigned port)
+static bool evtchn_2l_is_pending(unsigned int port)
 {
 	struct shared_info *s = HYPERVISOR_shared_info;
 	return sync_test_bit(port, BM(&s->evtchn_pending[0]));
 }
 
-static bool evtchn_2l_test_and_set_mask(unsigned port)
+static bool evtchn_2l_test_and_set_mask(unsigned int port)
 {
 	struct shared_info *s = HYPERVISOR_shared_info;
 	return sync_test_and_set_bit(port, BM(&s->evtchn_mask[0]));
 }
 
-static void evtchn_2l_mask(unsigned port)
+static void evtchn_2l_mask(unsigned int port)
 {
 	struct shared_info *s = HYPERVISOR_shared_info;
 	sync_set_bit(port, BM(&s->evtchn_mask[0]));
 }
 
-static void evtchn_2l_unmask(unsigned port)
+static void evtchn_2l_unmask(unsigned int port)
 {
 	struct shared_info *s = HYPERVISOR_shared_info;
 	unsigned int cpu = get_cpu();
@@ -159,7 +159,7 @@ static inline xen_ulong_t active_evtchns(unsigned int cpu,
  * a bitset of words which contain pending event bits.  The second
  * level is a bitset of pending events themselves.
  */
-static void evtchn_2l_handle_events(unsigned cpu)
+static void evtchn_2l_handle_events(unsigned int cpu)
 {
 	int irq;
 	xen_ulong_t pending_words;
drivers/xen/events/events_base.c +46 -46

284 lines not on this page · raw message

drivers/xen/events/events_fifo.c +26 -26

176 lines not on this page · raw message

drivers/xen/events/events_internal.h +23 -23

103 lines not on this page · raw message

drivers/xen/evtchn.c +4 -3
index 052b55a14ebc..4cd7a36031ea 100644
@@ -83,7 +83,7 @@ struct per_user_data {
 struct user_evtchn {
 	struct rb_node node;
 	struct per_user_data *user;
-	unsigned port;
+	unsigned int port;
 	bool enabled;
 };
 
@@ -138,7 +138,8 @@ static void del_evtchn(struct per_user_data *u, struct user_evtchn *evtchn)
 	kfree(evtchn);
 }
 
-static struct user_evtchn *find_evtchn(struct per_user_data *u, unsigned port)
+static struct user_evtchn *find_evtchn(struct per_user_data *u,
+				       unsigned int port)
 {
 	struct rb_node *node = u->evtchns.rb_node;
 
@@ -286,7 +287,7 @@ static ssize_t evtchn_write(struct file *file, const char __user *buf,
 	mutex_lock(&u->bind_mutex);
 
 	for (i = 0; i < (count/sizeof(evtchn_port_t)); i++) {
-		unsigned port = kbuf[i];
+		unsigned int port = kbuf[i];
 		struct user_evtchn *evtchn;
 
 		evtchn = find_evtchn(u, port);
drivers/xen/grant-table.c +6 -6
index 7b36b51cdb9f..7d9e8d90e139 100644
@@ -116,7 +116,7 @@ struct gnttab_ops {
 	 * status of the grant entry to be updated.
 	 */
 	void (*update_entry)(grant_ref_t ref, domid_t domid,
-			     unsigned long frame, unsigned flags);
+			     unsigned long frame, unsigned int flags);
 	/*
 	 * Stop granting a grant entry to domain for accessing. Ref parameter is
 	 * reference of a grant entry whose grant access will be stopped,
@@ -167,7 +167,7 @@ static inline grant_ref_t *__gnttab_entry(grant_ref_t entry)
 /* This can be used as an l-value */
 #define gnttab_entry(entry) (*__gnttab_entry(entry))
 
-static int get_free_entries(unsigned count)
+static int get_free_entries(unsigned int count)
 {
 	unsigned long flags;
 	int ref, rc = 0;
@@ -242,7 +242,7 @@ static void put_free_entry(grant_ref_t ref)
  *  4. Write ent->flags, inc. valid type.
  */
 static void gnttab_update_entry_v1(grant_ref_t ref, domid_t domid,
-				   unsigned long frame, unsigned flags)
+				   unsigned long frame, unsigned int flags)
 {
 	gnttab_shared.v1[ref].domid = domid;
 	gnttab_shared.v1[ref].frame = frame;
@@ -940,7 +940,7 @@ static inline void
 gnttab_retry_eagain_gop(unsigned int cmd, void *gop, int16_t *status,
 						const char *func)
 {
-	unsigned delay = 1;
+	unsigned int delay = 1;
 
 	do {
 		BUG_ON(HYPERVISOR_grant_table_op(cmd, gop, 1));
@@ -954,7 +954,7 @@ gnttab_retry_eagain_gop(unsigned int cmd, void *gop, int16_t *status,
 	}
 }
 
-void gnttab_batch_map(struct gnttab_map_grant_ref *batch, unsigned count)
+void gnttab_batch_map(struct gnttab_map_grant_ref *batch, unsigned int count)
 {
 	struct gnttab_map_grant_ref *op;
 
@@ -967,7 +967,7 @@ void gnttab_batch_map(struct gnttab_map_grant_ref *batch, unsigned count)
 }
 EXPORT_SYMBOL_GPL(gnttab_batch_map);
 
-void gnttab_batch_copy(struct gnttab_copy *batch, unsigned count)
+void gnttab_batch_copy(struct gnttab_copy *batch, unsigned int count)
 {
 	struct gnttab_copy *op;
 
drivers/xen/mcelog.c +3 -3
index e9ac3b8c4167..c0b3507054c7 100644
@@ -107,7 +107,7 @@ static ssize_t xen_mce_chrdev_read(struct file *filp, char __user *ubuf,
 				size_t usize, loff_t *off)
 {
 	char __user *buf = ubuf;
-	unsigned num;
+	unsigned int num;
 	int i, err;
 
 	mutex_lock(&mcelog_lock);
@@ -163,7 +163,7 @@ static long xen_mce_chrdev_ioctl(struct file *f, unsigned int cmd,
 	case MCE_GET_LOG_LEN:
 		return put_user(XEN_MCE_LOG_LEN, p);
 	case MCE_GETCLEAR_FLAGS: {
-		unsigned flags;
+		unsigned int flags;
 
 		do {
 			flags = xen_mcelog.flags;
@@ -196,7 +196,7 @@ static struct miscdevice xen_mce_chrdev_device = {
  */
 static void xen_mce_log(struct xen_mce *mce)
 {
-	unsigned entry;
+	unsigned int entry;
 
 	entry = xen_mcelog.next;
 
drivers/xen/privcmd.c +5 -5
index c6070e70dd73..52447ab70e6b 100644
@@ -107,10 +107,10 @@ static void free_page_list(struct list_head *pages)
  * error code; its up to the caller to dispose of any partial list.
  */
 static int gather_array(struct list_head *pagelist,
-			unsigned nelem, size_t size,
+			unsigned int nelem, size_t size,
 			const void __user *data)
 {
-	unsigned pageidx;
+	unsigned int pageidx;
 	void *pagedata;
 	int ret;
 
@@ -151,13 +151,13 @@ static int gather_array(struct list_head *pagelist,
  * Call function "fn" on each element of the array fragmented
  * over a list of pages.
  */
-static int traverse_pages(unsigned nelem, size_t size,
+static int traverse_pages(unsigned int nelem, size_t size,
 			  struct list_head *pos,
 			  int (*fn)(void *data, void *state),
 			  void *state)
 {
 	void *pagedata;
-	unsigned pageidx;
+	unsigned int pageidx;
 	int ret = 0;
 
 	BUG_ON(size > PAGE_SIZE);
@@ -187,7 +187,7 @@ static int traverse_pages(unsigned nelem, size_t size,
  * Similar to traverse_pages, but use each page as a "block" of
  * data to be processed as one unit.
  */
-static int traverse_pages_block(unsigned nelem, size_t size,
+static int traverse_pages_block(unsigned int nelem, size_t size,
 				struct list_head *pos,
 				int (*fn)(void *data, int nr, void *state),
 				void *state)
drivers/xen/xen-scsiback.c +4 -4
index ba0942e481bc..45c341063ba5 100644
@@ -327,7 +327,7 @@ static void scsiback_send_response(struct vscsibk_info *info,
 	int notify;
 	struct scsi_sense_hdr sshdr;
 	unsigned long flags;
-	unsigned len;
+	unsigned int len;
 
 	spin_lock_irqsave(&info->ring_lock, flags);
 
@@ -340,7 +340,7 @@ static void scsiback_send_response(struct vscsibk_info *info,
 	if (sense_buffer != NULL &&
 	    scsi_normalize_sense(sense_buffer, VSCSIIF_SENSE_BUFFERSIZE,
 				 &sshdr)) {
-		len = min_t(unsigned, 8 + sense_buffer[7],
+		len = min_t(unsigned int, 8 + sense_buffer[7],
 			    VSCSIIF_SENSE_BUFFERSIZE);
 		memcpy(ring_res->sense_buffer, sense_buffer, len);
 		ring_res->sense_len = len;
@@ -507,8 +507,8 @@ static int scsiback_gnttab_data_map(struct vscsiif_request *ring_req,
 		for (i = 0; i < nr_sgl; i++) {
 			n_segs = ring_req->seg[i].length /
 				 sizeof(struct scsiif_request_segment);
-			if ((unsigned)ring_req->seg[i].offset +
-			    (unsigned)ring_req->seg[i].length > PAGE_SIZE ||
+			if ((unsigned int)ring_req->seg[i].offset +
+			    (unsigned int)ring_req->seg[i].length > PAGE_SIZE ||
 			    n_segs * sizeof(struct scsiif_request_segment) !=
 			    ring_req->seg[i].length)
 				return -EINVAL;
drivers/xen/xenbus/xenbus_dev_frontend.c +5 -4
index 597af455a522..30402f02a90d 100644
@@ -128,7 +128,7 @@ static ssize_t xenbus_file_read(struct file *filp,
 {
 	struct xenbus_file_priv *u = filp->private_data;
 	struct read_buffer *rb;
-	unsigned i;
+	unsigned int i;
 	int ret;
 
 	mutex_lock(&u->reply_mutex);
@@ -148,7 +148,8 @@ static ssize_t xenbus_file_read(struct file *filp,
 	rb = list_entry(u->read_buffers.next, struct read_buffer, list);
 	i = 0;
 	while (i < len) {
-		unsigned sz = min((unsigned)len - i, rb->len - rb->cons);
+		unsigned int sz = min((unsigned int)len - i,
+				      rb->len - rb->cons);
 
 		ret = copy_to_user(ubuf + i, &rb->msg[rb->cons], sz);
 
@@ -443,7 +444,7 @@ static int xenbus_command_reply(struct xenbus_file_priv *u,
 	return rc;
 }
 
-static int xenbus_write_transaction(unsigned msg_type,
+static int xenbus_write_transaction(unsigned int msg_type,
 				    struct xenbus_file_priv *u)
 {
 	int rc;
@@ -493,7 +494,7 @@ static int xenbus_write_transaction(unsigned msg_type,
 	return rc;
 }
 
-static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u)
+static int xenbus_write_watch(unsigned int msg_type, struct xenbus_file_priv *u)
 {
 	struct watch_adapter *watch;
 	char *path, *token;
drivers/xen/xlate_mmu.c +2 -2
index 7b1077f0abcb..e6b5cd4e26aa 100644
@@ -45,7 +45,7 @@
 typedef void (*xen_gfn_fn_t)(unsigned long gfn, void *data);
 
 /* Break down the pages in 4KB chunk and call fn for each gfn */
-static void xen_for_each_gfn(struct page **pages, unsigned nr_gfn,
+static void xen_for_each_gfn(struct page **pages, unsigned int nr_gfn,
 			     xen_gfn_fn_t fn, void *data)
 {
 	unsigned long xen_pfn = 0;
@@ -144,7 +144,7 @@ int xen_xlate_remap_gfn_array(struct vm_area_struct *vma,
 			      unsigned long addr,
 			      xen_pfn_t *gfn, int nr,
 			      int *err_ptr, pgprot_t prot,
-			      unsigned domid,
+			      unsigned int domid,
 			      struct page **pages)
 {
 	int err;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · Yan Yankovskyi

Resolve the following warning, reported by checkpatch.pl:
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'

No functional change.

IMO a change like this would ideally go a little further and try to use the actually designated types when adjusting them anyway, e.g. ...

Quoted 11 lines
drivers/xen/events/events_2l.c +1 -1
@@ -42,48 +42,48 @@
 
 static DEFINE_PER_CPU(xen_ulong_t [EVTCHN_MASK_SIZE], cpu_evtchn_mask);
 
-static unsigned evtchn_2l_max_channels(void)
+static unsigned int evtchn_2l_max_channels(void)
 {
 	return EVTCHN_2L_NR_CHANNELS;
 }

drivers/xen/events/events_2l.c line 56

Quoted 10 lines
drivers/xen/events/events_2l.c +2 -2
 
-static void evtchn_2l_bind_to_cpu(struct irq_info *info, unsigned cpu)
+static void evtchn_2l_bind_to_cpu(struct irq_info *info, unsigned int cpu)
 {
 	clear_bit(info->evtchn, BM(per_cpu(cpu_evtchn_mask, info->cpu)));
 	set_bit(info->evtchn, BM(per_cpu(cpu_evtchn_mask, cpu)));
 }
 
-static void evtchn_2l_clear_pending(unsigned port)
+static void evtchn_2l_clear_pending(unsigned int port)

... evtchn_port_t here and elsewhere.

Jan

#2 lore raw
Quoted 1 line · Jan Beulich

... evtchn_port_t here and elsewhere.

There are some interfaces with signed int as a type for port, e.g. in include/xen/events.h.
Should I create additional patch to resolve inconsistency with evtchn interface?
Or you suggest combining these changes into the existing patch?

Also as I understand 'evtchn' and 'port' are essentially the same entities from perspective of local domain, related to each other roughly like connection
and file descriptor pair. What do you think about renaming all 'evtchn' arguments
and variables to 'port'? It will eliminate inconsistencies in the code, for example
in include/xen/interface/event_channel.h and include/xen/events.h.

Yan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
In reply to Jan Beulich
Quoted 1 line · On Mon, Mar 2, 2020 at 10:11 Jan Beulich wrote:

... evtchn_port_t here and elsewhere.

There are some interfaces with signed int as a type for port, e.g. in include/xen/events.h.
Should I create additional patch to resolve inconsistency with evtchn interface?
Or you suggest combining these changes into the existing patch?

Also as I understand 'evtchn' and 'port' are essentially the same entities from perspective of local domain, related to each other roughly like connection and file descriptor pair. What do you think about renaming all 'evtchn' arguments and variables to 'port'?
It will eliminate inconsistencies in the code, for example in include/xen/interface/event_channel.h and include/xen/events.h.

#4 lore raw
Quoted 8 lines · Yan Yankovskyi
Quoted 1 line · On Mon, Mar 2, 2020 at 10:11 Jan Beulich wrote:

... evtchn_port_t here and elsewhere.

There are some interfaces with signed int as a type for port, e.g. in include/xen/events.h.
Should I create additional patch to resolve inconsistency with evtchn interface?
Or you suggest combining these changes into the existing patch?

Signed <-> unsigned conversions would perhaps better go into a separate patch. But note I'm not the maintainer of this code.

Quoted 6 lines

Also as I understand 'evtchn' and 'port' are essentially the same entities from perspective of local domain, related to each other roughly like connection and file descriptor pair. What do you think about renaming all 'evtchn' arguments and variables to 'port'?
It will eliminate inconsistencies in the code, for example in include/xen/interface/event_channel.h and include/xen/events.h.

I'd welcome this, but the maintainers will have the final say.

Jan

#5 lore raw
Quoted 11 lines · Jan Beulich
Quoted 7 lines · Yan Yankovskyi
Quoted 1 line · On Mon, Mar 2, 2020 at 10:11 Jan Beulich wrote:

... evtchn_port_t here and elsewhere.

There are some interfaces with signed int as a type for port, e.g. in include/xen/events.h.
Should I create additional patch to resolve inconsistency with evtchn interface?
Or you suggest combining these changes into the existing patch?

Signed <-> unsigned conversions would perhaps better go into a separate patch. But note I'm not the maintainer of this code.

Quoted 7 lines
Quoted 6 lines

Also as I understand 'evtchn' and 'port' are essentially the same entities from perspective of local domain, related to each other roughly like connection and file descriptor pair. What do you think about renaming all 'evtchn' arguments and variables to 'port'?
It will eliminate inconsistencies in the code, for example in include/xen/interface/event_channel.h and include/xen/events.h.

I'd welcome this, but the maintainers will have the final say.

TBH I'd rather see the things that Jan pointed to fixed than replacing 'unsigned' with 'unsigned int.'

The latter is purely a kernel style requirement and is typically fixed when the line is modified (in fact, we did just that last week).

-boris