aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@shadowen.org>2008-10-16 01:02:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:21:36 -0400
commit0776e594606e32a045e0a99bb919b2280b945495 (patch)
treeda5cb9f363484fcf343c72b7b48ada5191b97cf0 /scripts/checkpatch.pl
parent5fdd23acf9cd7f658746b119436ed1d787326c46 (diff)
checkpatch: do is not a possible type
A do without braces '{' may trigger a false possible type 'do' and then this may be interpreted as an external definition of foo(): do foo(); while (bar); Add do to the type exclusions. Fix up tests so we can check for them. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl24
1 files changed, 18 insertions, 6 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 118fe1f30e76..6b21188d2cf7 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -913,12 +913,22 @@ sub annotate_values {
913sub possible { 913sub possible {
914 my ($possible, $line) = @_; 914 my ($possible, $line) = @_;
915 915
916 print "CHECK<$possible> ($line)\n" if ($dbg_possible > 1); 916 print "CHECK<$possible> ($line)\n" if ($dbg_possible > 2);
917 if ($possible !~ /^(?:$Modifier|$Storage|$Type|DEFINE_\S+)$/ && 917 if ($possible !~ /(?:
918 $possible ne 'goto' && $possible ne 'return' && 918 ^(?:
919 $possible ne 'case' && $possible ne 'else' && 919 $Modifier|
920 $possible ne 'asm' && $possible ne '__asm__' && 920 $Storage|
921 $possible !~ /^(typedef|struct|enum)\b/) { 921 $Type|
922 DEFINE_\S+|
923 goto|
924 return|
925 case|
926 else|
927 asm|__asm__|
928 do
929 )$|
930 ^(?:typedef|struct|enum)\b
931 )/x) {
922 # Check for modifiers. 932 # Check for modifiers.
923 $possible =~ s/\s*$Storage\s*//g; 933 $possible =~ s/\s*$Storage\s*//g;
924 $possible =~ s/\s*$Sparse\s*//g; 934 $possible =~ s/\s*$Sparse\s*//g;
@@ -936,6 +946,8 @@ sub possible {
936 push(@typeList, $possible); 946 push(@typeList, $possible);
937 } 947 }
938 build_types(); 948 build_types();
949 } else {
950 warn "NOTPOSS: $possible ($line)\n" if ($dbg_possible > 1);
939 } 951 }
940} 952}
941 953






                                                                      


                              


                         




                     

                                                                   





































                                                                              

                                                   
 
                                                 








































                                                                           
/*
 * Create default crypto algorithm instances.
 *
 * Copyright (c) 2006 Herbert Xu <herbert@gondor.apana.org.au>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 */

#include <linux/crypto.h>
#include <linux/ctype.h>
#include <linux/err.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/notifier.h>
#include <linux/rtnetlink.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/workqueue.h>

#include "internal.h"

struct cryptomgr_param {
	struct work_struct work;

	struct {
		struct rtattr attr;
		struct crypto_attr_alg data;
	} alg;

	struct {
		u32 type;
		u32 mask;
		char name[CRYPTO_MAX_ALG_NAME];
	} larval;

	char template[CRYPTO_MAX_ALG_NAME];
};

static void cryptomgr_probe(struct work_struct *work)
{
	struct cryptomgr_param *param =
		container_of(work, struct cryptomgr_param, work);
	struct crypto_template *tmpl;
	struct crypto_instance *inst;
	int err;

	tmpl = crypto_lookup_template(param->template);
	if (!tmpl)
		goto err;

	do {
		inst = tmpl->alloc(&param->alg, sizeof(param->alg));
		if (IS_ERR(inst))
			err = PTR_ERR(inst);
		else if ((err = crypto_register_instance(tmpl, inst)))
			tmpl->free(inst);
	} while (err == -EAGAIN && !signal_pending(current));

	crypto_tmpl_put(tmpl);

	if (err)
		goto err;

out:
	kfree(param);
	return;

err:
	crypto_larval_error(param->larval.name, param->larval.type,
			    param->larval.mask);
	goto out;
}

static int cryptomgr_schedule_probe(struct crypto_larval *larval)
{
	struct cryptomgr_param *param;
	const char *name = larval->alg.cra_name;
	const char *p;
	unsigned int len;

	param = kmalloc(sizeof(*param), GFP_KERNEL);
	if (!param)
		goto err;

	for (p = name; isalnum(*p) || *p == '-' || *p == '_'; p++)
		;

	len = p - name;
	if (!len || *p != '(')
		goto err_free_param;

	memcpy(param->template, name, len);
	param->template[len] = 0;

	name = p + 1;
	for (p = name; isalnum(*p) || *p == '-' || *p == '_'; p++)
		;

	len = p - name;
	if (!len || *p != ')' || p[1])
		goto err_free_param;

	param->alg.attr.rta_len = sizeof(param->alg);
	param->alg.attr.rta_type = CRYPTOA_ALG;
	memcpy(param->alg.data.name, name, len);
	param->alg.data.name[len] = 0;

	memcpy(param->larval.name, larval->alg.cra_name, CRYPTO_MAX_ALG_NAME);
	param->larval.type = larval->alg.cra_flags;
	param->larval.mask = larval->mask;

	INIT_WORK(&param->work, cryptomgr_probe);
	schedule_work(&param->work);

	return NOTIFY_STOP;

err_free_param:
	kfree(param);
err:
	return NOTIFY_OK;
}

static int cryptomgr_notify(struct notifier_block *this, unsigned long msg,
			    void *data)
{
	switch (msg) {
	case CRYPTO_MSG_ALG_REQUEST:
		return cryptomgr_schedule_probe(data);
	}

	return NOTIFY_DONE;
}

static struct notifier_block cryptomgr_notifier = {
	.notifier_call = cryptomgr_notify,
};

static int __init cryptomgr_init(void)
{
	return crypto_register_notifier(&cryptomgr_notifier);
}

static void __exit cryptomgr_exit(void)
{
	int err = crypto_unregister_notifier(&cryptomgr_notifier);
	BUG_ON(err);
}

module_init(cryptomgr_init);
module_exit(cryptomgr_exit);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Crypto Algorithm Manager");