type stringclasses 5
values | content stringlengths 9 163k |
|---|---|
includes | #include <asm/io.h> |
includes | #include <asm/delay.h> |
includes | #include <asm/tlbflush.h> |
includes | #include <asm/cacheflush.h> |
includes | #include <asm/checksum.h> |
defines |
#define DECLARE_EXPORT(name) extern void name(void);EXPORT_SYMBOL(name) |
includes |
#include <assert.h> |
includes | #include <ctype.h> |
includes | #include <string.h> |
defines | #define TAG_MAP_SIZE (sizeof(kGumboTagMap) / sizeof(kGumboTagMap[0])) |
functions | void gumbo_tag_from_original_text(GumboStringPiece* text) {
if (text->data == NULL) {
return;
} |
functions | int case_memcmp(const char* s1, const char* s2, unsigned int n) {
while (n--) {
unsigned char c1 = tolower(*s1++);
unsigned char c2 = tolower(*s2++);
if (c1 != c2) return (int) c1 - (int) c2;
} |
functions | GumboTag gumbo_tagn_enum(const char* tagname, unsigned int length) {
if (length) {
unsigned int key = tag_hash(tagname, length);
if (key < TAG_MAP_SIZE) {
GumboTag tag = (GumboTag)kGumboTagMap[key];
if (length == kGumboTagSizes[(int) tag] &&
!case_memcmp(tagname, kGumboTagNames[(int) tag... |
functions | GumboTag gumbo_tag_enum(const char* tagname) {
return gumbo_tagn_enum(tagname, strlen(tagname));
} |
functions | int staticReturnsTrue()
{
return 1;
} |
functions | int staticReturnsFalse()
{
return 0;
} |
functions | void CWE191_Integer_Underflow__int_rand_predec_08_bad()
{
int data;
/* Initialize data */
data = 0;
if(staticReturnsTrue())
{
/* POTENTIAL FLAW: Set data to a random value */
data = RAND32();
} |
functions | void goodB2G1()
{
int data;
/* Initialize data */
data = 0;
if(staticReturnsTrue())
{
/* POTENTIAL FLAW: Set data to a random value */
data = RAND32();
} |
functions | void goodB2G2()
{
int data;
/* Initialize data */
data = 0;
if(staticReturnsTrue())
{
/* POTENTIAL FLAW: Set data to a random value */
data = RAND32();
} |
functions | void goodG2B1()
{
int data;
/* Initialize data */
data = 0;
if(staticReturnsFalse())
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
} |
functions | void goodG2B2()
{
int data;
/* Initialize data */
data = 0;
if(staticReturnsTrue())
{
/* FIX: Use a small, non-zero value that will not cause an integer underflow in the sinks */
data = -2;
} |
functions | void CWE191_Integer_Underflow__int_rand_predec_08_good()
{
goodB2G1();
goodB2G2();
goodG2B1();
goodG2B2();
} |
main | int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE191_Integer_Underflow__int_rand_predec_08_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...... |
includes |
#include <assert.h> |
includes | #include <limits.h> |
includes | #include <math.h> |
functions | void vp9_noise_estimate_init(NOISE_ESTIMATE *const ne, int width, int height) {
ne->enabled = 0;
ne->level = kLowLow;
ne->value = 0;
ne->count = 0;
ne->thresh = 90;
ne->last_w = 0;
ne->last_h = 0;
if (width * height >= 1920 * 1080) {
ne->thresh = 200;
} |
functions | else if (width * height >= 1280 * 720) {
ne->thresh = 140;
} |
functions | else if (width * height >= 640 * 360) {
ne->thresh = 100;
} |
functions | int enable_noise_estimation(VP9_COMP *const cpi) {
#if CONFIG_VP9_HIGHBITDEPTH
if (cpi->common.use_highbitdepth) return 0;
#endif
// Enable noise estimation if denoising is on.
#if CONFIG_VP9_TEMPORAL_DENOISING
if (cpi->oxcf.noise_sensitivity > 0 && denoise_svc(cpi) &&
cpi->common.width >= 320 && cpi->common.... |
functions | void copy_frame(YV12_BUFFER_CONFIG *const dest,
const YV12_BUFFER_CONFIG *const src) {
int r;
const uint8_t *srcbuf = src->y_buffer;
uint8_t *destbuf = dest->y_buffer;
assert(dest->y_width == src->y_width);
assert(dest->y_height == src->y_height);
for (r = 0; r < dest->y_height; ++r... |
functions | NOISE_LEVEL vp9_noise_estimate_extract_level(NOISE_ESTIMATE *const ne) {
int noise_level = kLowLow;
if (ne->value > (ne->thresh << 1)) {
noise_level = kHigh;
} |
functions | void vp9_update_noise_estimate(VP9_COMP *const cpi) {
const VP9_COMMON *const cm = &cpi->common;
NOISE_ESTIMATE *const ne = &cpi->noise_estimate;
const int low_res = (cm->width <= 352 && cm->height <= 288);
// Estimate of noise level every frame_period frames.
int frame_period = 8;
int thresh_consec_zeromv ... |
functions | endif
if (last_source != NULL) {
ne->last_w = cm->width;
ne->last_h = cm->height;
} |
includes |
#include <stdbool.h> |
includes | #include <stdint.h> |
includes | #include <stdarg.h> |
defines | #define TX_BUFFER_USED (GetBufferCount(&g_ui32UARTTxReadIndex, \
|
defines | #define TX_BUFFER_FREE (UART_TX_BUFFER_SIZE - TX_BUFFER_USED)
|
defines | #define TX_BUFFER_EMPTY (IsBufferEmpty(&g_ui32UARTTxReadIndex, \
|
defines | #define TX_BUFFER_FULL (IsBufferFull(&g_ui32UARTTxReadIndex, \
|
defines | #define ADVANCE_TX_BUFFER_INDEX(Index) \
|
defines | #define RX_BUFFER_USED (GetBufferCount(&g_ui32UARTRxReadIndex, \
|
defines | #define RX_BUFFER_FREE (UART_RX_BUFFER_SIZE - RX_BUFFER_USED)
|
defines | #define RX_BUFFER_EMPTY (IsBufferEmpty(&g_ui32UARTRxReadIndex, \
|
defines | #define RX_BUFFER_FULL (IsBufferFull(&g_ui32UARTRxReadIndex, \
|
defines | #define ADVANCE_RX_BUFFER_INDEX(Index) \
|
functions | bool
IsBufferFull(volatile uint32_t *pui32Read,
volatile uint32_t *pui32Write, uint32_t ui32Size)
{
uint32_t ui32Write;
uint32_t ui32Read;
ui32Write = *pui32Write;
ui32Read = *pui32Read;
return((((ui32Write + 1) % ui32Size) == ui32Read) ? true : false);
} |
functions | bool
IsBufferEmpty(volatile uint32_t *pui32Read,
volatile uint32_t *pui32Write)
{
uint32_t ui32Write;
uint32_t ui32Read;
ui32Write = *pui32Write;
ui32Read = *pui32Read;
return((ui32Write == ui32Read) ? true : false);
} |
functions | uint32_t
GetBufferCount(volatile uint32_t *pui32Read,
volatile uint32_t *pui32Write, uint32_t ui32Size)
{
uint32_t ui32Write;
uint32_t ui32Read;
ui32Write = *pui32Write;
ui32Read = *pui32Read;
return((ui32Write >= ui32Read) ? (ui32Write - ui32Read) :
(ui32Size ... |
functions | void
UARTPrimeTransmit(uint32_t ui32Base)
{
//
// Do we have any data to transmit?
//
if(!TX_BUFFER_EMPTY)
{
//
// Disable the UART interrupt. If we don't do this there is a race
// condition which can cause the read index to be corrupted.
//
MAP_... |
functions | void
UARTStdioConfig(uint32_t ui32PortNum, uint32_t ui32Baud, uint32_t ui32SrcClock)
{
//
// Check the arguments.
//
ASSERT((ui32PortNum == 0) || (ui32PortNum == 1) ||
(ui32PortNum == 2));
#ifdef UART_BUFFERED
//
// In buffered mode, we only allow a single instance to be o... |
functions | int
UARTwrite(const char *pcBuf, uint32_t ui32Len)
{
#ifdef UART_BUFFERED
unsigned int uIdx;
//
// Check for valid arguments.
//
ASSERT(pcBuf != 0);
ASSERT(g_ui32Base != 0);
//
// Send the characters
//
for(uIdx = 0; uIdx < ui32Len; uIdx++)
{
//
... |
functions | int
UARTgets(char *pcBuf, uint32_t ui32Len)
{
#ifdef UART_BUFFERED
uint32_t ui32Count = 0;
int8_t cChar;
//
// Check the arguments.
//
ASSERT(pcBuf != 0);
ASSERT(ui32Len != 0);
ASSERT(g_ui32Base != 0);
//
// Adjust the length back by 1 to leave space for the trai... |
functions | char
UARTgetc(void)
{
#ifdef UART_BUFFERED
unsigned char cChar;
//
// Wait for a character to be received.
//
while(RX_BUFFER_EMPTY)
{
//
// Block waiting for a character to be received (if the buffer is
// currently empty).
//
} |
functions | void
UARTvprintf(const char *pcString, va_list vaArgP)
{
uint32_t ui32Idx, ui32Value, ui32Pos, ui32Count, ui32Base, ui32Neg;
char *pcStr, pcBuf[16], cFill;
//
// Check the arguments.
//
ASSERT(pcString != 0);
//
// Loop while there are more characters in the string.
//... |
functions | void
UARTprintf(const char *pcString, ...)
{
va_list vaArgP;
//
// Start the varargs processing.
//
va_start(vaArgP, pcString);
UARTvprintf(pcString, vaArgP);
//
// We're finished with the varargs now.
//
va_end(vaArgP);
} |
functions | int
UARTRxBytesAvail(void)
{
return(RX_BUFFER_USED);
} |
functions | int
UARTTxBytesFree(void)
{
return(TX_BUFFER_FREE);
} |
functions | int
UARTPeek(unsigned char ucChar)
{
int iCount;
int iAvail;
uint32_t ui32ReadIndex;
//
// How many characters are there in the receive buffer?
//
iAvail = (int)RX_BUFFER_USED;
ui32ReadIndex = g_ui32UARTRxReadIndex;
//
// Check all the unread characters looking fo... |
functions | void
UARTFlushRx(void)
{
uint32_t ui32Int;
//
// Temporarily turn off interrupts.
//
ui32Int = MAP_IntMasterDisable();
//
// Flush the receive buffer.
//
g_ui32UARTRxReadIndex = 0;
g_ui32UARTRxWriteIndex = 0;
//
// If interrupts were enabled when we tu... |
functions | void
UARTFlushTx(bool bDiscard)
{
uint32_t ui32Int;
//
// Should the remaining data be discarded or transmitted?
//
if(bDiscard)
{
//
// The remaining data should be discarded, so temporarily turn off
// interrupts.
//
ui32Int = MAP_IntMaste... |
functions | void
UARTEchoSet(bool bEnable)
{
g_bDisableEcho = !bEnable;
} |
functions | void
UARTStdioIntHandler(void)
{
uint32_t ui32Ints;
int8_t cChar;
int32_t i32Char;
static bool bLastWasCR = false;
//
// Get and clear the current interrupt source(s)
//
ui32Ints = MAP_UARTIntStatus(g_ui32Base, true);
MAP_UARTIntClear(g_ui32Base, ui32Ints);
//
... |
functions | int ArgoRx_preinit(ArgoRx_t *me) {
//if there are input events, reset them
//if there are output events, reset them
me->outputEvents.event.DataPresent = 0;
//if there are input vars with default values, set them
me->ChanId = 1;
//if there are output vars with default values, set them
//if there are internal ... |
functions | int ArgoRx_init(ArgoRx_t *me) {
//pass in any parameters on this level
//perform a data copy to all children (if any present) (can move config data around, doesn't do anything otherwise)
//if there are fb children (CFBs/Devices/Resources only), call this same function on them
me->chan = mp_create_qport(me... |
functions | void ArgoRx_run(ArgoRx_t *me) {
//if there are output events, reset them
me->outputEvents.event.DataPresent = 0;
if(me->needToAck == true) {
if(!mp_nback(me->chan)) {
return;
} |
includes | #include <allegro5/allegro.h> |
includes | #include <allegro5/allegro_image.h> |
includes | #include <allegro5/allegro_font.h> |
includes | #include <stdlib.h> |
includes | #include <math.h> |
defines |
#define FPS 60 |
functions | void update(void)
{
example.ticks++;
} |
functions | void redraw(void)
{
int w = al_get_display_width(example.display);
int h = al_get_display_height(example.display);
int i;
al_clear_to_color(example.bg);
for (i = 0; i < 6; i++) {
float x = (i / 2) * w / 3 + w / 6;
float y = (i % 2) * h / 2 + h / 4;
ALLEGRO_BITMAP *bmp = example.... |
main | int main(int argc, char **argv)
{
ALLEGRO_TIMER *timer;
ALLEGRO_EVENT_QUEUE *queue;
int w = 640, h = 480;
bool done = false;
bool need_redraw = true;
int i;
ALLEGRO_BITMAP *mysha;
(void)argc;
(void)argv;
if (!al_init()) {
abort_example("Failed to init Allegro.\n");
} |
functions | float
sinhf(float x)
{
float t,w,h;
int32_t ix,jx;
GET_FLOAT_WORD(jx,x);
ix = jx&0x7fffffff;
/* x is INF or NaN */
if(ix>=0x7f800000) return x+x;
h = 0.5;
if (jx<0) h = -h;
/* |x| in [0,22], return sign(x)*0.5*(E+E/(E+1))) */
if (ix < 0x41b00000) { /* |x|<22 */
if (ix<0x31800000) /* |x|<2**... |
includes |
#include <stdio.h> |
includes | #include <stdbool.h> |
includes | #include <stdlib.h> |
functions | void grafo_imprime(grafo_t* g)
{
/* TODO: fazer função */
} |
functions | bool grafo_insere_aresta(grafo_t* g, int v1, int v2)
{
if(v1 >= MAX_VERTICES || v2 >= MAX_VERTICES){
printf("ERRO: vertice invalido!\n");
return false;
} |
functions | void grafo_importa(grafo_t* g, char* arquivo)
{
int nvertices, narestas;
int i, v1, v2;
FILE* f = fopen(arquivo, "r");
fscanf(f, "%d", &nvertices);
fscanf(f, "%d", &narestas);
g->nvertices = nvertices;
g->narestas = narestas;
for(i = 0; i < narestas; i++){
fscanf(f, "%d %d", &v1, &v2);
g->arest... |
functions | void grafo_destroi(grafo_t* g)
{
memo_libera(g);
} |
functions | int vc1test_write_header(AVFormatContext *s)
{
AVCodecContext *avc = s->streams[0]->codec;
AVIOContext *pb = s->pb;
if (avc->codec_id != CODEC_ID_WMV3) {
av_log(s, AV_LOG_ERROR, "Only WMV3 is accepted!\n");
return -1;
} |
functions | int vc1test_write_packet(AVFormatContext *s, AVPacket *pkt)
{
RCVContext *ctx = s->priv_data;
AVIOContext *pb = s->pb;
if (!pkt->size)
return 0;
avio_wl32(pb, pkt->size | ((pkt->flags & AV_PKT_FLAG_KEY) ? 0x80000000 : 0));
avio_wl32(pb, pkt->pts);
avio_write(pb, pkt->data, pkt->size);
... |
functions | int vc1test_write_trailer(AVFormatContext *s)
{
RCVContext *ctx = s->priv_data;
AVIOContext *pb = s->pb;
if (s->pb->seekable) {
avio_seek(pb, 0, SEEK_SET);
avio_wl24(pb, ctx->frames);
avio_flush(pb);
} |
includes |
#include <cydevice_trm.h> |
includes | #include <CyLib.h> |
includes | #include <IsrBtn1Pressed.h> |
defines | #define CYINT_IRQ_BASE 16 |
defines | #define CYINT_VECT_TABLE ((cyisraddress **) CYREG_NVIC_VECT_OFFSET) |
functions | void IsrBtn1Pressed_Start(void)
{
/* For all we know the interrupt is active. */
IsrBtn1Pressed_Disable();
/* Set the ISR to point to the IsrBtn1Pressed Interrupt. */
IsrBtn1Pressed_SetVector(&IsrBtn1Pressed_Interrupt);
/* Set the priority. */
IsrBtn1Pressed_SetPriority((uint8)IsrBtn1Pressed_I... |
functions | void IsrBtn1Pressed_StartEx(cyisraddress address)
{
/* For all we know the interrupt is active. */
IsrBtn1Pressed_Disable();
/* Set the ISR to point to the IsrBtn1Pressed Interrupt. */
IsrBtn1Pressed_SetVector(address);
/* Set the priority. */
IsrBtn1Pressed_SetPriority((uint8)IsrBtn1Pressed_I... |
functions | void IsrBtn1Pressed_Stop(void)
{
/* Disable this interrupt. */
IsrBtn1Pressed_Disable();
/* Set the ISR to point to the passive one. */
IsrBtn1Pressed_SetVector(&IntDefaultHandler);
} |
functions | void IsrBtn1Pressed_SetVector(cyisraddress address)
{
cyisraddress * ramVectorTable;
ramVectorTable = (cyisraddress *) *CYINT_VECT_TABLE;
ramVectorTable[CYINT_IRQ_BASE + (uint32)IsrBtn1Pressed__INTC_NUMBER] = address;
} |
functions | cyisraddress IsrBtn1Pressed_GetVector(void)
{
cyisraddress * ramVectorTable;
ramVectorTable = (cyisraddress *) *CYINT_VECT_TABLE;
return ramVectorTable[CYINT_IRQ_BASE + (uint32)IsrBtn1Pressed__INTC_NUMBER];
} |
functions | void IsrBtn1Pressed_SetPriority(uint8 priority)
{
*IsrBtn1Pressed_INTC_PRIOR = priority << 5;
} |
functions | uint8 IsrBtn1Pressed_GetPriority(void)
{
uint8 priority;
priority = *IsrBtn1Pressed_INTC_PRIOR >> 5;
return priority;
} |
functions | void IsrBtn1Pressed_Enable(void)
{
/* Enable the general interrupt. */
*IsrBtn1Pressed_INTC_SET_EN = IsrBtn1Pressed__INTC_MASK;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.