aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig.debug2
-rw-r--r--lib/Makefile2
-rw-r--r--lib/idr.c4
-rw-r--r--lib/kasprintf.c44
-rw-r--r--lib/kobject_uevent.c16
-rw-r--r--lib/lzo/lzo1x_compress.c6
-rw-r--r--lib/vsprintf.c35
7 files changed, 59 insertions, 50 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index f3e0c2abcbd0..50a94eee4d92 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -349,7 +349,7 @@ config DEBUG_HIGHMEM
349config DEBUG_BUGVERBOSE 349config DEBUG_BUGVERBOSE
350 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED 350 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED
351 depends on BUG 351 depends on BUG
352 depends on ARM || ARM26 || AVR32 || M32R || M68K || SPARC32 || SPARC64 || FRV || SUPERH || GENERIC_BUG || BFIN 352 depends on ARM || AVR32 || M32R || M68K || SPARC32 || SPARC64 || FRV || SUPERH || GENERIC_BUG || BFIN
353 default !EMBEDDED 353 default !EMBEDDED
354 help 354 help
355 Say Y here to make BUG() panics output the file name and line number 355 Say Y here to make BUG() panics output the file name and line number
diff --git a/lib/Makefile b/lib/Makefile
index 614966387402..d9e5f1cd0bfb 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -2,7 +2,7 @@
2# Makefile for some libs needed in the kernel. 2# Makefile for some libs needed in the kernel.
3# 3#
4 4
5lib-y := ctype.o string.o vsprintf.o cmdline.o \ 5lib-y := ctype.o string.o vsprintf.o kasprintf.o cmdline.o \
6 rbtree.o radix-tree.o dump_stack.o \ 6 rbtree.o radix-tree.o dump_stack.o \
7 idr.o int_sqrt.o bitmap.o extable.o prio_tree.o \ 7 idr.o int_sqrt.o bitmap.o extable.o prio_tree.o \
8 sha1.o irq_regs.o reciprocal_div.o argv_split.o 8 sha1.o irq_regs.o reciprocal_div.o argv_split.o
diff --git a/lib/idr.c b/lib/idr.c
index ffd61941e75d..d0f1acdbfa3a 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -405,7 +405,7 @@ EXPORT_SYMBOL(idr_remove);
405 */ 405 */
406void idr_remove_all(struct idr *idp) 406void idr_remove_all(struct idr *idp)
407{ 407{
408 int n, id, max, error = 0; 408 int n, id, max;
409 struct idr_layer *p; 409 struct idr_layer *p;
410 struct idr_layer *pa[MAX_LEVEL]; 410 struct idr_layer *pa[MAX_LEVEL];
411 struct idr_layer **paa = &pa[0]; 411 struct idr_layer **paa = &pa[0];
@@ -415,7 +415,7 @@ void idr_remove_all(struct idr *idp)
415 max = 1 << n; 415 max = 1 << n;
416 416
417 id = 0; 417 id = 0;
418 while (id < max && !error) { 418 while (id < max) {
419 while (n > IDR_BITS && p) { 419 while (n > IDR_BITS && p) {
420 n -= IDR_BITS; 420 n -= IDR_BITS;
421 *paa++ = p; 421 *paa++ = p;
diff --git a/lib/kasprintf.c b/lib/kasprintf.c
new file mode 100644
index 000000000000..c5ff1fd10030
--- /dev/null
+++ b/lib/kasprintf.c
@@ -0,0 +1,44 @@
1/*
2 * linux/lib/kasprintf.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7#include <stdarg.h>
8#include <linux/module.h>
9#include <linux/types.h>
10#include <linux/string.h>
11
12/* Simplified asprintf. */
13char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
14{
15 unsigned int len;
16 char *p;
17 va_list aq;
18
19 va_copy(aq, ap);
20 len = vsnprintf(NULL, 0, fmt, aq);
21 va_end(aq);
22
23 p = kmalloc(len+1, gfp);
24 if (!p)
25 return NULL;
26
27 vsnprintf(p, len+1, fmt, ap);
28
29 return p;
30}
31EXPORT_SYMBOL(kvasprintf);
32
33char *kasprintf(gfp_t gfp, const char *fmt, ...)
34{
35 va_list ap;
36 char *p;
37
38 va_start(ap, fmt);
39 p = kvasprintf(gfp, fmt, ap);
40 va_end(ap);
41
42 return p;
43}
44EXPORT_SYMBOL(kasprintf);
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 6a80c784a8fb..df02814699d7 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -25,14 +25,6 @@
25#define BUFFER_SIZE 2048 /* buffer for the variables */ 25#define BUFFER_SIZE 2048 /* buffer for the variables */
26#define NUM_ENVP 32 /* number of env pointers */ 26#define NUM_ENVP 32 /* number of env pointers */
27 27
28#if defined(CONFIG_HOTPLUG)
29u64 uevent_seqnum;
30char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug";
31static DEFINE_SPINLOCK(sequence_lock);
32#if defined(CONFIG_NET)
33static struct sock *uevent_sock;
34#endif
35
36/* the strings here must match the enum in include/linux/kobject.h */ 28/* the strings here must match the enum in include/linux/kobject.h */
37const char *kobject_actions[] = { 29const char *kobject_actions[] = {
38 "add", 30 "add",
@@ -43,6 +35,14 @@ const char *kobject_actions[] = {
43 "offline", 35 "offline",
44}; 36};
45 37
38#if defined(CONFIG_HOTPLUG)
39u64 uevent_seqnum;
40char uevent_helper[UEVENT_HELPER_PATH_LEN] = "/sbin/hotplug";
41static DEFINE_SPINLOCK(sequence_lock);
42#if defined(CONFIG_NET)
43static struct sock *uevent_sock;
44#endif
45
46/** 46/**
47 * kobject_uevent_env - send an uevent with environmental data 47 * kobject_uevent_env - send an uevent with environmental data
48 * 48 *
diff --git a/lib/lzo/lzo1x_compress.c b/lib/lzo/lzo1x_compress.c
index c935f00073e9..a6040990a62e 100644
--- a/lib/lzo/lzo1x_compress.c
+++ b/lib/lzo/lzo1x_compress.c
@@ -32,13 +32,13 @@ _lzo1x_1_do_compress(const unsigned char *in, size_t in_len,
32 ip += 4; 32 ip += 4;
33 33
34 for (;;) { 34 for (;;) {
35 dindex = ((0x21 * DX3(ip, 5, 5, 6)) >> 5) & D_MASK; 35 dindex = ((size_t)(0x21 * DX3(ip, 5, 5, 6)) >> 5) & D_MASK;
36 m_pos = dict[dindex]; 36 m_pos = dict[dindex];
37 37
38 if (m_pos < in) 38 if (m_pos < in)
39 goto literal; 39 goto literal;
40 40
41 if (ip == m_pos || (ip - m_pos) > M4_MAX_OFFSET) 41 if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
42 goto literal; 42 goto literal;
43 43
44 m_off = ip - m_pos; 44 m_off = ip - m_pos;
@@ -51,7 +51,7 @@ _lzo1x_1_do_compress(const unsigned char *in, size_t in_len,
51 if (m_pos < in) 51 if (m_pos < in)
52 goto literal; 52 goto literal;
53 53
54 if (ip == m_pos || (ip - m_pos) > M4_MAX_OFFSET) 54 if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
55 goto literal; 55 goto literal;
56 56
57 m_off = ip - m_pos; 57 m_off = ip - m_pos;
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 6b6734df6d2d..7b481cea54ae 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -978,38 +978,3 @@ int sscanf(const char * buf, const char * fmt, ...)
978} 978}
979 979
980EXPORT_SYMBOL(sscanf); 980EXPORT_SYMBOL(sscanf);
981
982
983/* Simplified asprintf. */
984char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
985{
986 unsigned int len;
987 char *p;
988 va_list aq;
989
990 va_copy(aq, ap);
991 len = vsnprintf(NULL, 0, fmt, aq);
992 va_end(aq);
993
994 p = kmalloc(len+1, gfp);
995 if (!p)
996 return NULL;
997
998 vsnprintf(p, len+1, fmt, ap);
999
1000 return p;
1001}
1002EXPORT_SYMBOL(kvasprintf);
1003
1004char *kasprintf(gfp_t gfp, const char *fmt, ...)
1005{
1006 va_list ap;
1007 char *p;
1008
1009 va_start(ap, fmt);
1010 p = kvasprintf(gfp, fmt, ap);
1011 va_end(ap);
1012
1013 return p;
1014}
1015EXPORT_SYMBOL(kasprintf);