Linux内核错误

Linux内核错误,linux,linux-kernel,kernel,Linux,Linux Kernel,Kernel,我在这些行上也有同样的错误 error: lvalue required as left operand of assignment line 49: for (current = root; current != NULL; ptr = current) { line 50: current =current->link[res]; line 75: for (current = bf; current != newnode; res = link_dir[++i]) {

我在这些行上也有同样的错误

error: lvalue required as left operand of assignment

line 49:  for (current = root; current != NULL; ptr = current) {

line 50:  current =current->link[res];

line 75:  for (current = bf; current != newnode; res = link_dir[++i]) {

line 80:  current = current->link[res];

line 167: current = root;

line 192: current = current->link[res];
我怎样才能解决这个问题

我使用的是内核版本2.6.32-24-generic

这是我的函数之一,以上四个错误都来自于这个函数。。。 它是AVL树的一个插入函数

static void insertion (char value[]) {
        struct AVLTree_Node *bf, *parent_bf, *subtree, *temp;
        struct AVLTree_Node *current, *parent, *newnode, *ptr;
        int res = 0,i=0 ,num=100, compareLimit = 100; 
        char link_dir[32];

        if (!root) {
                root = createNode(value);
                return;
        }

        bf = parent_bf;
        parent_bf = root;
        // find the location for inserting the new node
        for (current = root; current != NULL; ptr = current) {
             current =current->link[res];
                num = strcmp(value,current->data);
                if (num == 0) {
                        printk(KERN_INFO "Cannot insert duplicates!!\n");
                        return;
                }
                int result = strncmp(value,current->data, compareLimit);
                if(result > 0) 
                        res = 1;  
                else if(result <= 0) 
                        res =0;
                parent = current;

                if (current->bfactor != 0) {
                        bf = current;
                        parent_bf = ptr;
                        i = 0;
                }
                link_dir[i++] = res;
        }
        // create the new node 
        newnode = createNode(value);
        parent->link[res] = newnode;
        res = link_dir[i = 0];
        // updating the height balance after insertion 
        for (current = bf; current != newnode; res = link_dir[++i]) {
                if (res == 0)
                        current->bfactor--;
                else
                        current->bfactor++;
                current = current->link[res];
        }

        // right sub-tree 
        if (bf->bfactor == 2) {
                printk(KERN_INFO "bfactor = 2\n");
                temp = bf->link[1];
                if (temp->bfactor == 1) {                   
                        subtree = temp;
                        bf->link[1] = temp->link[0];
                        temp->link[0] = bf;
                        temp->bfactor = bf->bfactor = 0;
                } else {
                        subtree = temp->link[0];
                        temp->link[0] = subtree->link[1];
                        subtree->link[1] = temp;
                        bf->link[1] = subtree->link[0];
                        subtree->link[0] = bf;
                        // update balance factors 
                        if (subtree->bfactor == -1) {
                                bf->bfactor = 0;
                                temp->bfactor = 1;
                        } else if (subtree->bfactor == 0) {
                                bf->bfactor = 0;
                                temp->bfactor = 0;
                        } else if (subtree->bfactor == 1) {
                                bf->bfactor = -1;
                                temp->bfactor = 0;
                        }
                        subtree->bfactor = 0;
                }
        // left sub-tree 
        } else if (bf->bfactor == -2) {
                temp = bf->link[0];
                if (temp->bfactor == -1) {

                         // single rotation(SR) right

                        subtree = temp;
                        bf->link[0] = temp->link[1];
                        temp->link[1] = bf;
                        temp->bfactor = bf->bfactor = 0;
                } else {
                        // double rotation - (SR left + SR right)

                        subtree = temp->link[1];
                        temp->link[1] = subtree->link[0];
                        subtree->link[0] = temp;
                        bf->link[0] = subtree->link[1];
                        subtree->link[1] = bf;
                        // update balance factors 
                        if (subtree->bfactor == -1) {
                                bf->bfactor = 1;
                                temp->bfactor = 0;
                        } else if (subtree->bfactor == 0) {
                                bf->bfactor = 0;
                                temp->bfactor = 0;
                        } else if (subtree->bfactor == 1) {
                                bf->bfactor = 0;
                                temp->bfactor = -1;
                        }
                        subtree->bfactor = 0;
                }
        } else {
                return;
        }

        if (bf == root) {
                root = subtree;
                return;
        }
        if (bf != parent_bf->link[0]) {
                parent_bf->link[1] = subtree;
        } else {
                parent_bf->link[0] = subtree;
        }
        return;
}
静态空白插入(字符值[]){
结构AVLTree_节点*bf、*父节点*bf、*子树、*temp;
结构AVLTree_Node*current、*parent、*newnode、*ptr;
int res=0,i=0,num=100,compareLimit=100;
char link_dir[32];
如果(!root){
root=createNode(值);
返回;
}
bf=父项_bf;
父项_bf=根;
//查找插入新节点的位置
for(当前=根;当前!=NULL;ptr=当前){
当前=当前->链接[res];
num=strcmp(值,当前->数据);
如果(num==0){
printk(KERN_INFO“无法插入重复项!!\n”);
返回;
}
int result=strncmp(值,当前->数据,比较限制);
如果(结果>0)
res=1;
else if(结果bfactor!=0){
bf=电流;
父项_bf=ptr;
i=0;
}
link_dir[i++]=res;
}
//创建新节点
newnode=createNode(值);
父->链接[res]=newnode;
res=link_dir[i=0];
//插入后更新高度平衡
for(current=bf;current!=newnode;res=link\u dir[++i]){
如果(res==0)
当前->bfactor--;
其他的
当前->bfactor++;
当前=当前->链接[res];
}
//右子树
如果(bf->bfactor==2){
printk(KERN_INFO“bfactor=2\n”);
temp=bf->link[1];
如果(temp->bfactor==1){
子树=温度;
bf->link[1]=temp->link[0];
温度->链接[0]=bf;
温度->bfactor=bf->bfactor=0;
}否则{
子树=临时->链接[0];
临时->链接[0]=子树->链接[1];
子树->链接[1]=temp;
bf->链接[1]=子树->链接[0];
子树->链接[0]=bf;
//更新平衡系数
if(子树->bfactor==-1){
bf->bfactor=0;
温度->系数=1;
}else if(子树->bfactor==0){
bf->bfactor=0;
温度->系数=0;
}else if(子树->bfactor==1){
bf->bfactor=-1;
温度->系数=0;
}
子树->bfactor=0;
}
//左子树
}否则如果(bf->bfactor==-2){
temp=bf->link[0];
如果(临时->bfactor==-1){
//单旋转(SR)右
子树=温度;
bf->link[0]=temp->link[1];
温度->链接[1]=bf;
温度->bfactor=bf->bfactor=0;
}否则{
//双旋转-(SR左+SR右)
子树=临时->链接[1];
临时->链接[1]=子树->链接[0];
子树->链接[0]=temp;
bf->link[0]=子树->链接[1];
子树->链接[1]=bf;
//更新平衡系数
if(子树->bfactor==-1){
bf->bfactor=1;
温度->系数=0;
}else if(子树->bfactor==0){
bf->bfactor=0;
温度->系数=0;
}else if(子树->bfactor==1){
bf->bfactor=0;
温度->bfactor=-1;
}
子树->bfactor=0;
}
}否则{
返回;
}
if(bf==根){
根=子树;
返回;
}
如果(bf!=父项\u bf->链接[0]){
父树->链接[1]=子树;
}否则{
父树->链接[0]=子树;
}
返回;
}

current
是一个宏,可将其转换为函数调用:

static\uuu始终\u内联结构任务\u结构*获取当前(无效)
{
返回此cpu读取稳定(当前任务);
}
#定义当前get_current()

使用其他变量名。

Linux内核错误
如何处理内核?你是怎么得到这个错误的?我想你在编译一些代码时会遇到编译错误。所以请发布代码。请在这里提供更多信息,因为当你没有提供足够的信息时,很难回答,例如你正在做什么,什么时候发生这种情况,你编译的内核版本等等。谢谢你的回复,先生。。请再看一遍这篇文章。我已经15年没有在C语言开发了,所以我觉得无法回答你。代码看起来不错。编译器问题似乎“current”不是变量。但它的定义如上所述。当我在C中运行它时,它看起来还可以,但是当我将它编译为内核模块时,它会显示这样的错误。。。