mirror of
				https://github.com/Mbed-TLS/mbedtls.git
				synced 2025-11-03 20:33:16 +03:00 
			
		
		
		
	More consistent usage of volatile
Fix MSVC warning C4090. Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
		@@ -30,9 +30,9 @@ volatile int false_but_the_compiler_does_not_know = 0;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Set n bytes at the address p to all-bits-zero, in such a way that
 | 
					/* Set n bytes at the address p to all-bits-zero, in such a way that
 | 
				
			||||||
 * the compiler should not know that p is all-bits-zero. */
 | 
					 * the compiler should not know that p is all-bits-zero. */
 | 
				
			||||||
static void set_to_zero_but_the_compiler_does_not_know(void *p, size_t n)
 | 
					static void set_to_zero_but_the_compiler_does_not_know(volatile void *p, size_t n)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    memset(p, false_but_the_compiler_does_not_know, n);
 | 
					    memset((void *) p, false_but_the_compiler_does_not_know, n);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -54,7 +54,7 @@ void meta_test_fail(const char *name)
 | 
				
			|||||||
void null_pointer_dereference(const char *name)
 | 
					void null_pointer_dereference(const char *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    (void) name;
 | 
					    (void) name;
 | 
				
			||||||
    volatile char *p;
 | 
					    volatile char *volatile p;
 | 
				
			||||||
    set_to_zero_but_the_compiler_does_not_know(&p, sizeof(p));
 | 
					    set_to_zero_but_the_compiler_does_not_know(&p, sizeof(p));
 | 
				
			||||||
    mbedtls_printf("%p -> %u\n", p, (unsigned) *p);
 | 
					    mbedtls_printf("%p -> %u\n", p, (unsigned) *p);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -62,7 +62,7 @@ void null_pointer_dereference(const char *name)
 | 
				
			|||||||
void null_pointer_call(const char *name)
 | 
					void null_pointer_call(const char *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    (void) name;
 | 
					    (void) name;
 | 
				
			||||||
    unsigned (*p)(void);
 | 
					    unsigned(*volatile p)(void);
 | 
				
			||||||
    set_to_zero_but_the_compiler_does_not_know(&p, sizeof(p));
 | 
					    set_to_zero_but_the_compiler_does_not_know(&p, sizeof(p));
 | 
				
			||||||
    /* The pointer representation may be truncated, but we don't care:
 | 
					    /* The pointer representation may be truncated, but we don't care:
 | 
				
			||||||
     * the only point of printing it is to have some use of the pointer
 | 
					     * the only point of printing it is to have some use of the pointer
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user