Android内核编译错误-从类型 ‘uid_t’分配给类型 ‘kuid_t’时类型不兼容

标签 android compiler-errors linux-kernel android-source android-kernel

我在尝试编译 Android 内核时遇到以下错误,我不确定如何更改这部分代码来解决错误。

  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);
}

最佳答案

我认为以下功能可以帮助您:

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

你可以在include/linux/uidgid.h中找到它

关于Android内核编译错误-从类型 ‘uid_t’分配给类型 ‘kuid_t’时类型不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30143654/

相关文章:

java - Android 上 java.awt.image.BufferedImage 的 ClassNotFoundException

c++ - 重载比较运算符 == C++

c++ - 构造函数无法重新声明。为什么?

linux - 如何统计ARM程序执行的指令数?

linux - 在 Linux 系统上,除了使用 "cgroups"之外,还有什么方法可以限制正在运行的进程的内存使用量吗?

linux-kernel - linux cdc_ecm 驱动程序与 rndis 驱动程序

java - Android:正确关闭线程和Looper?

java - 如何查看Android Studio的内嵌JDK版本?

file - 处理时output.println()中的错误

android 前向声明在 1.6 中不起作用