mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	contributing: add safety section
This commit is contained in:
		
							parent
							
								
									1b0694b794
								
							
						
					
					
						commit
						3406c1b17a
					
				
					 1 changed files with 9 additions and 0 deletions
				
			
		| 
						 | 
					@ -237,6 +237,15 @@ used and `#undef` them after.
 | 
				
			||||||
* Document the contents and container of a `struct wl_list` with a
 | 
					* Document the contents and container of a `struct wl_list` with a
 | 
				
			||||||
  `// content.link` and `// container.list` comment.
 | 
					  `// content.link` and `// container.list` comment.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Safety
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* Avoid string manipulation functions which don't take the size of the
 | 
				
			||||||
 | 
					  destination buffer as input: for instance, prefer `snprintf` over `sprintf`.
 | 
				
			||||||
 | 
					* Avoid repeating type names in `sizeof()` where possible. For instance, prefer
 | 
				
			||||||
 | 
					  `ptr = calloc(1, sizeof(*ptr))` over `ptr = calloc(1, sizeof(struct foo))`.
 | 
				
			||||||
 | 
					* Prefer `*ptr = (struct foo){0}` over `memset(ptr, 0, sizeof(*ptr))`.
 | 
				
			||||||
 | 
					* Prefer `*foo = *bar` over `memcpy(foo, bar, sizeof(*foo))`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Example
 | 
					### Example
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```c
 | 
					```c
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue