当前位置:网站首页>Embedded development: tips and techniques -- the best practice of defensive programming with C
Embedded development: tips and techniques -- the best practice of defensive programming with C
2022-07-28 03:48:00 【Guangdong embedded Education】
Best practices are fundamental to every firmware application 、 Basic practice . Defensive programming has always been an important software skill . Here are some uses that embedded developers should keep in mind C Best practices for defensive programming :

l Check the input and output of the function
l Check the return value of the function ( They are often ignored !)
l Monitor the buffer to prevent overflow
l Verify that the pointer is not empty , Especially function pointers
l Use assertion macros to detect errors rather than error conditions
l 2–3% The code of should be assertions
l Assert that the state of the system should not be modified
l Only expose data and functions that large programs need to know ( encapsulation )
l Perform static analysis during the build
l Monitor whether the stack overflows
l Use known mode 、ISR Vector or stop Instruction fills unused ROM
l The watchdog system should be integrated , Don't spoil the watchdog blindly
Embedded developers follow these simple best practices to help ensure improved firmware quality , This is the first step in developing security firmware .
边栏推荐
- Super nice PHP program source code of nteam official website
- 动态规划——62. 不同路径
- 高等数学(第七版)同济大学 习题3-5 个人解答
- 简单、好用的性能测试工具推荐
- Advanced Mathematics (Seventh Edition) Tongji University exercises 3-6 personal solutions
- LeetCode_409_最长回文串
- 贪心——122. 买卖股票的最佳时机 II
- Airiot Q & A issue 6 | how to use the secondary development engine?
- 高等数学(第七版)同济大学 习题3-4 个人解答(后8题)
- WordPress simple mkblog blog theme template v2.1
猜你喜欢

常用的接口测试工具

单调栈——739. 每日温度

TypeError: ufunc ‘bitwise_and‘ not supported for the input types, and the inputs could not be safely

8000 word explanation of OBSA principle and application practice

4-day excel practical training camp, 0.01 yuan special offer for only three days, 200 sets of learning kits

Unity backpack system

conda虚拟环境总结与解读

Dynamic programming - 509. Fibonacci number

AI chief architect 12 AICA Baidu OCR vertical large-scale landing practice

Vertical align align the elements in the row are vertically centered
随机推荐
Advanced Mathematics (Seventh Edition) Tongji University exercises 3-5 personal solutions
Lightpicture - exquisite drawing bed system
数据挖掘-01
Unity backpack system
Advanced Mathematics (Seventh Edition) Tongji University exercises 3-4 personal solutions (the last 8 questions)
动态规划——416. 分割等和子集
In December, the PMP Exam adopted the new syllabus for the first time. How to learn?
Prefix-Tuning: Optimizing Continuous Prompts for Generation
Screenshot of deepstream detection results
Leetcode58. Length of the last word
动态规划——474. 一和零
Daily practice ----- realize the lottery function of two-color ball. Rules: Six non repeating numbers are randomly selected from 36 red balls, and one from 15 basketball is randomly selected to form a
Swift中的协议
2022 summary of the latest Android handler related interview questions
超好用的 PC 端长截图工具
MangoPapa 的实用小脚本(目录篇)
贪心——122. 买卖股票的最佳时机 II
C语言:求一个整数存储在内存中的二进制中1的个数
【LeetCode】34、在排序数组中查找元素的第一个和最后一个位置
[openvx] VX for basic use of objects_ image