linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* arch/s390/lib/uaccess_pt.c: Missing breaks: ?
@ 2013-04-14  6:06 Joe Perches
  2013-04-15  5:48 ` Heiko Carstens
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2013-04-14  6:06 UTC (permalink / raw)
  To: Heiko Carstens; +Cc: Martin Schwidefsky, linux-s390, LKML

Hello Heiko.

Commit ea81531d ("s390/uaccess: fix page table walk")
added this code.  It looks like it should have break;
for each case.

------------

static unsigned long follow_table(struct mm_struct *mm,
				  unsigned long address, int write)
{
	unsigned long *table = (unsigned long *)__pa(mm->pgd);

	switch (mm->context.asce_bits & _ASCE_TYPE_MASK) {
	case _ASCE_TYPE_REGION1:
		table = table + ((address >> 53) & 0x7ff);
		if (unlikely(*table & _REGION_ENTRY_INV))
			return -0x39UL;
		table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN);
	case _ASCE_TYPE_REGION2:
		table = table + ((address >> 42) & 0x7ff);
		if (unlikely(*table & _REGION_ENTRY_INV))
			return -0x3aUL;
		table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN);
	case _ASCE_TYPE_REGION3:
		table = table + ((address >> 31) & 0x7ff);
		if (unlikely(*table & _REGION_ENTRY_INV))
			return -0x3bUL;
		table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN);
	case _ASCE_TYPE_SEGMENT:
		table = table + ((address >> 20) & 0x7ff);
		if (unlikely(*table & _SEGMENT_ENTRY_INV))
			return -0x10UL;
		if (unlikely(*table & _SEGMENT_ENTRY_LARGE)) {
			if (write && (*table & _SEGMENT_ENTRY_RO))
				return -0x04UL;
			return (*table & _SEGMENT_ENTRY_ORIGIN_LARGE) +
				(address & ~_SEGMENT_ENTRY_ORIGIN_LARGE);
		}
		table = (unsigned long *)(*table & _SEGMENT_ENTRY_ORIGIN);
	}



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: arch/s390/lib/uaccess_pt.c: Missing breaks: ?
  2013-04-14  6:06 arch/s390/lib/uaccess_pt.c: Missing breaks: ? Joe Perches
@ 2013-04-15  5:48 ` Heiko Carstens
  2013-04-15  5:53   ` Joe Perches
  0 siblings, 1 reply; 5+ messages in thread
From: Heiko Carstens @ 2013-04-15  5:48 UTC (permalink / raw)
  To: Joe Perches; +Cc: Martin Schwidefsky, linux-s390, LKML

On Sat, Apr 13, 2013 at 11:06:14PM -0700, Joe Perches wrote:
> Hello Heiko.
> 
> Commit ea81531d ("s390/uaccess: fix page table walk")
> added this code.  It looks like it should have break;
> for each case.

Hi Joe,

no, the fallthrough is on purpose for each case statement.

> static unsigned long follow_table(struct mm_struct *mm,
> 				  unsigned long address, int write)
> {
> 	unsigned long *table = (unsigned long *)__pa(mm->pgd);
> 
> 	switch (mm->context.asce_bits & _ASCE_TYPE_MASK) {
> 	case _ASCE_TYPE_REGION1:
> 		table = table + ((address >> 53) & 0x7ff);
> 		if (unlikely(*table & _REGION_ENTRY_INV))
> 			return -0x39UL;
> 		table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN);
> 	case _ASCE_TYPE_REGION2:


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: arch/s390/lib/uaccess_pt.c: Missing breaks: ?
  2013-04-15  5:48 ` Heiko Carstens
@ 2013-04-15  5:53   ` Joe Perches
  2013-04-15  5:58     ` Heiko Carstens
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Perches @ 2013-04-15  5:53 UTC (permalink / raw)
  To: Heiko Carstens; +Cc: Martin Schwidefsky, linux-s390, LKML

On Mon, 2013-04-15 at 07:48 +0200, Heiko Carstens wrote:
> On Sat, Apr 13, 2013 at 11:06:14PM -0700, Joe Perches wrote:
> > Commit ea81531d ("s390/uaccess: fix page table walk")
> > added this code.  It looks like it should have break;
> > for each case.
> no, the fallthrough is on purpose for each case statement.

Hi again.  It might be useful to add /* fallthrough */
or some other comment showing it's intentional.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: arch/s390/lib/uaccess_pt.c: Missing breaks: ?
  2013-04-15  5:53   ` Joe Perches
@ 2013-04-15  5:58     ` Heiko Carstens
  2013-04-15  6:15       ` Joe Perches
  0 siblings, 1 reply; 5+ messages in thread
From: Heiko Carstens @ 2013-04-15  5:58 UTC (permalink / raw)
  To: Joe Perches; +Cc: Martin Schwidefsky, linux-s390, LKML

On Sun, Apr 14, 2013 at 10:53:27PM -0700, Joe Perches wrote:
> On Mon, 2013-04-15 at 07:48 +0200, Heiko Carstens wrote:
> > On Sat, Apr 13, 2013 at 11:06:14PM -0700, Joe Perches wrote:
> > > Commit ea81531d ("s390/uaccess: fix page table walk")
> > > added this code.  It looks like it should have break;
> > > for each case.
> > no, the fallthrough is on purpose for each case statement.
> 
> Hi again.  It might be useful to add /* fallthrough */
> or some other comment showing it's intentional.

I might add some comment above the function, since for everybody
*knowing* the architecture it's obvious ;) that these must be
fallthroughs.
How did you stuble across this?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: arch/s390/lib/uaccess_pt.c: Missing breaks: ?
  2013-04-15  5:58     ` Heiko Carstens
@ 2013-04-15  6:15       ` Joe Perches
  0 siblings, 0 replies; 5+ messages in thread
From: Joe Perches @ 2013-04-15  6:15 UTC (permalink / raw)
  To: Heiko Carstens; +Cc: Martin Schwidefsky, linux-s390, LKML

On Mon, 2013-04-15 at 07:58 +0200, Heiko Carstens wrote:
> On Sun, Apr 14, 2013 at 10:53:27PM -0700, Joe Perches wrote:
> > On Mon, 2013-04-15 at 07:48 +0200, Heiko Carstens wrote:
> > > On Sat, Apr 13, 2013 at 11:06:14PM -0700, Joe Perches wrote:
> > > > Commit ea81531d ("s390/uaccess: fix page table walk")
> > > > added this code.  It looks like it should have break;
> > > > for each case.
> > > no, the fallthrough is on purpose for each case statement.
> > 
> > Hi again.  It might be useful to add /* fallthrough */
> > or some other comment showing it's intentional.
> 
> I might add some comment above the function, since for everybody
> *knowing* the architecture it's obvious ;) that these must be
> fallthroughs.
> How did you stuble across this?

Tony Prisk sent an patch about a duplicated set of
a variable in a switch/case without a break and I
generalized it and found this and another one in
arch/arm. (the arm one was a real defect)

This one looked like it could be intentional (or not),
but I thought I'd ask.

$ grep-2.5.4 -rP --include=*.[ch] "\b(\w+)\s*=[^;]+;\s*(?:case\s+\w+:|default:)\s*\1\s*=" *



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-04-15  6:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-14  6:06 arch/s390/lib/uaccess_pt.c: Missing breaks: ? Joe Perches
2013-04-15  5:48 ` Heiko Carstens
2013-04-15  5:53   ` Joe Perches
2013-04-15  5:58     ` Heiko Carstens
2013-04-15  6:15       ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).