1

尝试编译Android内核时出现以下错误,我不确定如何更改代码的这部分解决错误。Android内核编译错误 - 从类型'kuid_t'分配类型'uid_t'时的不兼容类型

CC  net/netfilter/xt_IDLETIMER.o 
net/netfilter/xt_IDLETIMER.c: In function ‘reset_timer’: 
net/netfilter/xt_IDLETIMER.c:360:16: error: incompatible types when assigning to type ‘uid_t’ from type ‘kuid_t’ 
    timer->uid = sk->sk_socket->file->f_cred->uid; 
       ^
scripts/Makefile.build:257: recipe for target 'net/netfilter/xt_IDLETIMER.o' failed 
make[2]: *** [net/netfilter/xt_IDLETIMER.o] Error 1 
scripts/Makefile.build:402: recipe for target 'net/netfilter' failed 
make[1]: *** [net/netfilter] Error 2 
Makefile:937: recipe for target 'net' failed 
make: *** [net] Error 2 

我正在使用来自https://android.googlesource.com/kernel/common.git/+/android-3.18的3.18内核。 我使用make menuconfig生成了一个默认的.config,然后我合并了Android基础和android/configs文件夹中包含的推荐配置。在做一个make bzImage时,我得到了上面的错误。

我建立在运行Ubuntu 14.10和gcc 4.9.1的ARM机器上(用于ARM)。

封闭函数的代码是:

static void reset_timer(const struct idletimer_tg_info *info, 
         struct sk_buff *skb) 
{ 
     unsigned long now = jiffies; 
     struct idletimer_tg *timer = info->timer; 
     bool timer_prev; 

     spin_lock_bh(&timestamp_lock); 
     timer_prev = timer->active; 
     timer->active = true; 
     /* timer_prev is used to guard overflow problem in time_before*/ 
     if (!timer_prev || time_before(timer->timer.expires, now)) { 
       pr_debug("Starting Checkentry timer (Expired, Jiffies): %lu, %lu\n", 
           timer->timer.expires, now); 

       /* Stores the uid resposible for waking up the radio */ 
       if (skb && (skb->sk)) { 
         struct sock *sk = skb->sk; 
         read_lock_bh(&sk->sk_callback_lock); 
         if ((sk->sk_socket) && (sk->sk_socket->file) && 
        (sk->sk_socket->file->f_cred)) 
           timer->uid = sk->sk_socket->file->f_cred->uid; 
         read_unlock_bh(&sk->sk_callback_lock); 
       } 

       /* checks if there is a pending inactive notification*/ 
       if (timer->work_pending) 
         timer->delayed_timer_trigger = timer->last_modified_timer; 
       else { 
         timer->work_pending = true; 
         schedule_work(&timer->work); 
       } 
     } 

     get_monotonic_boottime(&timer->last_modified_timer); 
     mod_timer(&timer->timer, 
         msecs_to_jiffies(info->timeout * 1000) + now); 
     spin_unlock_bh(&timestamp_lock); 
} 

回答

2

我认为有以下功能将帮助您:

static inline uid_t __kuid_val(kuid_t uid) 
{ 
     return uid.val; 
} 

可以在include/linux/uidgid.h

+0

该诀窍找到它。谢谢! – pilcrowpipe

+0

你做了什么确切的改变? –