1、A seamless revolution for the safe use of the language family that has passed the test of timeC is a critical infrastructure of the worldC is supported by strong economic reasons270002500023000210001900017000150002018 2019 2020 2021 2022If used without discipline C has great safety and security issu
2、es MISRA compliance solves many of these but not allThe industry is so concerned about these issues that a passage to Rust is actually being discussedWhat if there was a safer and cheaper way?In short,the borrow checker and much more can be implemented for C,yet preserving the entire C ecosystem (an
3、d the huge investments done on it)In fact there is!1void process(char*string);23int foo(const char*fname,size_t bufsize)4int fd=open(fname,O_RDONLY);5char*buf=(char*)malloc(bufsize);6+fd;7ssize_t bytes=read(fd,buf,bufsize-1U);8bufbytes=0;9process(buf);10return 0;11No Warnings by the CompilerSeveral
4、Warnings by the C-rusted Analyzer1#include 23void process(char*e hown string);45int foo(const char*fname,size_t bufsize)6int fd=open(fname,O_RDONLY);7if(fd=-1)return 1;8char*buf=(char*)malloc(bufsize);9if(buf=NULL|bufsize=0U)return 1;10ssize_t bytes=read(fd,buf,bufsize-1U);11if(bytes=-1)12free(buf);
5、13return 1;1415bufbytes=0;16process(buf);17return(close(fd)=-1)?1:0;18No Warnings by the C-rusted Analyzer1typedef inte type()e geq(0)fd_t;2typedef fd_te own(fd)own_fd_t;3typedef own_fd_t e opt(-1)opt_own_fd_t;45/Read property.6opt_own_fd_t e with(r)7open(const char*path,8int e and eq(O RDONLY|O WRO
6、NLY|O RDWR,O RDONLY)oflag);910/Write property.11opt_own_fd_t e with(w)12open(const char*path,13int e and eq(O RDONLY|O WRONLY|O RDWR,O WRONLY)oflag);1415/Read and write properties.16opt_own_fd_t e with(r,w)17open(const char*path,18int e and eq(O RDONLY|O WRONLY|O RDWR,O RDWR)oflag);Standard Librarie