1. 07 8月, 2014 2 次提交
    • J
      checkpatch: warn on unnecessary else after return or break · 032a4c0f
      Joe Perches 提交于
      Using an else following a break or return can unnecessarily indent code
      blocks.
      
      ie:
      	for (i = 0; i < 100; i++) {
      		int foo = bar();
      		if (foo < 1)
      			break;
      		else
      			usleep(1);
      	}
      
      is generally better written as:
      
      	for (i = 0; i < 100; i++) {
      		int foo = bar();
      		if (foo < 1)
      			break;
      		usleep(1);
      	}
      
      Warn when a bare else statement is preceded by a break or return
      indented 1 tab more than the else.
      Signed-off-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      032a4c0f
    • J
      checkpatch: attempt to find unnecessary 'out of memory' messages · ebfdc409
      Joe Perches 提交于
      Logging messages that show some type of "out of memory" error are
      generally unnecessary as there is a generic message and a stack dump
      done by the memory subsystem.
      
      These messages generally increase kernel size without much added value.
      
      Emit a warning on these types of messages.
      
      This test looks for any inserted message function, then looks at the
      previous line for an "if (!foo)" or "if (foo == NULL)" test and then
      looks at the preceding statement for an allocation function like "foo =
      kmalloc()"
      
      ie: this code matches:
      
      	foo = kmalloc();
      	if (foo == NULL) {
      		printk("Out of memory\n");
      		return -ENOMEM;
      	}
      
      This test is very crude and incomplete.
      
      This test can miss quite a lot of of OOM messages that do not have this
      specific form.
      
      ie: this code does not match:
      
      	foo = kmalloc();
      	if (!foo) {
      		rtn = -ENOMEM;
      		printk("Out of memory!\n");
      		goto out;
      	}
      
      This test could also be a false positive when the logging message itself
      does not specify anything about memory, but I did not find any false
      positives in my limited testing.
      
      spatch could be a better solution but correctness seems non-trivial for
      that tool too.
      Signed-off-by: NJoe Perches <joe@perches.com>
      Acked-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      ebfdc409
  2. 24 6月, 2014 1 次提交
  3. 05 6月, 2014 9 次提交
  4. 04 4月, 2014 22 次提交
  5. 11 2月, 2014 1 次提交
  6. 28 1月, 2014 1 次提交
  7. 24 1月, 2014 4 次提交