The following commit has been merged in the master branch: commit 4fab6a00f5a44ee5ca30e556575d8c707a9b7e61 Author: simon simon@45894c77-fb22-0410-b583-ff6e7d5dbf6c Date: Sat Oct 17 17:56:02 2009 +0000
enable pre2.6.25 kernels again by adding compatibility for strict_strto[u]l()
git-svn-id: http://downloads.open-mesh.net/svn/batman/trunk/batman-adv-kernelland@1447 45894c77-fb22-0410-b583-ff6e7d5dbf6c
diff --git a/compat.h b/compat.h index 2f0877c..cd3e71f 100644 --- a/compat.h +++ b/compat.h @@ -60,3 +60,14 @@ #define cancel_delayed_work_sync(wq) cancel_rearming_delayed_work(wq)
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23) */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) +#define strict_strtoul(cp, base, res) \ + ({ \ + int ret = 0; \ + char *endp; \ + *res = simple_strtoul(cp, &endp, base); \ + if (cp == endp) \ + ret = -EINVAL; \ + ret; \ +}) +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) */ diff --git a/proc.c b/proc.c index 8718079..7677de0 100644 --- a/proc.c +++ b/proc.c @@ -26,6 +26,7 @@ #include "types.h" #include "hash.h" #include "vis.h" +#include "compat.h"
uint8_t vis_format = DOT_DRAW;
@@ -146,7 +147,7 @@ static ssize_t proc_orig_interval_write(struct file *file, { char *interval_string; int not_copied = 0; - long originator_interval_tmp; + unsigned long originator_interval_tmp; int retval;
interval_string = kmalloc(count, GFP_KERNEL); @@ -157,7 +158,7 @@ static ssize_t proc_orig_interval_write(struct file *file, not_copied = copy_from_user(interval_string, buffer, count); interval_string[count - not_copied - 1] = 0;
- retval = strict_strtol(interval_string, 10, &originator_interval_tmp); + retval = strict_strtoul(interval_string, 10, &originator_interval_tmp); if (retval) { debug_log(LOG_TYPE_WARN, "New originator interval invalid\n"); goto end; @@ -290,7 +291,7 @@ static ssize_t proc_log_level_write(struct file *instance, { char *log_level_string, *tokptr, *cp; int finished, not_copied = 0; - uint8_t log_level_tmp = 0; + unsigned long log_level_tmp = 0;
log_level_string = kmalloc(count, GFP_KERNEL);
@@ -300,10 +301,8 @@ static ssize_t proc_log_level_write(struct file *instance, not_copied = copy_from_user(log_level_string, userbuffer, count); log_level_string[count - not_copied - 1] = 0;
- log_level_tmp = simple_strtol(log_level_string, &cp, 10); - - if (cp == log_level_string) { - /* was not (beginning with) a number, doing textual parsing */ + if (strict_strtoul(log_level_string, 10, &log_level_tmp) < 0) { + /* was not a number, doing textual parsing */ log_level_tmp = 0; tokptr = log_level_string;
@@ -663,7 +662,7 @@ static ssize_t proc_aggr_write(struct file *file, const char __user *buffer, { char *aggr_string; int not_copied = 0; - long aggregation_enabled_tmp; + unsigned long aggregation_enabled_tmp;
aggr_string = kmalloc(count, GFP_KERNEL);
@@ -673,7 +672,7 @@ static ssize_t proc_aggr_write(struct file *file, const char __user *buffer, not_copied = copy_from_user(aggr_string, buffer, count); aggr_string[count - not_copied - 1] = 0;
- strict_strtol(aggr_string, 10, &aggregation_enabled_tmp); + strict_strtoul(aggr_string, 10, &aggregation_enabled_tmp);
if ((aggregation_enabled_tmp != 0) && (aggregation_enabled_tmp != 1)) { debug_log(LOG_TYPE_WARN, "Aggregation can only be enabled (1) or disabled (0), given value: %li\n", aggregation_enabled_tmp);