Source code static analysis tools

Source: Internet
Author: User

Code writing is not rigorous. It often leads to many unpredictable errors in your software, and these errors are sometimes random, which makes it difficult for you to analyze and locate problems. We can use some excellent static source code analysis tools to help us check many programming tasks such as uninitialized variables, memory leakage, null pointer reference, buffer overflow, and array out-of-bounds. error, make the software more stable and robust. Well-known tools include klocwork and lint. Case 1: Check for Memory leakage: p1 = malloc (10); if (p1 = null) {return;} p2 = malloc (20); if (p2 = null) {return;} case 2 array out-of-bounds check: int a [10] = {0}; a [10] = 0x20; Case 3 Null Pointer Reference check: char * ps_name = null; char s_name [10] = "my_name" memcpy (ps_name, s_name, 10); Case 4 buffer overflow check: p1 = malloc (10 ); char s_name [20] = "my name is vector"; strcpy (p1, s_name); although programming errors are always unavoidable, we still need to develop good programming habits, minimize such errors and strive to improve software quality.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.