static struct usb_function_instance *try_get_usb_function_instance(const char *name) { struct usb_function_driver *fd; struct usb_function_instance *fi; fi = ERR_PTR(-ENOENT); mutex_lock(&func_lock); list_for_each_entry(fd, &func_list, list) { if (strcmp(name, fd->name)) continue; if (!try_module_get(fd->mod)) { fi = ERR_PTR(-EBUSY); break; } fi = fd->alloc_inst(); if (IS_ERR(fi)) module_put(fd->mod); else fi->fd = fd; break; } mutex_unlock(&func_lock); return fi; }
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #include <signal.h> #include <string.h> // static static char* name[] = {"uac","uvc","back","fprint"}; int main() { int i = 0; while(i++<10) { if(strcmp(name[i],"uac")) { printf("string is not the same \n"); continue; } } while(1); return 0; }
C/C++函数,比较两个字符串 设这两个字符串为str1,str2, 若str1==str2,则返回零; 若str1<str2,则返回负数; 若str1>str2,则返回正数。 matlab中函数,strcmp(s1,s2) 判断两个字符串s1和s2是否相同,相同返回true ,不同返回false
原文:https://www.cnblogs.com/nowroot/p/13655058.html