idx
int64 | func
string | target
int64 |
|---|---|---|
508,364
|
bool close_cached_connection_tables(THD *thd, LEX_STRING *connection)
{
close_cached_connection_tables_arg argument;
DBUG_ENTER("close_cached_connections");
DBUG_ASSERT(thd);
argument.thd= thd;
argument.connection= connection;
argument.tables= NULL;
if (tdc_iterate(thd,
(my_hash_walk_action) close_cached_connection_tables_callback,
&argument))
DBUG_RETURN(true);
DBUG_RETURN(argument.tables ?
close_cached_tables(thd, argument.tables, FALSE, LONG_TIMEOUT) :
false);
}
| 0
|
225,896
|
GF_Err udta_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_Err e = gf_isom_box_array_read(s, bs);
if (e) return e;
if (s->size==4) {
u32 val = gf_bs_read_u32(bs);
s->size = 0;
if (val) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] udta has 4 remaining bytes set to %08X but they should be 0\n", val));
}
}
return GF_OK;
| 0
|
308,180
|
static void fastrpc_map_put(struct fastrpc_map *map)
{
if (map)
kref_put(&map->refcount, fastrpc_free_map);
}
| 0
|
387,748
|
ModuleEntry* InstanceKlass::module() const {
if (!in_unnamed_package()) {
return _package_entry->module();
}
const Klass* host = host_klass();
if (host == NULL) {
return class_loader_data()->unnamed_module();
}
return host->class_loader_data()->unnamed_module();
}
| 0
|
513,109
|
inline void TABLE::mark_virtual_column_deps(Field *field)
{
DBUG_ASSERT(field->vcol_info);
DBUG_ASSERT(field->vcol_info->expr);
field->vcol_info->expr->walk(&Item::register_field_in_read_map, 1, 0);
}
| 0
|
246,749
|
static GF_Err do_export_tracks_non_isobmf()
{
u32 i;
GF_MediaExporter mdump;
char szFile[GF_MAX_PATH+24];
for (i=0; i<nb_track_act; i++) {
GF_Err e;
TrackAction *tka = &tracks[i];
if (tka->act_type != TRAC_ACTION_RAW_EXTRACT) continue;
memset(&mdump, 0, sizeof(mdump));
mdump.in_name = inName;
mdump.flags = tka->dump_type;
mdump.trackID = tka->trackID;
mdump.track_type = tka->dump_track_type;
mdump.sample_num = tka->sample_num;
if (dump_std) {
mdump.out_name = "std";
}
else if (outName) {
mdump.out_name = outName;
mdump.flags |= GF_EXPORT_MERGE;
} else if (nb_track_act>1) {
sprintf(szFile, "%s_track%d", outfile, mdump.trackID);
mdump.out_name = szFile;
} else {
mdump.out_name = outfile;
}
mdump.print_stats_graph = fs_dump_flags;
e = gf_media_export(&mdump);
if (e) return e;
}
return GF_OK;
}
| 0
|
242,656
|
static void isoffin_purge_mem(ISOMReader *read, u64 min_offset)
{
u32 i, count;
u64 top_offset;
u32 nb_bytes_to_purge;
u64 bytes_missing;
//purge every
if (read->mstore_purge && (min_offset - read->last_min_offset < read->mstore_purge))
return;
if (read->frag_type) {
//get position of current box being parsed - if new offset is greater than this box we cannot remove
//bytes (we would trash the top-level box header)
gf_isom_get_current_top_box_offset(read->mov, &top_offset);
if (top_offset<min_offset) {
return;
}
}
read->last_min_offset = min_offset;
assert(min_offset>=read->bytes_removed);
//min_offset is given in absolute file position
nb_bytes_to_purge = (u32) (min_offset - read->bytes_removed);
assert(nb_bytes_to_purge<=read->mem_blob.size);
memmove(read->mem_blob.data, read->mem_blob.data+nb_bytes_to_purge, read->mem_blob.size - nb_bytes_to_purge);
read->mem_blob.size -= nb_bytes_to_purge;
read->bytes_removed += nb_bytes_to_purge;
gf_isom_set_removed_bytes(read->mov, read->bytes_removed);
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[IsoMedia] mem mode %d bytes in mem, "LLU" bytes trashed since start\n", read->mem_blob.size, read->bytes_removed));
//force a refresh
gf_isom_refresh_fragmented(read->mov, &bytes_missing, read->mem_url);
if (!read->frag_type)
return;
//fragmented file, cleanup sample tables
count = gf_list_count(read->channels);
for (i=0; i<count; i++) {
ISOMChannel *ch = gf_list_get(read->channels, i);
u32 num_samples;
u32 prev_samples = gf_isom_get_sample_count(read->mov, ch->track);
//don't run this too often
if (ch->sample_num<=1+read->mstore_samples) continue;
num_samples = ch->sample_num-1;
if (num_samples>=prev_samples) continue;
if (gf_isom_purge_samples(read->mov, ch->track, num_samples) == GF_OK)
ch->sample_num = 1;
num_samples = gf_isom_get_sample_count(read->mov, ch->track);
assert(ch->sample_num<=num_samples);
GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[IsoMedia] mem mode %d samples now in track %d (prev %d)\n", num_samples, ch->track_id, prev_samples));
}
}
| 0
|
261,246
|
void MqttClient_DeInit(MqttClient *client)
{
if (client != NULL) {
#ifdef WOLFMQTT_MULTITHREAD
(void)wm_SemFree(&client->lockSend);
(void)wm_SemFree(&client->lockRecv);
(void)wm_SemFree(&client->lockClient);
#endif
}
#ifdef WOLFMQTT_V5
(void)MqttProps_ShutDown();
#endif
}
| 0
|
225,866
|
GF_Err tpyl_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_NTYLBox *ptr = (GF_NTYLBox *)s;
if (ptr == NULL) return GF_BAD_PARAM;
ISOM_DECREASE_SIZE(ptr, 8);
ptr->nbBytes = gf_bs_read_u64(bs);
return GF_OK;
}
| 0
|
458,917
|
cin_isfuncdecl(
char_u **sp,
linenr_T first_lnum,
linenr_T min_lnum)
{
char_u *s;
linenr_T lnum = first_lnum;
linenr_T save_lnum = curwin->w_cursor.lnum;
int retval = FALSE;
pos_T *trypos;
int just_started = TRUE;
if (sp == NULL)
s = ml_get(lnum);
else
s = *sp;
curwin->w_cursor.lnum = lnum;
if (find_last_paren(s, '(', ')')
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL)
{
lnum = trypos->lnum;
if (lnum < min_lnum)
{
curwin->w_cursor.lnum = save_lnum;
return FALSE;
}
s = ml_get(lnum);
}
curwin->w_cursor.lnum = save_lnum;
// Ignore line starting with #.
if (cin_ispreproc(s))
return FALSE;
while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"')
{
if (cin_iscomment(s)) // ignore comments
s = cin_skipcomment(s);
else if (*s == ':')
{
if (*(s + 1) == ':')
s += 2;
else
// To avoid a mistake in the following situation:
// A::A(int a, int b)
// : a(0) // <--not a function decl
// , b(0)
// {...
return FALSE;
}
else
++s;
}
if (*s != '(')
return FALSE; // ';', ' or " before any () or no '('
while (*s && *s != ';' && *s != '\'' && *s != '"')
{
if (*s == ')' && cin_nocode(s + 1))
{
// ')' at the end: may have found a match
// Check for he previous line not to end in a backslash:
// #if defined(x) && {backslash}
// defined(y)
lnum = first_lnum - 1;
s = ml_get(lnum);
if (*s == NUL || s[STRLEN(s) - 1] != '\\')
retval = TRUE;
goto done;
}
if ((*s == ',' && cin_nocode(s + 1)) || s[1] == NUL || cin_nocode(s))
{
int comma = (*s == ',');
// ',' at the end: continue looking in the next line.
// At the end: check for ',' in the next line, for this style:
// func(arg1
// , arg2)
for (;;)
{
if (lnum >= curbuf->b_ml.ml_line_count)
break;
s = ml_get(++lnum);
if (!cin_ispreproc(s))
break;
}
if (lnum >= curbuf->b_ml.ml_line_count)
break;
// Require a comma at end of the line or a comma or ')' at the
// start of next line.
s = skipwhite(s);
if (!just_started && (!comma && *s != ',' && *s != ')'))
break;
just_started = FALSE;
}
else if (cin_iscomment(s)) // ignore comments
s = cin_skipcomment(s);
else
{
++s;
just_started = FALSE;
}
}
done:
if (lnum != first_lnum && sp != NULL)
*sp = ml_get(first_lnum);
return retval;
}
| 0
|
473,938
|
onigenc_not_support_get_ctype_code_range(OnigCtype ctype,
OnigCodePoint* sb_out, const OnigCodePoint* ranges[],
OnigEncoding enc)
{
return ONIG_NO_SUPPORT_CONFIG;
}
| 0
|
348,431
|
static struct mkiss *mkiss_get(struct tty_struct *tty)
{
struct mkiss *ax;
read_lock(&disc_data_lock);
ax = tty->disc_data;
if (ax)
refcount_inc(&ax->refcnt);
read_unlock(&disc_data_lock);
return ax;
}
| 0
|
336,011
|
static int sr9700_bind(struct usbnet *dev, struct usb_interface *intf)
{
struct net_device *netdev;
struct mii_if_info *mii;
u8 addr[ETH_ALEN];
int ret;
ret = usbnet_get_endpoints(dev, intf);
if (ret)
goto out;
netdev = dev->net;
netdev->netdev_ops = &sr9700_netdev_ops;
netdev->ethtool_ops = &sr9700_ethtool_ops;
netdev->hard_header_len += SR_TX_OVERHEAD;
dev->hard_mtu = netdev->mtu + netdev->hard_header_len;
/* bulkin buffer is preferably not less than 3K */
dev->rx_urb_size = 3072;
mii = &dev->mii;
mii->dev = netdev;
mii->mdio_read = sr_mdio_read;
mii->mdio_write = sr_mdio_write;
mii->phy_id_mask = 0x1f;
mii->reg_num_mask = 0x1f;
sr_write_reg(dev, SR_NCR, NCR_RST);
udelay(20);
/* read MAC
* After Chip Power on, the Chip will reload the MAC from
* EEPROM automatically to PAR. In case there is no EEPROM externally,
* a default MAC address is stored in PAR for making chip work properly.
*/
if (sr_read(dev, SR_PAR, ETH_ALEN, addr) < 0) {
netdev_err(netdev, "Error reading MAC address\n");
ret = -ENODEV;
goto out;
}
eth_hw_addr_set(netdev, addr);
/* power up and reset phy */
sr_write_reg(dev, SR_PRR, PRR_PHY_RST);
/* at least 10ms, here 20ms for safe */
msleep(20);
sr_write_reg(dev, SR_PRR, 0);
/* at least 1ms, here 2ms for reading right register */
udelay(2 * 1000);
/* receive broadcast packets */
sr9700_set_multicast(netdev);
sr_mdio_write(netdev, mii->phy_id, MII_BMCR, BMCR_RESET);
sr_mdio_write(netdev, mii->phy_id, MII_ADVERTISE, ADVERTISE_ALL |
ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
mii_nway_restart(mii);
out:
return ret;
}
| 0
|
508,878
|
bool st_select_lex::test_limit()
{
if (select_limit != 0)
{
my_error(ER_NOT_SUPPORTED_YET, MYF(0),
"LIMIT & IN/ALL/ANY/SOME subquery");
return(1);
}
return(0);
}
| 0
|
312,469
|
f_getqflist(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
{
# ifdef FEAT_QUICKFIX
if (in_vim9script() && check_for_opt_dict_arg(argvars, 0) == FAIL)
return;
get_qf_loc_list(TRUE, NULL, &argvars[0], rettv);
# endif
}
| 0
|
225,500
|
MutableGraphView::GetFanout(const GraphView::OutputPort& port) const {
return GetFanout(MutableGraphView::OutputPort(const_cast<NodeDef*>(port.node),
port.port_id));
}
| 0
|
251,513
|
static inline void RelinquishDCMMemory(DCMInfo *info,DCMMap *map,
DCMStreamInfo *stream_info,LinkedListInfo *stack,unsigned char *data)
{
if (info->scale != (Quantum *) NULL)
info->scale=(Quantum *) RelinquishMagickMemory(info->scale);
if (map->gray != (int *) NULL)
map->gray=(int *) RelinquishMagickMemory(map->gray);
if (map->blue != (int *) NULL)
map->blue=(int *) RelinquishMagickMemory(map->blue);
if (map->green != (int *) NULL)
map->green=(int *) RelinquishMagickMemory(map->green);
if (map->red != (int *) NULL)
map->red=(int *) RelinquishMagickMemory(map->red);
if (stream_info->offsets != (ssize_t *) NULL)
stream_info->offsets=(ssize_t *) RelinquishMagickMemory(
stream_info->offsets);
if (stream_info != (DCMStreamInfo *) NULL)
stream_info=(DCMStreamInfo *) RelinquishMagickMemory(stream_info);
if (stack != (LinkedListInfo *) NULL)
stack=DestroyLinkedList(stack,RelinquishDCMInfo);
if (data != (unsigned char *) NULL)
data=(unsigned char *) RelinquishMagickMemory(data);
}
| 0
|
359,316
|
DEFUN (ip_community_list_name_standard,
ip_community_list_name_standard_cmd,
"ip community-list standard WORD (deny|permit) .AA:NN",
IP_STR
COMMUNITY_LIST_STR
"Add a standard community-list entry\n"
"Community list name\n"
"Specify community to reject\n"
"Specify community to accept\n"
COMMUNITY_VAL_STR)
{
return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_STANDARD, 1);
}
| 0
|
512,396
|
Item *get_copy(THD *thd)
{ return get_item_copy<Item_cache_str>(thd, this); }
| 0
|
484,057
|
START_TEST(Securechannel_sendAsymmetricOPNMessage_extraPaddingPresentWhenKeyLargerThan2048Bits) {
keySizes.asym_rmt_enc_key_size = 4096;
keySizes.asym_rmt_blocksize = 4096;
keySizes.asym_rmt_ptext_blocksize = 4096;
UA_OpenSecureChannelResponse dummyResponse;
createDummyResponse(&dummyResponse);
testChannel.securityMode = UA_MESSAGESECURITYMODE_SIGNANDENCRYPT;
UA_UInt32 requestId = UA_UInt32_random();
UA_StatusCode retval =
UA_SecureChannel_sendAsymmetricOPNMessage(&testChannel, requestId, &dummyResponse,
&UA_TYPES[UA_TYPES_OPENSECURECHANNELRESPONSE]);
ck_assert_msg(retval == UA_STATUSCODE_GOOD, "Expected function to succeed");
size_t offset = 0;
UA_TcpMessageHeader header;
UA_TcpMessageHeader_decodeBinary(&sentData, &offset, &header);
UA_UInt32 secureChannelId;
UA_UInt32_decodeBinary(&sentData, &offset, &secureChannelId);
UA_AsymmetricAlgorithmSecurityHeader asymSecurityHeader;
UA_AsymmetricAlgorithmSecurityHeader_decodeBinary(&sentData, &offset, &asymSecurityHeader);
ck_assert_msg(UA_ByteString_equal(&dummyCertificate, &asymSecurityHeader.senderCertificate),
"Expected the certificate to be equal to the one used by the secureChannel");
ck_assert_msg(UA_ByteString_equal(&testChannel.securityPolicy->policyUri,
&asymSecurityHeader.securityPolicyUri),
"Expected securityPolicyUri to be equal to the one used by the secureChannel");
UA_ByteString thumbPrint = {20, testChannel.remoteCertificateThumbprint};
ck_assert_msg(UA_ByteString_equal(&thumbPrint,
&asymSecurityHeader.receiverCertificateThumbprint),
"Expected receiverCertificateThumbprint to be equal to the one set "
"in the secureChannel");
for(size_t i = offset; i < header.messageSize; ++i) {
sentData.data[i] = (UA_Byte)((sentData.data[i] - 1) % (UA_BYTE_MAX + 1));
}
UA_SequenceHeader sequenceHeader;
UA_SequenceHeader_decodeBinary(&sentData, &offset, &sequenceHeader);
ck_assert_msg(sequenceHeader.requestId == requestId, "Expected requestId to be %i but was %i",
requestId, sequenceHeader.requestId);
UA_NodeId requestTypeId;
UA_NodeId_decodeBinary(&sentData, &offset, &requestTypeId);
ck_assert_msg(UA_NodeId_equal(&UA_TYPES[UA_TYPES_OPENSECURECHANNELRESPONSE].binaryEncodingId, &requestTypeId), "Expected nodeIds to be equal");
UA_OpenSecureChannelResponse sentResponse;
UA_OpenSecureChannelResponse_decodeBinary(&sentData, &offset, &sentResponse);
ck_assert_msg(memcmp(&sentResponse, &dummyResponse, sizeof(UA_OpenSecureChannelResponse)) == 0,
"Expected the sent response to be equal to the one supplied to the send function");
UA_Byte paddingByte = sentData.data[offset];
UA_Byte extraPaddingByte = sentData.data[sentData.length - keySizes.asym_lcl_sig_size - 1];
size_t paddingSize = (size_t)paddingByte;
paddingSize |= extraPaddingByte << 8;
for(size_t i = 0; i <= paddingSize; ++i) {
ck_assert_msg(sentData.data[offset + i] == paddingByte,
"Expected padding byte %i to be %i but got value %i",
(int)i, paddingByte, sentData.data[offset + i]);
}
ck_assert_msg(sentData.data[offset + paddingSize + 1] == extraPaddingByte,
"Expected extra padding byte to be %i but got %i",
extraPaddingByte, sentData.data[offset + paddingSize + 1]);
ck_assert_msg(sentData.data[offset + paddingSize + 2] == '*',
"Expected first byte 42 of signature but got %i",
sentData.data[offset + paddingSize + 2]);
UA_AsymmetricAlgorithmSecurityHeader_clear(&asymSecurityHeader);
UA_SequenceHeader_clear(&sequenceHeader);
UA_OpenSecureChannelResponse_clear(&sentResponse);
}END_TEST
| 0
|
248,274
|
DLLIMPORT signed long cfg_getint(cfg_t *cfg, const char *name)
{
return cfg_getnint(cfg, name, 0);
}
| 0
|
209,102
|
do_mouse(
oparg_T *oap, // operator argument, can be NULL
int c, // K_LEFTMOUSE, etc
int dir, // Direction to 'put' if necessary
long count,
int fixindent) // PUT_FIXINDENT if fixing indent necessary
{
static int do_always = FALSE; // ignore 'mouse' setting next time
static int got_click = FALSE; // got a click some time back
int which_button; // MOUSE_LEFT, _MIDDLE or _RIGHT
int is_click = FALSE; // If FALSE it's a drag or release event
int is_drag = FALSE; // If TRUE it's a drag event
int jump_flags = 0; // flags for jump_to_mouse()
pos_T start_visual;
int moved; // Has cursor moved?
int in_status_line; // mouse in status line
static int in_tab_line = FALSE; // mouse clicked in tab line
int in_sep_line; // mouse in vertical separator line
int c1, c2;
#if defined(FEAT_FOLDING)
pos_T save_cursor;
#endif
win_T *old_curwin = curwin;
static pos_T orig_cursor;
colnr_T leftcol, rightcol;
pos_T end_visual;
int diff;
int old_active = VIsual_active;
int old_mode = VIsual_mode;
int regname;
#if defined(FEAT_FOLDING)
save_cursor = curwin->w_cursor;
#endif
// When GUI is active, always recognize mouse events, otherwise:
// - Ignore mouse event in normal mode if 'mouse' doesn't include 'n'.
// - Ignore mouse event in visual mode if 'mouse' doesn't include 'v'.
// - For command line and insert mode 'mouse' is checked before calling
// do_mouse().
if (do_always)
do_always = FALSE;
else
#ifdef FEAT_GUI
if (!gui.in_use)
#endif
{
if (VIsual_active)
{
if (!mouse_has(MOUSE_VISUAL))
return FALSE;
}
else if (State == MODE_NORMAL && !mouse_has(MOUSE_NORMAL))
return FALSE;
}
for (;;)
{
which_button = get_mouse_button(KEY2TERMCAP1(c), &is_click, &is_drag);
if (is_drag)
{
// If the next character is the same mouse event then use that
// one. Speeds up dragging the status line.
// Note: Since characters added to the stuff buffer in the code
// below need to come before the next character, do not do this
// when the current character was stuffed.
if (!KeyStuffed && vpeekc() != NUL)
{
int nc;
int save_mouse_row = mouse_row;
int save_mouse_col = mouse_col;
// Need to get the character, peeking doesn't get the actual
// one.
nc = safe_vgetc();
if (c == nc)
continue;
vungetc(nc);
mouse_row = save_mouse_row;
mouse_col = save_mouse_col;
}
}
break;
}
if (c == K_MOUSEMOVE)
{
// Mouse moved without a button pressed.
#ifdef FEAT_BEVAL_TERM
ui_may_remove_balloon();
if (p_bevalterm)
{
profile_setlimit(p_bdlay, &bevalexpr_due);
bevalexpr_due_set = TRUE;
}
#endif
#ifdef FEAT_PROP_POPUP
popup_handle_mouse_moved();
#endif
return FALSE;
}
#ifdef FEAT_MOUSESHAPE
// May have stopped dragging the status or separator line. The pointer is
// most likely still on the status or separator line.
if (!is_drag && drag_status_line)
{
drag_status_line = FALSE;
update_mouseshape(SHAPE_IDX_STATUS);
}
if (!is_drag && drag_sep_line)
{
drag_sep_line = FALSE;
update_mouseshape(SHAPE_IDX_VSEP);
}
#endif
// Ignore drag and release events if we didn't get a click.
if (is_click)
got_click = TRUE;
else
{
if (!got_click) // didn't get click, ignore
return FALSE;
if (!is_drag) // release, reset got_click
{
got_click = FALSE;
if (in_tab_line)
{
in_tab_line = FALSE;
return FALSE;
}
}
}
// CTRL right mouse button does CTRL-T
if (is_click && (mod_mask & MOD_MASK_CTRL) && which_button == MOUSE_RIGHT)
{
if (State & MODE_INSERT)
stuffcharReadbuff(Ctrl_O);
if (count > 1)
stuffnumReadbuff(count);
stuffcharReadbuff(Ctrl_T);
got_click = FALSE; // ignore drag&release now
return FALSE;
}
// CTRL only works with left mouse button
if ((mod_mask & MOD_MASK_CTRL) && which_button != MOUSE_LEFT)
return FALSE;
// When a modifier is down, ignore drag and release events, as well as
// multiple clicks and the middle mouse button.
// Accept shift-leftmouse drags when 'mousemodel' is "popup.*".
if ((mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT
| MOD_MASK_META))
&& (!is_click
|| (mod_mask & MOD_MASK_MULTI_CLICK)
|| which_button == MOUSE_MIDDLE)
&& !((mod_mask & (MOD_MASK_SHIFT|MOD_MASK_ALT))
&& mouse_model_popup()
&& which_button == MOUSE_LEFT)
&& !((mod_mask & MOD_MASK_ALT)
&& !mouse_model_popup()
&& which_button == MOUSE_RIGHT)
)
return FALSE;
// If the button press was used as the movement command for an operator
// (eg "d<MOUSE>"), or it is the middle button that is held down, ignore
// drag/release events.
if (!is_click && which_button == MOUSE_MIDDLE)
return FALSE;
if (oap != NULL)
regname = oap->regname;
else
regname = 0;
// Middle mouse button does a 'put' of the selected text
if (which_button == MOUSE_MIDDLE)
{
if (State == MODE_NORMAL)
{
// If an operator was pending, we don't know what the user wanted
// to do. Go back to normal mode: Clear the operator and beep().
if (oap != NULL && oap->op_type != OP_NOP)
{
clearopbeep(oap);
return FALSE;
}
// If visual was active, yank the highlighted text and put it
// before the mouse pointer position.
// In Select mode replace the highlighted text with the clipboard.
if (VIsual_active)
{
if (VIsual_select)
{
stuffcharReadbuff(Ctrl_G);
stuffReadbuff((char_u *)"\"+p");
}
else
{
stuffcharReadbuff('y');
stuffcharReadbuff(K_MIDDLEMOUSE);
}
do_always = TRUE; // ignore 'mouse' setting next time
return FALSE;
}
// The rest is below jump_to_mouse()
}
else if ((State & MODE_INSERT) == 0)
return FALSE;
// Middle click in insert mode doesn't move the mouse, just insert the
// contents of a register. '.' register is special, can't insert that
// with do_put().
// Also paste at the cursor if the current mode isn't in 'mouse' (only
// happens for the GUI).
if ((State & MODE_INSERT) || !mouse_has(MOUSE_NORMAL))
{
if (regname == '.')
insert_reg(regname, TRUE);
else
{
#ifdef FEAT_CLIPBOARD
if (clip_star.available && regname == 0)
regname = '*';
#endif
if ((State & REPLACE_FLAG) && !yank_register_mline(regname))
insert_reg(regname, TRUE);
else
{
do_put(regname, NULL, BACKWARD, 1L,
fixindent | PUT_CURSEND);
// Repeat it with CTRL-R CTRL-O r or CTRL-R CTRL-P r
AppendCharToRedobuff(Ctrl_R);
AppendCharToRedobuff(fixindent ? Ctrl_P : Ctrl_O);
AppendCharToRedobuff(regname == 0 ? '"' : regname);
}
}
return FALSE;
}
}
// When dragging or button-up stay in the same window.
if (!is_click)
jump_flags |= MOUSE_FOCUS | MOUSE_DID_MOVE;
start_visual.lnum = 0;
// Check for clicking in the tab page line.
if (mouse_row == 0 && firstwin->w_winrow > 0)
{
if (is_drag)
{
if (in_tab_line)
{
c1 = TabPageIdxs[mouse_col];
tabpage_move(c1 <= 0 ? 9999 : c1 < tabpage_index(curtab)
? c1 - 1 : c1);
}
return FALSE;
}
// click in a tab selects that tab page
if (is_click
# ifdef FEAT_CMDWIN
&& cmdwin_type == 0
# endif
&& mouse_col < Columns)
{
in_tab_line = TRUE;
c1 = TabPageIdxs[mouse_col];
if (c1 >= 0)
{
if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)
{
// double click opens new page
end_visual_mode_keep_button();
tabpage_new();
tabpage_move(c1 == 0 ? 9999 : c1 - 1);
}
else
{
// Go to specified tab page, or next one if not clicking
// on a label.
goto_tabpage(c1);
// It's like clicking on the status line of a window.
if (curwin != old_curwin)
end_visual_mode_keep_button();
}
}
else
{
tabpage_T *tp;
// Close the current or specified tab page.
if (c1 == -999)
tp = curtab;
else
tp = find_tabpage(-c1);
if (tp == curtab)
{
if (first_tabpage->tp_next != NULL)
tabpage_close(FALSE);
}
else if (tp != NULL)
tabpage_close_other(tp, FALSE);
}
}
return TRUE;
}
else if (is_drag && in_tab_line)
{
c1 = TabPageIdxs[mouse_col];
tabpage_move(c1 <= 0 ? 9999 : c1 - 1);
return FALSE;
}
// When 'mousemodel' is "popup" or "popup_setpos", translate mouse events:
// right button up -> pop-up menu
// shift-left button -> right button
// alt-left button -> alt-right button
if (mouse_model_popup())
{
if (which_button == MOUSE_RIGHT
&& !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)))
{
#ifdef USE_POPUP_SETPOS
# ifdef FEAT_GUI
if (gui.in_use)
{
# if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \
|| defined(FEAT_GUI_PHOTON)
if (!is_click)
// Ignore right button release events, only shows the popup
// menu on the button down event.
return FALSE;
# endif
# if defined(FEAT_GUI_MSWIN) || defined(FEAT_GUI_HAIKU)
if (is_click || is_drag)
// Ignore right button down and drag mouse events. Windows
// only shows the popup menu on the button up event.
return FALSE;
# endif
}
# endif
# if defined(FEAT_GUI) && defined(FEAT_TERM_POPUP_MENU)
else
# endif
# if defined(FEAT_TERM_POPUP_MENU)
if (!is_click)
// Ignore right button release events, only shows the popup
// menu on the button down event.
return FALSE;
#endif
jump_flags = 0;
if (STRCMP(p_mousem, "popup_setpos") == 0)
{
// First set the cursor position before showing the popup
// menu.
if (VIsual_active)
{
pos_T m_pos;
// set MOUSE_MAY_STOP_VIS if we are outside the
// selection or the current window (might have false
// negative here)
if (mouse_row < curwin->w_winrow
|| mouse_row
> (curwin->w_winrow + curwin->w_height))
jump_flags = MOUSE_MAY_STOP_VIS;
else if (get_fpos_of_mouse(&m_pos) != IN_BUFFER)
jump_flags = MOUSE_MAY_STOP_VIS;
else
{
if ((LT_POS(curwin->w_cursor, VIsual)
&& (LT_POS(m_pos, curwin->w_cursor)
|| LT_POS(VIsual, m_pos)))
|| (LT_POS(VIsual, curwin->w_cursor)
&& (LT_POS(m_pos, VIsual)
|| LT_POS(curwin->w_cursor, m_pos))))
{
jump_flags = MOUSE_MAY_STOP_VIS;
}
else if (VIsual_mode == Ctrl_V)
{
getvcols(curwin, &curwin->w_cursor, &VIsual,
&leftcol, &rightcol);
getvcol(curwin, &m_pos, NULL, &m_pos.col, NULL);
if (m_pos.col < leftcol || m_pos.col > rightcol)
jump_flags = MOUSE_MAY_STOP_VIS;
}
}
}
else
jump_flags = MOUSE_MAY_STOP_VIS;
}
if (jump_flags)
{
jump_flags = jump_to_mouse(jump_flags, NULL, which_button);
update_curbuf(VIsual_active ? UPD_INVERTED : UPD_VALID);
setcursor();
out_flush(); // Update before showing popup menu
}
# ifdef FEAT_MENU
show_popupmenu();
got_click = FALSE; // ignore release events
# endif
return (jump_flags & CURSOR_MOVED) != 0;
#else
return FALSE;
#endif
}
if (which_button == MOUSE_LEFT
&& (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_ALT)))
{
which_button = MOUSE_RIGHT;
mod_mask &= ~MOD_MASK_SHIFT;
}
}
if ((State & (MODE_NORMAL | MODE_INSERT))
&& !(mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)))
{
if (which_button == MOUSE_LEFT)
{
if (is_click)
{
// stop Visual mode for a left click in a window, but not when
// on a status line
if (VIsual_active)
jump_flags |= MOUSE_MAY_STOP_VIS;
}
else if (mouse_has(MOUSE_VISUAL))
jump_flags |= MOUSE_MAY_VIS;
}
else if (which_button == MOUSE_RIGHT)
{
if (is_click && VIsual_active)
{
// Remember the start and end of visual before moving the
// cursor.
if (LT_POS(curwin->w_cursor, VIsual))
{
start_visual = curwin->w_cursor;
end_visual = VIsual;
}
else
{
start_visual = VIsual;
end_visual = curwin->w_cursor;
}
}
jump_flags |= MOUSE_FOCUS;
if (mouse_has(MOUSE_VISUAL))
jump_flags |= MOUSE_MAY_VIS;
}
}
// If an operator is pending, ignore all drags and releases until the
// next mouse click.
if (!is_drag && oap != NULL && oap->op_type != OP_NOP)
{
got_click = FALSE;
oap->motion_type = MCHAR;
}
// When releasing the button let jump_to_mouse() know.
if (!is_click && !is_drag)
jump_flags |= MOUSE_RELEASED;
// JUMP!
jump_flags = jump_to_mouse(jump_flags,
oap == NULL ? NULL : &(oap->inclusive), which_button);
#ifdef FEAT_MENU
// A click in the window toolbar has no side effects.
if (jump_flags & MOUSE_WINBAR)
return FALSE;
#endif
moved = (jump_flags & CURSOR_MOVED);
in_status_line = (jump_flags & IN_STATUS_LINE);
in_sep_line = (jump_flags & IN_SEP_LINE);
#ifdef FEAT_NETBEANS_INTG
if (isNetbeansBuffer(curbuf)
&& !(jump_flags & (IN_STATUS_LINE | IN_SEP_LINE)))
{
int key = KEY2TERMCAP1(c);
if (key == (int)KE_LEFTRELEASE || key == (int)KE_MIDDLERELEASE
|| key == (int)KE_RIGHTRELEASE)
netbeans_button_release(which_button);
}
#endif
// When jumping to another window, clear a pending operator. That's a bit
// friendlier than beeping and not jumping to that window.
if (curwin != old_curwin && oap != NULL && oap->op_type != OP_NOP)
clearop(oap);
#ifdef FEAT_FOLDING
if (mod_mask == 0
&& !is_drag
&& (jump_flags & (MOUSE_FOLD_CLOSE | MOUSE_FOLD_OPEN))
&& which_button == MOUSE_LEFT)
{
// open or close a fold at this line
if (jump_flags & MOUSE_FOLD_OPEN)
openFold(curwin->w_cursor.lnum, 1L);
else
closeFold(curwin->w_cursor.lnum, 1L);
// don't move the cursor if still in the same window
if (curwin == old_curwin)
curwin->w_cursor = save_cursor;
}
#endif
#if defined(FEAT_CLIPBOARD) && defined(FEAT_CMDWIN)
if ((jump_flags & IN_OTHER_WIN) && !VIsual_active && clip_star.available)
{
clip_modeless(which_button, is_click, is_drag);
return FALSE;
}
#endif
// Set global flag that we are extending the Visual area with mouse
// dragging; temporarily minimize 'scrolloff'.
if (VIsual_active && is_drag && get_scrolloff_value())
{
// In the very first line, allow scrolling one line
if (mouse_row == 0)
mouse_dragging = 2;
else
mouse_dragging = 1;
}
// When dragging the mouse above the window, scroll down.
if (is_drag && mouse_row < 0 && !in_status_line)
{
scroll_redraw(FALSE, 1L);
mouse_row = 0;
}
if (start_visual.lnum) // right click in visual mode
{
// When ALT is pressed make Visual mode blockwise.
if (mod_mask & MOD_MASK_ALT)
VIsual_mode = Ctrl_V;
// In Visual-block mode, divide the area in four, pick up the corner
// that is in the quarter that the cursor is in.
if (VIsual_mode == Ctrl_V)
{
getvcols(curwin, &start_visual, &end_visual, &leftcol, &rightcol);
if (curwin->w_curswant > (leftcol + rightcol) / 2)
end_visual.col = leftcol;
else
end_visual.col = rightcol;
if (curwin->w_cursor.lnum >=
(start_visual.lnum + end_visual.lnum) / 2)
end_visual.lnum = start_visual.lnum;
// move VIsual to the right column
start_visual = curwin->w_cursor; // save the cursor pos
curwin->w_cursor = end_visual;
coladvance(end_visual.col);
VIsual = curwin->w_cursor;
curwin->w_cursor = start_visual; // restore the cursor
}
else
{
// If the click is before the start of visual, change the start.
// If the click is after the end of visual, change the end. If
// the click is inside the visual, change the closest side.
if (LT_POS(curwin->w_cursor, start_visual))
VIsual = end_visual;
else if (LT_POS(end_visual, curwin->w_cursor))
VIsual = start_visual;
else
{
// In the same line, compare column number
if (end_visual.lnum == start_visual.lnum)
{
if (curwin->w_cursor.col - start_visual.col >
end_visual.col - curwin->w_cursor.col)
VIsual = start_visual;
else
VIsual = end_visual;
}
// In different lines, compare line number
else
{
diff = (curwin->w_cursor.lnum - start_visual.lnum) -
(end_visual.lnum - curwin->w_cursor.lnum);
if (diff > 0) // closest to end
VIsual = start_visual;
else if (diff < 0) // closest to start
VIsual = end_visual;
else // in the middle line
{
if (curwin->w_cursor.col <
(start_visual.col + end_visual.col) / 2)
VIsual = end_visual;
else
VIsual = start_visual;
}
}
}
}
}
// If Visual mode started in insert mode, execute "CTRL-O"
else if ((State & MODE_INSERT) && VIsual_active)
stuffcharReadbuff(Ctrl_O);
// Middle mouse click: Put text before cursor.
if (which_button == MOUSE_MIDDLE)
{
#ifdef FEAT_CLIPBOARD
if (clip_star.available && regname == 0)
regname = '*';
#endif
if (yank_register_mline(regname))
{
if (mouse_past_bottom)
dir = FORWARD;
}
else if (mouse_past_eol)
dir = FORWARD;
if (fixindent)
{
c1 = (dir == BACKWARD) ? '[' : ']';
c2 = 'p';
}
else
{
c1 = (dir == FORWARD) ? 'p' : 'P';
c2 = NUL;
}
prep_redo(regname, count, NUL, c1, NUL, c2, NUL);
// Remember where the paste started, so in edit() Insstart can be set
// to this position
if (restart_edit != 0)
where_paste_started = curwin->w_cursor;
do_put(regname, NULL, dir, count, fixindent | PUT_CURSEND);
}
#if defined(FEAT_QUICKFIX)
// Ctrl-Mouse click or double click in a quickfix window jumps to the
// error under the mouse pointer.
else if (((mod_mask & MOD_MASK_CTRL)
|| (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)
&& bt_quickfix(curbuf))
{
if (curwin->w_llist_ref == NULL) // quickfix window
do_cmdline_cmd((char_u *)".cc");
else // location list window
do_cmdline_cmd((char_u *)".ll");
got_click = FALSE; // ignore drag&release now
}
#endif
// Ctrl-Mouse click (or double click in a help window) jumps to the tag
// under the mouse pointer.
else if ((mod_mask & MOD_MASK_CTRL) || (curbuf->b_help
&& (mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK))
{
if (State & MODE_INSERT)
stuffcharReadbuff(Ctrl_O);
stuffcharReadbuff(Ctrl_RSB);
got_click = FALSE; // ignore drag&release now
}
// Shift-Mouse click searches for the next occurrence of the word under
// the mouse pointer
else if ((mod_mask & MOD_MASK_SHIFT))
{
if ((State & MODE_INSERT) || (VIsual_active && VIsual_select))
stuffcharReadbuff(Ctrl_O);
if (which_button == MOUSE_LEFT)
stuffcharReadbuff('*');
else // MOUSE_RIGHT
stuffcharReadbuff('#');
}
// Handle double clicks, unless on status line
else if (in_status_line)
{
#ifdef FEAT_MOUSESHAPE
if ((is_drag || is_click) && !drag_status_line)
{
drag_status_line = TRUE;
update_mouseshape(-1);
}
#endif
}
else if (in_sep_line)
{
#ifdef FEAT_MOUSESHAPE
if ((is_drag || is_click) && !drag_sep_line)
{
drag_sep_line = TRUE;
update_mouseshape(-1);
}
#endif
}
else if ((mod_mask & MOD_MASK_MULTI_CLICK)
&& (State & (MODE_NORMAL | MODE_INSERT))
&& mouse_has(MOUSE_VISUAL))
{
if (is_click || !VIsual_active)
{
if (VIsual_active)
orig_cursor = VIsual;
else
{
check_visual_highlight();
VIsual = curwin->w_cursor;
orig_cursor = VIsual;
VIsual_active = TRUE;
VIsual_reselect = TRUE;
// start Select mode if 'selectmode' contains "mouse"
may_start_select('o');
setmouse();
}
if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)
{
// Double click with ALT pressed makes it blockwise.
if (mod_mask & MOD_MASK_ALT)
VIsual_mode = Ctrl_V;
else
VIsual_mode = 'v';
}
else if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_3CLICK)
VIsual_mode = 'V';
else if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_4CLICK)
VIsual_mode = Ctrl_V;
#ifdef FEAT_CLIPBOARD
// Make sure the clipboard gets updated. Needed because start and
// end may still be the same, and the selection needs to be owned
clip_star.vmode = NUL;
#endif
}
// A double click selects a word or a block.
if ((mod_mask & MOD_MASK_MULTI_CLICK) == MOD_MASK_2CLICK)
{
pos_T *pos = NULL;
int gc;
if (is_click)
{
// If the character under the cursor (skipping white space) is
// not a word character, try finding a match and select a (),
// {}, [], #if/#endif, etc. block.
end_visual = curwin->w_cursor;
while (gc = gchar_pos(&end_visual), VIM_ISWHITE(gc))
inc(&end_visual);
if (oap != NULL)
oap->motion_type = MCHAR;
if (oap != NULL
&& VIsual_mode == 'v'
&& !vim_iswordc(gchar_pos(&end_visual))
&& EQUAL_POS(curwin->w_cursor, VIsual)
&& (pos = findmatch(oap, NUL)) != NULL)
{
curwin->w_cursor = *pos;
if (oap->motion_type == MLINE)
VIsual_mode = 'V';
else if (*p_sel == 'e')
{
if (LT_POS(curwin->w_cursor, VIsual))
++VIsual.col;
else
++curwin->w_cursor.col;
}
}
}
if (pos == NULL && (is_click || is_drag))
{
// When not found a match or when dragging: extend to include
// a word.
if (LT_POS(curwin->w_cursor, orig_cursor))
{
find_start_of_word(&curwin->w_cursor);
find_end_of_word(&VIsual);
}
else
{
find_start_of_word(&VIsual);
if (*p_sel == 'e' && *ml_get_cursor() != NUL)
curwin->w_cursor.col +=
(*mb_ptr2len)(ml_get_cursor());
find_end_of_word(&curwin->w_cursor);
}
}
curwin->w_set_curswant = TRUE;
}
if (is_click)
redraw_curbuf_later(UPD_INVERTED); // update the inversion
}
else if (VIsual_active && !old_active)
{
if (mod_mask & MOD_MASK_ALT)
VIsual_mode = Ctrl_V;
else
VIsual_mode = 'v';
}
// If Visual mode changed show it later.
if ((!VIsual_active && old_active && mode_displayed)
|| (VIsual_active && p_smd && msg_silent == 0
&& (!old_active || VIsual_mode != old_mode)))
redraw_cmdline = TRUE;
return moved;
}
| 1
|
387,621
|
static int snd_ctl_elem_info(struct snd_ctl_file *ctl,
struct snd_ctl_elem_info *info)
{
struct snd_card *card = ctl->card;
struct snd_kcontrol *kctl;
int result;
down_read(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, &info->id);
if (kctl == NULL)
result = -ENOENT;
else
result = __snd_ctl_elem_info(card, kctl, info, ctl);
up_read(&card->controls_rwsem);
return result;
}
| 0
|
369,310
|
static int io_mkdirat(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_mkdir *mkd = &req->mkdir;
int ret;
if (issue_flags & IO_URING_F_NONBLOCK)
return -EAGAIN;
ret = do_mkdirat(mkd->dfd, mkd->filename, mkd->mode);
req->flags &= ~REQ_F_NEED_CLEANUP;
if (ret < 0)
req_set_fail(req);
io_req_complete(req, ret);
return 0;
}
| 0
|
452,388
|
static MagickBooleanType WriteGROUP4Image(const ImageInfo *image_info,
Image *image)
{
char
filename[MaxTextExtent];
FILE
*file;
Image
*huffman_image;
ImageInfo
*write_info;
int
unique_file;
MagickBooleanType
status;
ssize_t
i;
ssize_t
count;
TIFF
*tiff;
toff_t
*byte_count,
strip_size;
unsigned char
*buffer;
/*
Write image as CCITT Group4 TIFF image to a temporary file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (IsEventLogging() != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
if (status == MagickFalse)
return(status);
huffman_image=CloneImage(image,0,0,MagickTrue,&image->exception);
if (huffman_image == (Image *) NULL)
{
(void) CloseBlob(image);
return(MagickFalse);
}
huffman_image->endian=MSBEndian;
file=(FILE *) NULL;
unique_file=AcquireUniqueFileResource(filename);
if (unique_file != -1)
file=fdopen(unique_file,"wb");
if ((unique_file == -1) || (file == (FILE *) NULL))
{
ThrowFileException(&image->exception,FileOpenError,
"UnableToCreateTemporaryFile",filename);
return(MagickFalse);
}
(void) FormatLocaleString(huffman_image->filename,MaxTextExtent,"tiff:%s",
filename);
if (IsMonochromeImage(image,&image->exception) != MagickFalse)
(void) SetImageType(huffman_image,BilevelType);
write_info=CloneImageInfo((ImageInfo *) NULL);
SetImageInfoFile(write_info,file);
if (IsMonochromeImage(image,&image->exception) == MagickFalse)
(void) SetImageType(image,BilevelType);
(void) SetImageDepth(image,1);
write_info->compression=Group4Compression;
write_info->type=BilevelType;
status=WriteTIFFImage(write_info,huffman_image);
(void) fflush(file);
write_info=DestroyImageInfo(write_info);
if (status == MagickFalse)
{
InheritException(&image->exception,&huffman_image->exception);
huffman_image=DestroyImage(huffman_image);
(void) fclose(file);
(void) RelinquishUniqueFileResource(filename);
return(MagickFalse);
}
tiff=TIFFOpen(filename,"rb");
if (tiff == (TIFF *) NULL)
{
huffman_image=DestroyImage(huffman_image);
(void) fclose(file);
(void) RelinquishUniqueFileResource(filename);
ThrowFileException(&image->exception,FileOpenError,"UnableToOpenFile",
image_info->filename);
return(MagickFalse);
}
/*
Allocate raw strip buffer.
*/
if (TIFFGetField(tiff,TIFFTAG_STRIPBYTECOUNTS,&byte_count) != 1)
{
TIFFClose(tiff);
huffman_image=DestroyImage(huffman_image);
(void) fclose(file);
(void) RelinquishUniqueFileResource(filename);
return(MagickFalse);
}
strip_size=byte_count[0];
for (i=1; i < (ssize_t) TIFFNumberOfStrips(tiff); i++)
if (byte_count[i] > strip_size)
strip_size=byte_count[i];
buffer=(unsigned char *) AcquireQuantumMemory((size_t) strip_size,
sizeof(*buffer));
if (buffer == (unsigned char *) NULL)
{
TIFFClose(tiff);
huffman_image=DestroyImage(huffman_image);
(void) fclose(file);
(void) RelinquishUniqueFileResource(filename);
ThrowBinaryImageException(ResourceLimitError,"MemoryAllocationFailed",
image_info->filename);
}
/*
Compress runlength encoded to 2D Huffman pixels.
*/
for (i=0; i < (ssize_t) TIFFNumberOfStrips(tiff); i++)
{
count=(ssize_t) TIFFReadRawStrip(tiff,(uint32) i,buffer,strip_size);
if (WriteBlob(image,(size_t) count,buffer) != count)
status=MagickFalse;
}
buffer=(unsigned char *) RelinquishMagickMemory(buffer);
TIFFClose(tiff);
huffman_image=DestroyImage(huffman_image);
(void) fclose(file);
(void) RelinquishUniqueFileResource(filename);
(void) CloseBlob(image);
return(status);
}
| 0
|
507,780
|
ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group,
ECPARAMETERS *params)
{
size_t len = 0;
ECPARAMETERS *ret = NULL;
const BIGNUM *tmp;
unsigned char *buffer = NULL;
const EC_POINT *point = NULL;
point_conversion_form_t form;
ASN1_INTEGER *orig;
if (params == NULL) {
if ((ret = ECPARAMETERS_new()) == NULL) {
ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_MALLOC_FAILURE);
goto err;
}
} else
ret = params;
/* set the version (always one) */
ret->version = (long)0x1;
/* set the fieldID */
if (!ec_asn1_group2fieldid(group, ret->fieldID)) {
ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_EC_LIB);
goto err;
}
/* set the curve */
if (!ec_asn1_group2curve(group, ret->curve)) {
ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_EC_LIB);
goto err;
}
/* set the base point */
if ((point = EC_GROUP_get0_generator(group)) == NULL) {
ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, EC_R_UNDEFINED_GENERATOR);
goto err;
}
form = EC_GROUP_get_point_conversion_form(group);
len = EC_POINT_point2buf(group, point, form, &buffer, NULL);
if (len == 0) {
ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_EC_LIB);
goto err;
}
if (ret->base == NULL && (ret->base = ASN1_OCTET_STRING_new()) == NULL) {
OPENSSL_free(buffer);
ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_MALLOC_FAILURE);
goto err;
}
ASN1_STRING_set0(ret->base, buffer, len);
/* set the order */
tmp = EC_GROUP_get0_order(group);
if (tmp == NULL) {
ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_EC_LIB);
goto err;
}
ret->order = BN_to_ASN1_INTEGER(tmp, orig = ret->order);
if (ret->order == NULL) {
ret->order = orig;
ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_ASN1_LIB);
goto err;
}
/* set the cofactor (optional) */
tmp = EC_GROUP_get0_cofactor(group);
if (tmp != NULL) {
ret->cofactor = BN_to_ASN1_INTEGER(tmp, orig = ret->cofactor);
if (ret->cofactor == NULL) {
ret->cofactor = orig;
ECerr(EC_F_EC_GROUP_GET_ECPARAMETERS, ERR_R_ASN1_LIB);
goto err;
}
}
return ret;
err:
if (params == NULL)
ECPARAMETERS_free(ret);
return NULL;
}
| 0
|
289,317
|
static int _snd_pcm_hw_param_min(struct snd_pcm_hw_params *params,
snd_pcm_hw_param_t var, unsigned int val,
int dir)
{
int changed;
int open = 0;
if (dir) {
if (dir > 0) {
open = 1;
} else if (dir < 0) {
if (val > 0) {
open = 1;
val--;
}
}
}
if (hw_is_mask(var))
changed = snd_mask_refine_min(hw_param_mask(params, var),
val + !!open);
else if (hw_is_interval(var))
changed = snd_interval_refine_min(hw_param_interval(params, var),
val, open);
else
return -EINVAL;
if (changed > 0) {
params->cmask |= 1 << var;
params->rmask |= 1 << var;
}
return changed;
}
| 0
|
384,812
|
byte2cells(int b)
{
if (enc_utf8 && b >= 0x80)
return 0;
return (g_chartab[b] & CT_CELL_MASK);
}
| 0
|
522,362
|
int GmfGotoKwd(int64_t MshIdx, int KwdCod)
{
GmfMshSct *msh = (GmfMshSct *)MshIdx;
KwdSct *kwd = &msh->KwdTab[ KwdCod ];
if( (KwdCod < 1) || (KwdCod > GmfMaxKwd) || !kwd->NmbLin )
return(0);
return(SetFilPos(msh, kwd->pos));
}
| 0
|
227,031
|
irc_protocol_recv_command (struct t_irc_server *server,
const char *irc_message,
const char *msg_command,
const char *msg_channel)
{
int i, cmd_found, return_code, argc, decode_color, keep_trailing_spaces;
int message_ignored, flags;
char *message_colors_decoded, *pos_space, *tags;
struct t_irc_channel *ptr_channel;
t_irc_recv_func *cmd_recv_func;
const char *cmd_name, *ptr_msg_after_tags;
time_t date;
const char *nick1, *address1, *host1;
char *nick, *address, *address_color, *host, *host_no_color, *host_color;
char **argv, **argv_eol;
struct t_hashtable *hash_tags;
struct t_irc_protocol_msg irc_protocol_messages[] =
{ { "account", /* account (cap account-notify) */ 1, 0, &irc_protocol_cb_account },
{ "authenticate", /* authenticate */ 1, 0, &irc_protocol_cb_authenticate },
{ "away", /* away (cap away-notify) */ 1, 0, &irc_protocol_cb_away },
{ "cap", /* client capability */ 1, 0, &irc_protocol_cb_cap },
{ "chghost", /* user/host change (cap chghost) */ 1, 0, &irc_protocol_cb_chghost },
{ "error", /* error received from IRC server */ 1, 0, &irc_protocol_cb_error },
{ "invite", /* invite a nick on a channel */ 1, 0, &irc_protocol_cb_invite },
{ "join", /* join a channel */ 1, 0, &irc_protocol_cb_join },
{ "kick", /* forcibly remove a user from a channel */ 1, 1, &irc_protocol_cb_kick },
{ "kill", /* close client-server connection */ 1, 1, &irc_protocol_cb_kill },
{ "mode", /* change channel or user mode */ 1, 0, &irc_protocol_cb_mode },
{ "nick", /* change current nickname */ 1, 0, &irc_protocol_cb_nick },
{ "notice", /* send notice message to user */ 1, 1, &irc_protocol_cb_notice },
{ "part", /* leave a channel */ 1, 1, &irc_protocol_cb_part },
{ "ping", /* ping server */ 1, 0, &irc_protocol_cb_ping },
{ "pong", /* answer to a ping message */ 1, 0, &irc_protocol_cb_pong },
{ "privmsg", /* message received */ 1, 1, &irc_protocol_cb_privmsg },
{ "quit", /* close all connections and quit */ 1, 1, &irc_protocol_cb_quit },
{ "topic", /* get/set channel topic */ 0, 1, &irc_protocol_cb_topic },
{ "wallops", /* send a message to all currently connected users who have "
"set the 'w' user mode "
"for themselves */ 1, 1, &irc_protocol_cb_wallops },
{ "001", /* a server message */ 1, 0, &irc_protocol_cb_001 },
{ "005", /* a server message */ 1, 0, &irc_protocol_cb_005 },
{ "008", /* server notice mask */ 1, 0, &irc_protocol_cb_008 },
{ "221", /* user mode string */ 1, 0, &irc_protocol_cb_221 },
{ "223", /* whois (charset is) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "264", /* whois (is using encrypted connection) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "275", /* whois (secure connection) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "276", /* whois (has client certificate fingerprint) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "301", /* away message */ 1, 1, &irc_protocol_cb_301 },
{ "303", /* ison */ 1, 0, &irc_protocol_cb_303 },
{ "305", /* unaway */ 1, 0, &irc_protocol_cb_305 },
{ "306", /* now away */ 1, 0, &irc_protocol_cb_306 },
{ "307", /* whois (registered nick) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "310", /* whois (help mode) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "311", /* whois (user) */ 1, 0, &irc_protocol_cb_311 },
{ "312", /* whois (server) */ 1, 0, &irc_protocol_cb_312 },
{ "313", /* whois (operator) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "314", /* whowas */ 1, 0, &irc_protocol_cb_314 },
{ "315", /* end of /who list */ 1, 0, &irc_protocol_cb_315 },
{ "317", /* whois (idle) */ 1, 0, &irc_protocol_cb_317 },
{ "318", /* whois (end) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "319", /* whois (channels) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "320", /* whois (identified user) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "321", /* /list start */ 1, 0, &irc_protocol_cb_321 },
{ "322", /* channel (for /list) */ 1, 0, &irc_protocol_cb_322 },
{ "323", /* end of /list */ 1, 0, &irc_protocol_cb_323 },
{ "324", /* channel mode */ 1, 0, &irc_protocol_cb_324 },
{ "326", /* whois (has oper privs) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "327", /* whois (host) */ 1, 0, &irc_protocol_cb_327 },
{ "328", /* channel url */ 1, 0, &irc_protocol_cb_328 },
{ "329", /* channel creation date */ 1, 0, &irc_protocol_cb_329 },
{ "330", /* is logged in as */ 1, 0, &irc_protocol_cb_330_343 },
{ "331", /* no topic for channel */ 1, 0, &irc_protocol_cb_331 },
{ "332", /* topic of channel */ 0, 1, &irc_protocol_cb_332 },
{ "333", /* infos about topic (nick and date changed) */ 1, 0, &irc_protocol_cb_333 },
{ "335", /* is a bot on */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "338", /* whois (host) */ 1, 0, &irc_protocol_cb_338 },
{ "341", /* inviting */ 1, 0, &irc_protocol_cb_341 },
{ "343", /* is opered as */ 1, 0, &irc_protocol_cb_330_343 },
{ "344", /* channel reop */ 1, 0, &irc_protocol_cb_344 },
{ "345", /* end of channel reop list */ 1, 0, &irc_protocol_cb_345 },
{ "346", /* invite list */ 1, 0, &irc_protocol_cb_346 },
{ "347", /* end of invite list */ 1, 0, &irc_protocol_cb_347 },
{ "348", /* channel exception list */ 1, 0, &irc_protocol_cb_348 },
{ "349", /* end of channel exception list */ 1, 0, &irc_protocol_cb_349 },
{ "351", /* server version */ 1, 0, &irc_protocol_cb_351 },
{ "352", /* who */ 1, 0, &irc_protocol_cb_352 },
{ "353", /* list of nicks on channel */ 1, 0, &irc_protocol_cb_353 },
{ "354", /* whox */ 1, 0, &irc_protocol_cb_354 },
{ "366", /* end of /names list */ 1, 0, &irc_protocol_cb_366 },
{ "367", /* banlist */ 1, 0, &irc_protocol_cb_367 },
{ "368", /* end of banlist */ 1, 0, &irc_protocol_cb_368 },
{ "369", /* whowas (end) */ 1, 0, &irc_protocol_cb_whowas_nick_msg },
{ "378", /* whois (connecting from) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "379", /* whois (using modes) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "401", /* no such nick/channel */ 1, 0, &irc_protocol_cb_generic_error },
{ "402", /* no such server */ 1, 0, &irc_protocol_cb_generic_error },
{ "403", /* no such channel */ 1, 0, &irc_protocol_cb_generic_error },
{ "404", /* cannot send to channel */ 1, 0, &irc_protocol_cb_generic_error },
{ "405", /* too many channels */ 1, 0, &irc_protocol_cb_generic_error },
{ "406", /* was no such nick */ 1, 0, &irc_protocol_cb_generic_error },
{ "407", /* was no such nick */ 1, 0, &irc_protocol_cb_generic_error },
{ "409", /* no origin */ 1, 0, &irc_protocol_cb_generic_error },
{ "410", /* no services */ 1, 0, &irc_protocol_cb_generic_error },
{ "411", /* no recipient */ 1, 0, &irc_protocol_cb_generic_error },
{ "412", /* no text to send */ 1, 0, &irc_protocol_cb_generic_error },
{ "413", /* no toplevel */ 1, 0, &irc_protocol_cb_generic_error },
{ "414", /* wilcard in toplevel domain */ 1, 0, &irc_protocol_cb_generic_error },
{ "421", /* unknown command */ 1, 0, &irc_protocol_cb_generic_error },
{ "422", /* MOTD is missing */ 1, 0, &irc_protocol_cb_generic_error },
{ "423", /* no administrative info */ 1, 0, &irc_protocol_cb_generic_error },
{ "424", /* file error */ 1, 0, &irc_protocol_cb_generic_error },
{ "431", /* no nickname given */ 1, 0, &irc_protocol_cb_generic_error },
{ "432", /* erroneous nickname */ 1, 0, &irc_protocol_cb_432 },
{ "433", /* nickname already in use */ 1, 0, &irc_protocol_cb_433 },
{ "436", /* nickname collision */ 1, 0, &irc_protocol_cb_generic_error },
{ "437", /* nick/channel unavailable */ 1, 0, &irc_protocol_cb_437 },
{ "438", /* not authorized to change nickname */ 1, 0, &irc_protocol_cb_438 },
{ "441", /* user not in channel */ 1, 0, &irc_protocol_cb_generic_error },
{ "442", /* not on channel */ 1, 0, &irc_protocol_cb_generic_error },
{ "443", /* user already on channel */ 1, 0, &irc_protocol_cb_generic_error },
{ "444", /* user not logged in */ 1, 0, &irc_protocol_cb_generic_error },
{ "445", /* summon has been disabled */ 1, 0, &irc_protocol_cb_generic_error },
{ "446", /* users has been disabled */ 1, 0, &irc_protocol_cb_generic_error },
{ "451", /* you are not registered */ 1, 0, &irc_protocol_cb_generic_error },
{ "461", /* not enough parameters */ 1, 0, &irc_protocol_cb_generic_error },
{ "462", /* you may not register */ 1, 0, &irc_protocol_cb_generic_error },
{ "463", /* your host isn't among the privileged */ 1, 0, &irc_protocol_cb_generic_error },
{ "464", /* password incorrect */ 1, 0, &irc_protocol_cb_generic_error },
{ "465", /* you are banned from this server */ 1, 0, &irc_protocol_cb_generic_error },
{ "467", /* channel key already set */ 1, 0, &irc_protocol_cb_generic_error },
{ "470", /* forwarding to another channel */ 1, 0, &irc_protocol_cb_470 },
{ "471", /* channel is already full */ 1, 0, &irc_protocol_cb_generic_error },
{ "472", /* unknown mode char to me */ 1, 0, &irc_protocol_cb_generic_error },
{ "473", /* cannot join channel (invite only) */ 1, 0, &irc_protocol_cb_generic_error },
{ "474", /* cannot join channel (banned from channel) */ 1, 0, &irc_protocol_cb_generic_error },
{ "475", /* cannot join channel (bad channel key) */ 1, 0, &irc_protocol_cb_generic_error },
{ "476", /* bad channel mask */ 1, 0, &irc_protocol_cb_generic_error },
{ "477", /* channel doesn't support modes */ 1, 0, &irc_protocol_cb_generic_error },
{ "481", /* you're not an IRC operator */ 1, 0, &irc_protocol_cb_generic_error },
{ "482", /* you're not channel operator */ 1, 0, &irc_protocol_cb_generic_error },
{ "483", /* you can't kill a server! */ 1, 0, &irc_protocol_cb_generic_error },
{ "484", /* your connection is restricted! */ 1, 0, &irc_protocol_cb_generic_error },
{ "485", /* user is immune from kick/deop */ 1, 0, &irc_protocol_cb_generic_error },
{ "487", /* network split */ 1, 0, &irc_protocol_cb_generic_error },
{ "491", /* no O-lines for your host */ 1, 0, &irc_protocol_cb_generic_error },
{ "501", /* unknown mode flag */ 1, 0, &irc_protocol_cb_generic_error },
{ "502", /* can't change mode for other users */ 1, 0, &irc_protocol_cb_generic_error },
{ "671", /* whois (secure connection) */ 1, 0, &irc_protocol_cb_whois_nick_msg },
{ "728", /* quietlist */ 1, 0, &irc_protocol_cb_728 },
{ "729", /* end of quietlist */ 1, 0, &irc_protocol_cb_729 },
{ "730", /* monitored nicks online */ 1, 0, &irc_protocol_cb_730 },
{ "731", /* monitored nicks offline */ 1, 0, &irc_protocol_cb_731 },
{ "732", /* list of monitored nicks */ 1, 0, &irc_protocol_cb_732 },
{ "733", /* end of monitor list */ 1, 0, &irc_protocol_cb_733 },
{ "734", /* monitor list is full */ 1, 0, &irc_protocol_cb_734 },
{ "900", /* logged in as (SASL) */ 1, 0, &irc_protocol_cb_900 },
{ "901", /* you are now logged in */ 1, 0, &irc_protocol_cb_901 },
{ "902", /* SASL authentication failed (account locked/held) */ 1, 0, &irc_protocol_cb_sasl_end_fail },
{ "903", /* SASL authentication successful */ 1, 0, &irc_protocol_cb_sasl_end_ok },
{ "904", /* SASL authentication failed */ 1, 0, &irc_protocol_cb_sasl_end_fail },
{ "905", /* SASL message too long */ 1, 0, &irc_protocol_cb_sasl_end_fail },
{ "906", /* SASL authentication aborted */ 1, 0, &irc_protocol_cb_sasl_end_fail },
{ "907", /* You have already completed SASL authentication */ 1, 0, &irc_protocol_cb_sasl_end_ok },
{ "936", /* censored word */ 1, 0, &irc_protocol_cb_generic_error },
{ "973", /* whois (secure connection) */ 1, 0, &irc_protocol_cb_server_mode_reason },
{ "974", /* whois (secure connection) */ 1, 0, &irc_protocol_cb_server_mode_reason },
{ "975", /* whois (secure connection) */ 1, 0, &irc_protocol_cb_server_mode_reason },
{ NULL, 0, 0, NULL }
};
if (!msg_command)
return;
message_colors_decoded = NULL;
argv = NULL;
argv_eol = NULL;
hash_tags = NULL;
date = 0;
ptr_msg_after_tags = irc_message;
/* get tags as hashtable */
if (irc_message && (irc_message[0] == '@'))
{
pos_space = strchr (irc_message, ' ');
if (pos_space)
{
tags = weechat_strndup (irc_message + 1,
pos_space - (irc_message + 1));
if (tags)
{
hash_tags = irc_protocol_get_message_tags (tags);
if (hash_tags)
{
date = irc_protocol_parse_time (
weechat_hashtable_get (hash_tags, "time"));
}
free (tags);
}
ptr_msg_after_tags = pos_space;
while (ptr_msg_after_tags[0] == ' ')
{
ptr_msg_after_tags++;
}
}
else
ptr_msg_after_tags = NULL;
}
/* get nick/host/address from IRC message */
nick1 = NULL;
address1 = NULL;
host1 = NULL;
if (ptr_msg_after_tags && (ptr_msg_after_tags[0] == ':'))
{
nick1 = irc_message_get_nick_from_host (ptr_msg_after_tags);
address1 = irc_message_get_address_from_host (ptr_msg_after_tags);
host1 = ptr_msg_after_tags + 1;
}
nick = (nick1) ? strdup (nick1) : NULL;
address = (address1) ? strdup (address1) : NULL;
address_color = (address) ?
irc_color_decode (
address,
weechat_config_boolean (irc_config_network_colors_receive)) :
NULL;
host = (host1) ? strdup (host1) : NULL;
if (host)
{
pos_space = strchr (host, ' ');
if (pos_space)
pos_space[0] = '\0';
}
host_no_color = (host) ? irc_color_decode (host, 0) : NULL;
host_color = (host) ?
irc_color_decode (
host,
weechat_config_boolean (irc_config_network_colors_receive)) :
NULL;
/* check if message is ignored or not */
ptr_channel = NULL;
if (msg_channel)
ptr_channel = irc_channel_search (server, msg_channel);
message_ignored = irc_ignore_check (
server,
(ptr_channel) ? ptr_channel->name : msg_channel,
nick, host_no_color);
/* send signal with received command, even if command is ignored */
irc_server_send_signal (server, "irc_raw_in", msg_command,
irc_message, NULL);
/* send signal with received command, only if message is not ignored */
if (!message_ignored)
{
irc_server_send_signal (server, "irc_in", msg_command,
irc_message, NULL);
}
/* look for IRC command */
cmd_found = -1;
for (i = 0; irc_protocol_messages[i].name; i++)
{
if (weechat_strcasecmp (irc_protocol_messages[i].name,
msg_command) == 0)
{
cmd_found = i;
break;
}
}
/* command not found */
if (cmd_found < 0)
{
/* for numeric commands, we use default recv function */
if (irc_protocol_is_numeric_command (msg_command))
{
cmd_name = msg_command;
decode_color = 1;
keep_trailing_spaces = 0;
cmd_recv_func = irc_protocol_cb_numeric;
}
else
{
weechat_printf (server->buffer,
_("%s%s: command \"%s\" not found:"),
weechat_prefix ("error"), IRC_PLUGIN_NAME,
msg_command);
weechat_printf (server->buffer,
"%s%s",
weechat_prefix ("error"), irc_message);
goto end;
}
}
else
{
cmd_name = irc_protocol_messages[cmd_found].name;
decode_color = irc_protocol_messages[cmd_found].decode_color;
keep_trailing_spaces = irc_protocol_messages[cmd_found].keep_trailing_spaces;
cmd_recv_func = irc_protocol_messages[cmd_found].recv_function;
}
if (cmd_recv_func != NULL)
{
if (ptr_msg_after_tags)
{
if (decode_color)
{
message_colors_decoded = irc_color_decode (
ptr_msg_after_tags,
weechat_config_boolean (irc_config_network_colors_receive));
}
else
{
message_colors_decoded = strdup (ptr_msg_after_tags);
}
}
else
message_colors_decoded = NULL;
argv = weechat_string_split (message_colors_decoded, " ", NULL,
WEECHAT_STRING_SPLIT_STRIP_LEFT
| WEECHAT_STRING_SPLIT_STRIP_RIGHT
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS,
0, &argc);
flags = WEECHAT_STRING_SPLIT_STRIP_LEFT
| WEECHAT_STRING_SPLIT_COLLAPSE_SEPS
| WEECHAT_STRING_SPLIT_KEEP_EOL;
if (keep_trailing_spaces)
flags |= WEECHAT_STRING_SPLIT_STRIP_RIGHT;
argv_eol = weechat_string_split (message_colors_decoded, " ", NULL,
flags, 0, NULL);
return_code = (int) (cmd_recv_func) (server,
date, nick, address_color,
host_color, cmd_name,
message_ignored, argc, argv,
argv_eol);
if (return_code == WEECHAT_RC_ERROR)
{
weechat_printf (server->buffer,
_("%s%s: failed to parse command \"%s\" (please "
"report to developers):"),
weechat_prefix ("error"), IRC_PLUGIN_NAME,
msg_command);
weechat_printf (server->buffer,
"%s%s",
weechat_prefix ("error"), irc_message);
}
/* send signal with received command (if message is not ignored) */
if (!message_ignored)
{
irc_server_send_signal (server, "irc_in2", msg_command,
irc_message, NULL);
}
}
/* send signal with received command, even if command is ignored */
irc_server_send_signal (server, "irc_raw_in2", msg_command,
irc_message, NULL);
end:
if (nick)
free (nick);
if (address)
free (address);
if (address_color)
free (address_color);
if (host)
free (host);
if (host_no_color)
free (host_no_color);
if (host_color)
free (host_color);
if (message_colors_decoded)
free (message_colors_decoded);
if (argv)
weechat_string_free_split (argv);
if (argv_eol)
weechat_string_free_split (argv_eol);
if (hash_tags)
weechat_hashtable_free (hash_tags);
}
| 0
|
242,976
|
static int ssl_flight_append( mbedtls_ssl_context *ssl )
{
mbedtls_ssl_flight_item *msg;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "=> ssl_flight_append" ) );
MBEDTLS_SSL_DEBUG_BUF( 4, "message appended to flight",
ssl->out_msg, ssl->out_msglen );
/* Allocate space for current message */
if( ( msg = mbedtls_calloc( 1, sizeof( mbedtls_ssl_flight_item ) ) ) == NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc %" MBEDTLS_PRINTF_SIZET " bytes failed",
sizeof( mbedtls_ssl_flight_item ) ) );
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
if( ( msg->p = mbedtls_calloc( 1, ssl->out_msglen ) ) == NULL )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "alloc %" MBEDTLS_PRINTF_SIZET " bytes failed",
ssl->out_msglen ) );
mbedtls_free( msg );
return( MBEDTLS_ERR_SSL_ALLOC_FAILED );
}
/* Copy current handshake message with headers */
memcpy( msg->p, ssl->out_msg, ssl->out_msglen );
msg->len = ssl->out_msglen;
msg->type = ssl->out_msgtype;
msg->next = NULL;
/* Append to the current flight */
if( ssl->handshake->flight == NULL )
ssl->handshake->flight = msg;
else
{
mbedtls_ssl_flight_item *cur = ssl->handshake->flight;
while( cur->next != NULL )
cur = cur->next;
cur->next = msg;
}
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= ssl_flight_append" ) );
return( 0 );
}
| 0
|
432,165
|
RAMBlock *qemu_ram_alloc(struct uc_struct *uc, ram_addr_t size, MemoryRegion *mr)
{
return qemu_ram_alloc_from_ptr(uc, size, NULL, mr);
}
| 0
|
353,193
|
bool SplashOutputDev::imageMaskSrc(void *data, SplashColorPtr line) {
SplashOutImageMaskData *imgMaskData = (SplashOutImageMaskData *)data;
unsigned char *p;
SplashColorPtr q;
int x;
if (imgMaskData->y == imgMaskData->height) {
return false;
}
if (!(p = imgMaskData->imgStr->getLine())) {
return false;
}
for (x = 0, q = line; x < imgMaskData->width; ++x) {
*q++ = *p++ ^ imgMaskData->invert;
}
++imgMaskData->y;
return true;
}
| 0
|
458,998
|
http_GetHdrToken(const struct http *hp, hdr_t hdr,
const char *token, const char **pb, const char **pe)
{
const char *h, *b, *e;
if (pb != NULL)
*pb = NULL;
if (pe != NULL)
*pe = NULL;
if (!http_GetHdr(hp, hdr, &h))
return (0);
AN(h);
while (http_split(&h, NULL, ",", &b, &e))
if (http_istoken(&b, e, token))
break;
if (b == NULL)
return (0);
if (pb != NULL) {
for (; vct_islws(*b); b++)
continue;
if (b == e) {
b = NULL;
e = NULL;
}
*pb = b;
if (pe != NULL)
*pe = e;
}
return (1);
}
| 0
|
238,412
|
static bool reg_type_may_be_refcounted_or_null(enum bpf_reg_type type)
{
return base_type(type) == PTR_TO_SOCKET ||
base_type(type) == PTR_TO_TCP_SOCK ||
base_type(type) == PTR_TO_MEM;
}
| 0
|
326,643
|
set_mode(struct archive_write_disk *a, int mode)
{
int r = ARCHIVE_OK;
int r2;
mode &= 07777; /* Strip off file type bits. */
if (a->todo & TODO_SGID_CHECK) {
/*
* If we don't know the GID is right, we must stat()
* to verify it. We can't just check the GID of this
* process, since systems sometimes set GID from
* the enclosing dir or based on ACLs.
*/
if ((r = lazy_stat(a)) != ARCHIVE_OK)
return (r);
if (a->pst->st_gid != a->gid) {
mode &= ~ S_ISGID;
if (a->flags & ARCHIVE_EXTRACT_OWNER) {
/*
* This is only an error if you
* requested owner restore. If you
* didn't, we'll try to restore
* sgid/suid, but won't consider it a
* problem if we can't.
*/
archive_set_error(&a->archive, -1,
"Can't restore SGID bit");
r = ARCHIVE_WARN;
}
}
/* While we're here, double-check the UID. */
if (a->pst->st_uid != a->uid
&& (a->todo & TODO_SUID)) {
mode &= ~ S_ISUID;
if (a->flags & ARCHIVE_EXTRACT_OWNER) {
archive_set_error(&a->archive, -1,
"Can't restore SUID bit");
r = ARCHIVE_WARN;
}
}
a->todo &= ~TODO_SGID_CHECK;
a->todo &= ~TODO_SUID_CHECK;
} else if (a->todo & TODO_SUID_CHECK) {
/*
* If we don't know the UID is right, we can just check
* the user, since all systems set the file UID from
* the process UID.
*/
if (a->user_uid != a->uid) {
mode &= ~ S_ISUID;
if (a->flags & ARCHIVE_EXTRACT_OWNER) {
archive_set_error(&a->archive, -1,
"Can't make file SUID");
r = ARCHIVE_WARN;
}
}
a->todo &= ~TODO_SUID_CHECK;
}
if (S_ISLNK(a->mode)) {
#ifdef HAVE_LCHMOD
/*
* If this is a symlink, use lchmod(). If the
* platform doesn't support lchmod(), just skip it. A
* platform that doesn't provide a way to set
* permissions on symlinks probably ignores
* permissions on symlinks, so a failure here has no
* impact.
*/
if (lchmod(a->name, mode) != 0) {
switch (errno) {
case ENOTSUP:
case ENOSYS:
#if ENOTSUP != EOPNOTSUPP
case EOPNOTSUPP:
#endif
/*
* if lchmod is defined but the platform
* doesn't support it, silently ignore
* error
*/
break;
default:
archive_set_error(&a->archive, errno,
"Can't set permissions to 0%o", (int)mode);
r = ARCHIVE_WARN;
}
}
#endif
} else if (!S_ISDIR(a->mode)) {
/*
* If it's not a symlink and not a dir, then use
* fchmod() or chmod(), depending on whether we have
* an fd. Dirs get their perms set during the
* post-extract fixup, which is handled elsewhere.
*/
#ifdef HAVE_FCHMOD
if (a->fd >= 0)
r2 = fchmod(a->fd, mode);
else
#endif
/* If this platform lacks fchmod(), then
* we'll just use chmod(). */
r2 = chmod(a->name, mode);
if (r2 != 0) {
archive_set_error(&a->archive, errno,
"Can't set permissions to 0%o", (int)mode);
r = ARCHIVE_WARN;
}
}
return (r);
}
| 0
|
248,246
|
static char *parse_title(const char *name, size_t *len)
{
const char *escapes = "'\\";
char *title;
char *end;
char *ch;
if (*name != '\'') {
*len = strcspn(name, "|");
if (!*len)
return NULL;
return strndup(name, *len);
}
title = strdup(name + 1);
if (!title)
return NULL;
*len = 1;
ch = title;
end = title + strlen(title);
while (ch < end) {
size_t l = strcspn(ch, escapes);
*len += l + 1;
ch += l;
switch (*ch) {
case '\'':
*ch = 0;
return title;
case '\\':
if (!ch[1] || strcspn(ch + 1, escapes)) {
free(title);
return NULL;
}
memmove(ch, ch + 1, strlen(ch));
ch++;
(*len)++;
break;
default:
free(title);
return NULL;
}
}
free(title);
return NULL;
}
| 0
|
300,778
|
static bool tipc_sk_connected(struct sock *sk)
{
return sk->sk_state == TIPC_ESTABLISHED;
}
| 0
|
343,312
|
static int create_home_and_chdir(const char * const home)
{
char *pathcomp;
char *z;
size_t len;
const char delim = '/';
if (home == NULL || *home != '/') {
return -1;
}
if (chdir(home) == 0) {
return 0;
}
if (create_home == 0) {
return -1;
}
len = strlen(home) + (size_t) 1U;
if (len < (size_t) 2U || *home != delim) {
return -1;
}
if ((pathcomp = ALLOCA(len)) == NULL) {
return -1;
}
memcpy(pathcomp, home, len); /* safe, no possible overflow */
z = pathcomp;
for (;;) {
z++;
if (*z == 0) {
break;
}
if (*z == delim) {
*z = 0;
if (z[1] == 0) {
break;
}
(void) mkdir(pathcomp, (mode_t) 0755);
*z = delim;
}
}
ALLOCA_FREE(pathcomp);
(void) mkdir(home, (mode_t) 0700);
if (chdir(home) != 0) {
return -1;
}
if (chmod(home, (mode_t) 0777 & ~u_mask_d) < 0 ||
chown(home, authresult.uid, authresult.gid) < 0) {
return -1;
}
return chdir(home);
}
| 0
|
421,389
|
static void puna(int d, int p, js_Ast *exp, const char *pre, const char *suf)
{
ps(pre);
pexpi(d, p, exp->a);
ps(suf);
}
| 0
|
219,903
|
GF_Err gf_isom_sdp_add_track_line(GF_ISOFile *the_file, u32 trackNumber, const char *text)
{
GF_TrackBox *trak;
GF_UserDataMap *map;
GF_HintTrackInfoBox *hnti;
GF_SDPBox *sdp;
GF_Err e;
char *buf;
trak = gf_isom_get_track_from_file(the_file, trackNumber);
if (!trak) return GF_BAD_PARAM;
//currently, only RTP hinting supports SDP
if (!CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM;
map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HNTI, NULL);
if (!map) return GF_ISOM_INVALID_FILE;
//we should have only one HNTI in the UDTA
if (gf_list_count(map->boxes) != 1) return GF_ISOM_INVALID_FILE;
hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxes, 0);
if (!hnti->SDP) {
e = hnti_on_child_box((GF_Box*)hnti, gf_isom_box_new_parent(&hnti->child_boxes, GF_ISOM_BOX_TYPE_SDP), GF_FALSE);
if (e) return e;
}
sdp = (GF_SDPBox *) hnti->SDP;
if (!sdp->sdpText) {
sdp->sdpText = (char *)gf_malloc(sizeof(char) * (strlen(text) + 3));
if (!sdp->sdpText) return GF_OUT_OF_MEM;
strcpy(sdp->sdpText, text);
strcat(sdp->sdpText, "\r\n");
return GF_OK;
}
buf = (char *)gf_malloc(sizeof(char) * (strlen(sdp->sdpText) + strlen(text) + 3));
if (!buf) return GF_OUT_OF_MEM;
strcpy(buf, sdp->sdpText);
strcat(buf, text);
strcat(buf, "\r\n");
gf_free(sdp->sdpText);
ReorderSDP(buf, GF_FALSE);
sdp->sdpText = buf;
return GF_OK;
}
| 0
|
220,842
|
log_x_for_x_greater_than_or_equal_to_1_impl(
gemmlowp::FixedPoint<int32_t, InputIntegerBits> input_val) {
// assert(__builtin_clz(0u) >= std::numeric_limits<uint32_t>::digits - 1);
// assert(__builtin_clz(0u) <= std::numeric_limits<uint32_t>::digits);
using FixedPoint0 = gemmlowp::FixedPoint<int32_t, 0>;
// The reason for accumulating the result with an extra bit of headroom is
// that z_pow_2_adj * log_2 might be saturated, and adding num_scaled *
// recip_denom will otherwise introduce an error.
static constexpr int kAccumIntegerBits = OutputIntegerBits + 1;
using FixedPointAccum = gemmlowp::FixedPoint<int32_t, kAccumIntegerBits>;
const FixedPoint0 log_2 = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(
FixedPoint0, 1488522236, std::log(2.0));
const FixedPoint0 sqrt_sqrt_half = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(
FixedPoint0, 1805811301, std::sqrt(std::sqrt(0.5)));
const FixedPoint0 sqrt_half = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(
FixedPoint0, 1518500250, std::sqrt(0.5));
const FixedPoint0 one_quarter =
GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(FixedPoint0, 536870912, 1.0 / 4.0);
const FixedPoint0 alpha_n = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(
FixedPoint0, 117049297, 11.0 / 240.0 * std::sqrt(std::sqrt(2.0)));
const FixedPoint0 alpha_d = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(
FixedPoint0, 127690142, 1.0 / 20.0 * std::sqrt(std::sqrt(2.0)));
const FixedPoint0 alpha_i = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(
FixedPoint0, 1057819769,
2.0 / std::sqrt(std::sqrt(2.0)) - std::sqrt(std::sqrt(2.0)));
const FixedPoint0 alpha_f = GEMMLOWP_CHECKED_FIXEDPOINT_CONSTANT(
FixedPoint0, 638450708, 1.0 / 4.0 * std::sqrt(std::sqrt(2.0)));
const FixedPointAccum shifted_quarter =
gemmlowp::Rescale<kAccumIntegerBits>(one_quarter);
// Reinterpret the input value as Q0.31, because we will figure out the
// required shift "ourselves" instead of using, say, Rescale.
FixedPoint0 z_a = FixedPoint0::FromRaw(input_val.raw());
// z_a_pow_2 = input_integer_bits - z_a_headroom;
int z_a_headroom_plus_1 = CountLeadingZeros(static_cast<uint32_t>(z_a.raw()));
FixedPoint0 r_a_tmp =
SaturatingRoundingMultiplyByPOTParam(z_a, (z_a_headroom_plus_1 - 1));
const int32_t r_a_raw =
SaturatingRoundingMultiplyByPOTParam((r_a_tmp * sqrt_half).raw(), 1);
// z_pow_2_adj = max(z_pow_2_a - 0.75, z_pow_2_b - 0.25);
// z_pow_2_adj = max(InputIntegerBits - z_a_headroom_plus_1 + 0.25,
// InputIntegerBits - z_b_headroom - 0.25);
const FixedPointAccum z_a_pow_2_adj = SaturatingAddNonGemmlowp(
FixedPointAccum::FromRaw(SaturatingRoundingMultiplyByPOTParam(
static_cast<int32_t>(InputIntegerBits - z_a_headroom_plus_1),
31 - kAccumIntegerBits)),
shifted_quarter);
// z_b is treated like z_a, but premultiplying by sqrt(0.5).
FixedPoint0 z_b = z_a * sqrt_half;
int z_b_headroom = CountLeadingZeros(static_cast<uint32_t>(z_b.raw())) - 1;
const int32_t r_b_raw =
SaturatingRoundingMultiplyByPOTParam(z_a.raw(), z_b_headroom);
const FixedPointAccum z_b_pow_2_adj = SaturatingSub(
FixedPointAccum::FromRaw(SaturatingRoundingMultiplyByPOTParam(
static_cast<int32_t>(InputIntegerBits - z_b_headroom),
31 - kAccumIntegerBits)),
shifted_quarter);
const FixedPoint0 r = FixedPoint0::FromRaw(std::min(r_a_raw, r_b_raw));
const FixedPointAccum z_pow_2_adj = FixedPointAccum::FromRaw(
std::max(z_a_pow_2_adj.raw(), z_b_pow_2_adj.raw()));
const FixedPoint0 p = gemmlowp::RoundingHalfSum(r, sqrt_sqrt_half);
FixedPoint0 q = r - sqrt_sqrt_half;
q = q + q;
const FixedPoint0 common_sq = q * q;
const FixedPoint0 num = q * r + q * common_sq * alpha_n;
const FixedPoint0 denom_minus_one_0 =
p * (alpha_i + q + alpha_d * common_sq) + alpha_f * q;
const FixedPoint0 recip_denom =
one_over_one_plus_x_for_x_in_0_1(denom_minus_one_0);
const FixedPointAccum num_scaled = gemmlowp::Rescale<kAccumIntegerBits>(num);
return gemmlowp::Rescale<OutputIntegerBits>(z_pow_2_adj * log_2 +
num_scaled * recip_denom);
}
| 0
|
125,901
|
v8::Handle<v8::Value> V8ThrowException::createRangeError(v8::Isolate* isolate, const String& message)
{
return v8::Exception::RangeError(v8String(isolate, message.isNull() ? "Range error" : message));
}
| 0
|
437,292
|
update_string_node_case_fold(regex_t* reg, Node *node)
{
UChar *p, *end, buf[ONIGENC_MBC_CASE_FOLD_MAXLEN];
UChar *sbuf, *ebuf, *sp;
int r, i, len, sbuf_size;
StrNode* sn = STR_(node);
end = sn->end;
sbuf_size = (int )(end - sn->s) * 2;
sbuf = (UChar* )xmalloc(sbuf_size);
CHECK_NULL_RETURN_MEMERR(sbuf);
ebuf = sbuf + sbuf_size;
sp = sbuf;
p = sn->s;
while (p < end) {
len = ONIGENC_MBC_CASE_FOLD(reg->enc, reg->case_fold_flag, &p, end, buf);
for (i = 0; i < len; i++) {
if (sp >= ebuf) {
sbuf = (UChar* )xrealloc(sbuf, sbuf_size * 2);
CHECK_NULL_RETURN_MEMERR(sbuf);
sp = sbuf + sbuf_size;
sbuf_size *= 2;
ebuf = sbuf + sbuf_size;
}
*sp++ = buf[i];
}
}
r = onig_node_str_set(node, sbuf, sp);
if (r != 0) {
xfree(sbuf);
return r;
}
xfree(sbuf);
return 0;
}
| 0
|
345,207
|
int con_set_trans_old(unsigned char __user * arg)
{
int i;
unsigned short inbuf[E_TABSZ];
unsigned char ubuf[E_TABSZ];
if (copy_from_user(ubuf, arg, E_TABSZ))
return -EFAULT;
for (i = 0; i < E_TABSZ ; i++)
inbuf[i] = UNI_DIRECT_BASE | ubuf[i];
console_lock();
memcpy(translations[USER_MAP], inbuf, sizeof(inbuf));
update_user_maps();
console_unlock();
return 0;
}
| 0
|
473,888
|
onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end,
OnigErrorInfo* einfo, const char *sourcefile, int sourceline)
{
#define COMPILE_INIT_SIZE 20
int r;
OnigDistance init_size;
Node* root;
ScanEnv scan_env = {0};
#ifdef USE_SUBEXP_CALL
UnsetAddrList uslist;
#endif
if (IS_NOT_NULL(einfo)) einfo->par = (UChar* )NULL;
scan_env.sourcefile = sourcefile;
scan_env.sourceline = sourceline;
reg->state = ONIG_STATE_COMPILING;
#ifdef ONIG_DEBUG
if (!onig_is_prelude()) print_enc_string(stderr, reg->enc, pattern, pattern_end);
#endif
if (reg->alloc == 0) {
init_size = (pattern_end - pattern) * 2;
if (init_size <= 0) init_size = COMPILE_INIT_SIZE;
r = BBUF_INIT(reg, init_size);
if (r != 0) goto end;
}
else
reg->used = 0;
reg->num_mem = 0;
reg->num_repeat = 0;
reg->num_null_check = 0;
reg->repeat_range_alloc = 0;
reg->repeat_range = (OnigRepeatRange* )NULL;
#ifdef USE_COMBINATION_EXPLOSION_CHECK
reg->num_comb_exp_check = 0;
#endif
r = onig_parse_make_tree(&root, pattern, pattern_end, reg, &scan_env);
if (r != 0) goto err;
#ifdef ONIG_DEBUG_PARSE_TREE
# if 0
fprintf(stderr, "ORIGINAL PARSE TREE:\n");
if (!onig_is_prelude()) {
print_tree(stderr, root);
}
# endif
#endif
#ifdef USE_NAMED_GROUP
/* mixed use named group and no-named group */
if (scan_env.num_named > 0 &&
IS_SYNTAX_BV(scan_env.syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
!ONIG_IS_OPTION_ON(reg->options, ONIG_OPTION_CAPTURE_GROUP)) {
if (scan_env.num_named != scan_env.num_mem)
r = disable_noname_group_capture(&root, reg, &scan_env);
else
r = numbered_ref_check(root);
if (r != 0) goto err;
}
#endif
#ifdef USE_SUBEXP_CALL
if (scan_env.num_call > 0) {
r = unset_addr_list_init(&uslist, scan_env.num_call);
if (r != 0) goto err;
scan_env.unset_addr_list = &uslist;
r = setup_subexp_call(root, &scan_env);
if (r != 0) goto err_unset;
r = subexp_recursive_check_trav(root, &scan_env);
if (r < 0) goto err_unset;
r = subexp_inf_recursive_check_trav(root, &scan_env);
if (r != 0) goto err_unset;
reg->num_call = scan_env.num_call;
}
else
reg->num_call = 0;
#endif
r = setup_tree(root, reg, 0, &scan_env);
if (r != 0) goto err_unset;
#ifdef ONIG_DEBUG_PARSE_TREE
if (!onig_is_prelude()) print_tree(stderr, root);
#endif
reg->capture_history = scan_env.capture_history;
reg->bt_mem_start = scan_env.bt_mem_start;
reg->bt_mem_start |= reg->capture_history;
if (IS_FIND_CONDITION(reg->options))
BIT_STATUS_ON_ALL(reg->bt_mem_end);
else {
reg->bt_mem_end = scan_env.bt_mem_end;
reg->bt_mem_end |= reg->capture_history;
}
#ifdef USE_COMBINATION_EXPLOSION_CHECK
if (scan_env.backrefed_mem == 0
#ifdef USE_SUBEXP_CALL
|| scan_env.num_call == 0
#endif
) {
setup_comb_exp_check(root, 0, &scan_env);
#ifdef USE_SUBEXP_CALL
if (scan_env.has_recursion != 0) {
scan_env.num_comb_exp_check = 0;
}
else
#endif
if (scan_env.comb_exp_max_regnum > 0) {
int i;
for (i = 1; i <= scan_env.comb_exp_max_regnum; i++) {
if (BIT_STATUS_AT(scan_env.backrefed_mem, i) != 0) {
scan_env.num_comb_exp_check = 0;
break;
}
}
}
}
reg->num_comb_exp_check = scan_env.num_comb_exp_check;
#endif
clear_optimize_info(reg);
#ifndef ONIG_DONT_OPTIMIZE
r = set_optimize_info_from_tree(root, reg, &scan_env);
if (r != 0) goto err_unset;
#endif
if (IS_NOT_NULL(scan_env.mem_nodes_dynamic)) {
xfree(scan_env.mem_nodes_dynamic);
scan_env.mem_nodes_dynamic = (Node** )NULL;
}
r = compile_tree(root, reg);
if (r == 0) {
r = add_opcode(reg, OP_END);
#ifdef USE_SUBEXP_CALL
if (scan_env.num_call > 0) {
r = unset_addr_list_fix(&uslist, reg);
unset_addr_list_end(&uslist);
if (r) goto err;
}
#endif
if ((reg->num_repeat != 0) || (reg->bt_mem_end != 0))
reg->stack_pop_level = STACK_POP_LEVEL_ALL;
else {
if (reg->bt_mem_start != 0)
reg->stack_pop_level = STACK_POP_LEVEL_MEM_START;
else
reg->stack_pop_level = STACK_POP_LEVEL_FREE;
}
}
#ifdef USE_SUBEXP_CALL
else if (scan_env.num_call > 0) {
unset_addr_list_end(&uslist);
}
#endif
onig_node_free(root);
#ifdef ONIG_DEBUG_COMPILE
#ifdef USE_NAMED_GROUP
if (!onig_is_prelude()) onig_print_names(stderr, reg);
#endif
if (!onig_is_prelude()) print_compiled_byte_code_list(stderr, reg);
#endif
end:
reg->state = ONIG_STATE_NORMAL;
return r;
err_unset:
#ifdef USE_SUBEXP_CALL
if (scan_env.num_call > 0) {
unset_addr_list_end(&uslist);
}
#endif
err:
if (IS_NOT_NULL(scan_env.error)) {
if (IS_NOT_NULL(einfo)) {
einfo->enc = scan_env.enc;
einfo->par = scan_env.error;
einfo->par_end = scan_env.error_end;
}
}
onig_node_free(root);
if (IS_NOT_NULL(scan_env.mem_nodes_dynamic))
xfree(scan_env.mem_nodes_dynamic);
return r;
}
| 0
|
238,619
|
static int add_subprog(struct bpf_verifier_env *env, int off)
{
int insn_cnt = env->prog->len;
int ret;
if (off >= insn_cnt || off < 0) {
verbose(env, "call to invalid destination\n");
return -EINVAL;
}
ret = find_subprog(env, off);
if (ret >= 0)
return ret;
if (env->subprog_cnt >= BPF_MAX_SUBPROGS) {
verbose(env, "too many subprograms\n");
return -E2BIG;
}
/* determine subprog starts. The end is one before the next starts */
env->subprog_info[env->subprog_cnt++].start = off;
sort(env->subprog_info, env->subprog_cnt,
sizeof(env->subprog_info[0]), cmp_subprogs, NULL);
return env->subprog_cnt - 1;
}
| 0
|
442,788
|
static int myprogress (void *clientp,
double dltotal,
double dlnow,
double ultotal,
double ulnow)
{
/* The original progress-bar source code was written for curl by Lars Aas,
and this new edition inherits some of his concepts. */
char line[256];
char outline[256];
char format[40];
double frac;
double percent;
int barwidth;
int num;
int i;
struct ProgressData *bar = (struct ProgressData *)clientp;
curl_off_t total = (curl_off_t)dltotal + (curl_off_t)ultotal +
bar->initial_size; /* expected transfer size */
curl_off_t point = (curl_off_t)dlnow + (curl_off_t)ulnow +
bar->initial_size; /* we've come this far */
if(point > total)
/* we have got more than the expected total! */
total = point;
bar->calls++; /* simply count invokes */
if(total < 1) {
curl_off_t prevblock = bar->prev / 1024;
curl_off_t thisblock = point / 1024;
while ( thisblock > prevblock ) {
fprintf( bar->out, "#" );
prevblock++;
}
}
else {
frac = (double)point / (double)total;
percent = frac * 100.0f;
barwidth = bar->width - 7;
num = (int) (((double)barwidth) * frac);
i = 0;
for ( i = 0; i < num; i++ ) {
line[i] = '#';
}
line[i] = '\0';
snprintf( format, sizeof(format), "%%-%ds %%5.1f%%%%", barwidth );
snprintf( outline, sizeof(outline), format, line, percent );
fprintf( bar->out, "\r%s", outline );
}
fflush(bar->out);
bar->prev = point;
return 0;
}
| 0
|
453,001
|
static int nft_dup_netdev_offload(struct nft_offload_ctx *ctx,
struct nft_flow_rule *flow,
const struct nft_expr *expr)
{
const struct nft_dup_netdev *priv = nft_expr_priv(expr);
int oif = ctx->regs[priv->sreg_dev].data.data[0];
return nft_fwd_dup_netdev_offload(ctx, flow, FLOW_ACTION_MIRRED, oif);
}
| 0
|
310,281
|
dirserv_should_launch_reachability_test(routerinfo_t *ri, routerinfo_t *ri_old)
{
if (!authdir_mode_handles_descs(get_options(), ri->purpose))
return 0;
if (!ri_old) {
/* New router: Launch an immediate reachability test, so we will have an
* opinion soon in case we're generating a consensus soon */
return 1;
}
if (ri_old->is_hibernating && !ri->is_hibernating) {
/* It just came out of hibernation; launch a reachability test */
return 1;
}
if (! routers_have_same_or_addr(ri, ri_old)) {
/* Address or port changed; launch a reachability test */
return 1;
}
return 0;
}
| 0
|
383,311
|
void gdImageCopyResampled (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)
{
int x, y;
if (!dst->trueColor) {
gdImageCopyResized (dst, src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
return;
}
for (y = dstY; (y < dstY + dstH); y++) {
for (x = dstX; (x < dstX + dstW); x++) {
float sy1, sy2, sx1, sx2;
float sx, sy;
float spixels = 0.0f;
float red = 0.0f, green = 0.0f, blue = 0.0f, alpha = 0.0f;
float alpha_factor, alpha_sum = 0.0f, contrib_sum = 0.0f;
sy1 = ((float)(y - dstY)) * (float)srcH / (float)dstH;
sy2 = ((float)(y + 1 - dstY)) * (float) srcH / (float) dstH;
sy = sy1;
do {
float yportion;
if (floor_cast(sy) == floor_cast(sy1)) {
yportion = 1.0f - (sy - floor_cast(sy));
if (yportion > sy2 - sy1) {
yportion = sy2 - sy1;
}
sy = floor_cast(sy);
} else if (sy == floorf(sy2)) {
yportion = sy2 - floor_cast(sy2);
} else {
yportion = 1.0f;
}
sx1 = ((float)(x - dstX)) * (float) srcW / dstW;
sx2 = ((float)(x + 1 - dstX)) * (float) srcW / dstW;
sx = sx1;
do {
float xportion;
float pcontribution;
int p;
if (floorf(sx) == floor_cast(sx1)) {
xportion = 1.0f - (sx - floor_cast(sx));
if (xportion > sx2 - sx1) {
xportion = sx2 - sx1;
}
sx = floor_cast(sx);
} else if (sx == floorf(sx2)) {
xportion = sx2 - floor_cast(sx2);
} else {
xportion = 1.0f;
}
pcontribution = xportion * yportion;
p = gdImageGetTrueColorPixel(src, (int) sx + srcX, (int) sy + srcY);
alpha_factor = ((gdAlphaMax - gdTrueColorGetAlpha(p))) * pcontribution;
red += gdTrueColorGetRed (p) * alpha_factor;
green += gdTrueColorGetGreen (p) * alpha_factor;
blue += gdTrueColorGetBlue (p) * alpha_factor;
alpha += gdTrueColorGetAlpha (p) * pcontribution;
alpha_sum += alpha_factor;
contrib_sum += pcontribution;
spixels += xportion * yportion;
sx += 1.0f;
}
while (sx < sx2);
sy += 1.0f;
}
while (sy < sy2);
if (spixels != 0.0f) {
red /= spixels;
green /= spixels;
blue /= spixels;
alpha /= spixels;
}
if ( alpha_sum != 0.0f) {
if( contrib_sum != 0.0f) {
alpha_sum /= contrib_sum;
}
red /= alpha_sum;
green /= alpha_sum;
blue /= alpha_sum;
}
/* Clamping to allow for rounding errors above */
if (red > 255.0f) {
red = 255.0f;
}
if (green > 255.0f) {
green = 255.0f;
}
if (blue > 255.0f) {
blue = 255.0f;
}
if (alpha > gdAlphaMax) {
alpha = gdAlphaMax;
}
gdImageSetPixel(dst, x, y, gdTrueColorAlpha ((int) red, (int) green, (int) blue, (int) alpha));
}
}
}
| 0
|
445,922
|
overwrite_dialog_response_cb (GtkDialog *dialog,
int response_id,
gpointer user_data)
{
OverwriteData *odata = user_data;
gboolean do_not_extract = FALSE;
switch (response_id) {
case _FR_RESPONSE_OVERWRITE_YES_ALL:
odata->edata->overwrite = FR_OVERWRITE_YES;
break;
case _FR_RESPONSE_OVERWRITE_YES:
odata->current_file = odata->current_file->next;
break;
case _FR_RESPONSE_OVERWRITE_NO:
{
/* remove the file from the list to extract */
GList *next = odata->current_file->next;
odata->edata->file_list = g_list_remove_link (odata->edata->file_list, odata->current_file);
_g_string_list_free (odata->current_file);
odata->current_file = next;
odata->extract_all = FALSE;
}
break;
case GTK_RESPONSE_DELETE_EVENT:
case GTK_RESPONSE_CANCEL:
do_not_extract = TRUE;
break;
default:
break;
}
gtk_widget_destroy (GTK_WIDGET (dialog));
if (do_not_extract) {
fr_window_stop_batch (odata->window);
g_free (odata);
return;
}
_fr_window_ask_overwrite_dialog (odata);
}
| 0
|
90,760
|
void DidGetHostQuota(QuotaStatusCode status,
const std::string& host,
StorageType type,
int64 quota) {
DCHECK_EQ(host_, host);
DCHECK_EQ(type_, type);
quota_status_ = status;
quota_ = quota;
CheckCompleted();
}
| 0
|
225,012
|
conninfo_parse(const char *conninfo, PQExpBuffer errorMessage,
bool use_defaults)
{
char *pname;
char *pval;
char *buf;
char *cp;
char *cp2;
PQconninfoOption *options;
/* Make a working copy of PQconninfoOptions */
options = conninfo_init(errorMessage);
if (options == NULL)
return NULL;
/* Need a modifiable copy of the input string */
if ((buf = strdup(conninfo)) == NULL)
{
appendPQExpBufferStr(errorMessage,
libpq_gettext("out of memory\n"));
PQconninfoFree(options);
return NULL;
}
cp = buf;
while (*cp)
{
/* Skip blanks before the parameter name */
if (isspace((unsigned char) *cp))
{
cp++;
continue;
}
/* Get the parameter name */
pname = cp;
while (*cp)
{
if (*cp == '=')
break;
if (isspace((unsigned char) *cp))
{
*cp++ = '\0';
while (*cp)
{
if (!isspace((unsigned char) *cp))
break;
cp++;
}
break;
}
cp++;
}
/* Check that there is a following '=' */
if (*cp != '=')
{
appendPQExpBuffer(errorMessage,
libpq_gettext("missing \"=\" after \"%s\" in connection info string\n"),
pname);
PQconninfoFree(options);
free(buf);
return NULL;
}
*cp++ = '\0';
/* Skip blanks after the '=' */
while (*cp)
{
if (!isspace((unsigned char) *cp))
break;
cp++;
}
/* Get the parameter value */
pval = cp;
if (*cp != '\'')
{
cp2 = pval;
while (*cp)
{
if (isspace((unsigned char) *cp))
{
*cp++ = '\0';
break;
}
if (*cp == '\\')
{
cp++;
if (*cp != '\0')
*cp2++ = *cp++;
}
else
*cp2++ = *cp++;
}
*cp2 = '\0';
}
else
{
cp2 = pval;
cp++;
for (;;)
{
if (*cp == '\0')
{
appendPQExpBufferStr(errorMessage,
libpq_gettext("unterminated quoted string in connection info string\n"));
PQconninfoFree(options);
free(buf);
return NULL;
}
if (*cp == '\\')
{
cp++;
if (*cp != '\0')
*cp2++ = *cp++;
continue;
}
if (*cp == '\'')
{
*cp2 = '\0';
cp++;
break;
}
*cp2++ = *cp++;
}
}
/*
* Now that we have the name and the value, store the record.
*/
if (!conninfo_storeval(options, pname, pval, errorMessage, false, false))
{
PQconninfoFree(options);
free(buf);
return NULL;
}
}
/* Done with the modifiable input string */
free(buf);
/*
* Add in defaults if the caller wants that.
*/
if (use_defaults)
{
if (!conninfo_add_defaults(options, errorMessage))
{
PQconninfoFree(options);
return NULL;
}
}
return options;
}
| 0
|
225,093
|
uint64 OpDefHash(const OpDef& o) {
uint64 h = RepeatedAttrDefHash(o.attr());
// Compute deterministic order-independent control outputs hash.
std::set<string> control_output(o.control_output().begin(),
o.control_output().end());
for (const auto& co : control_output) h = Hash64Combine(h, Hash64(co));
OpDef o_copy = o;
o_copy.clear_attr();
o_copy.clear_control_output();
return DeterministicProtoHash64(o_copy, h);
}
| 0
|
437,380
|
setup_call_node_call(CallNode* cn, ScanEnv* env, int state)
{
MemEnv* mem_env = SCANENV_MEMENV(env);
if (cn->by_number != 0) {
int gnum = cn->group_num;
if (env->num_named > 0 &&
IS_SYNTAX_BV(env->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
! ONIG_IS_OPTION_ON(env->options, ONIG_OPTION_CAPTURE_GROUP)) {
return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
}
if (gnum > env->num_mem) {
onig_scan_env_set_error_string(env, ONIGERR_UNDEFINED_GROUP_REFERENCE,
cn->name, cn->name_end);
return ONIGERR_UNDEFINED_GROUP_REFERENCE;
}
set_call_attr:
NODE_CALL_BODY(cn) = mem_env[cn->group_num].node;
if (IS_NULL(NODE_CALL_BODY(cn))) {
onig_scan_env_set_error_string(env, ONIGERR_UNDEFINED_NAME_REFERENCE,
cn->name, cn->name_end);
return ONIGERR_UNDEFINED_NAME_REFERENCE;
}
}
else {
int *refs;
int n = onig_name_to_group_numbers(env->reg, cn->name, cn->name_end, &refs);
if (n <= 0) {
onig_scan_env_set_error_string(env, ONIGERR_UNDEFINED_NAME_REFERENCE,
cn->name, cn->name_end);
return ONIGERR_UNDEFINED_NAME_REFERENCE;
}
else if (n > 1) {
onig_scan_env_set_error_string(env, ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL,
cn->name, cn->name_end);
return ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL;
}
else {
cn->group_num = refs[0];
goto set_call_attr;
}
}
return 0;
}
| 0
|
512,702
|
bool Item_in_optimizer::is_expensive_processor(void *arg)
{
DBUG_ASSERT(fixed);
return args[0]->is_expensive_processor(arg) ||
args[1]->is_expensive_processor(arg);
}
| 0
|
413,335
|
PHP_FUNCTION(snmp_set_enum_print)
{
long a1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &a1) == FAILURE) {
RETURN_FALSE;
}
netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_PRINT_NUMERIC_ENUM, (int) a1);
RETURN_TRUE;
}
| 0
|
359,428
|
peer_flag_set_vty (struct vty *vty, const char *ip_str, u_int16_t flag)
{
return peer_flag_modify_vty (vty, ip_str, flag, 1);
}
| 0
|
247,627
|
void testUtil(const TestUtilOptions& options) {
Event::SimulatedTimeSystem time_system;
Stats::TestUtil::TestStore server_stats_store;
Api::ApiPtr server_api = Api::createApiForTest(server_stats_store, time_system);
NiceMock<Runtime::MockLoader> runtime;
testing::NiceMock<Server::Configuration::MockTransportSocketFactoryContext>
server_factory_context;
ON_CALL(server_factory_context, api()).WillByDefault(ReturnRef(*server_api));
// For private key method testing.
NiceMock<Ssl::MockContextManager> context_manager;
Extensions::PrivateKeyMethodProvider::TestPrivateKeyMethodFactory test_factory;
Registry::InjectFactory<Ssl::PrivateKeyMethodProviderInstanceFactory>
test_private_key_method_factory(test_factory);
PrivateKeyMethodManagerImpl private_key_method_manager;
if (options.expectedPrivateKeyMethod()) {
EXPECT_CALL(server_factory_context, sslContextManager())
.WillOnce(ReturnRef(context_manager))
.WillRepeatedly(ReturnRef(context_manager));
EXPECT_CALL(context_manager, privateKeyMethodManager())
.WillOnce(ReturnRef(private_key_method_manager))
.WillRepeatedly(ReturnRef(private_key_method_manager));
}
envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext server_tls_context;
TestUtility::loadFromYaml(TestEnvironment::substitute(options.serverCtxYaml()),
server_tls_context);
auto server_cfg =
std::make_unique<ServerContextConfigImpl>(server_tls_context, server_factory_context);
ContextManagerImpl manager(*time_system);
ServerSslSocketFactory server_ssl_socket_factory(std::move(server_cfg), manager,
server_stats_store, std::vector<std::string>{});
Event::DispatcherPtr dispatcher = server_api->allocateDispatcher("test_thread");
auto socket = std::make_shared<Network::Test::TcpListenSocketImmediateListen>(
Network::Test::getCanonicalLoopbackAddress(options.version()));
Network::MockTcpListenerCallbacks callbacks;
Network::ListenerPtr listener =
dispatcher->createListener(socket, callbacks, runtime, true, false);
envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client_tls_context;
TestUtility::loadFromYaml(TestEnvironment::substitute(options.clientCtxYaml()),
client_tls_context);
Stats::TestUtil::TestStore client_stats_store;
Api::ApiPtr client_api = Api::createApiForTest(client_stats_store, time_system);
testing::NiceMock<Server::Configuration::MockTransportSocketFactoryContext>
client_factory_context;
ON_CALL(client_factory_context, api()).WillByDefault(ReturnRef(*client_api));
auto client_cfg =
std::make_unique<ClientContextConfigImpl>(client_tls_context, client_factory_context);
ClientSslSocketFactory client_ssl_socket_factory(std::move(client_cfg), manager,
client_stats_store);
Network::ClientConnectionPtr client_connection = dispatcher->createClientConnection(
socket->connectionInfoProvider().localAddress(), Network::Address::InstanceConstSharedPtr(),
client_ssl_socket_factory.createTransportSocket(nullptr), nullptr);
Network::ConnectionPtr server_connection;
Network::MockConnectionCallbacks server_connection_callbacks;
NiceMock<StreamInfo::MockStreamInfo> stream_info;
EXPECT_CALL(callbacks, onAccept_(_))
.WillOnce(Invoke([&](Network::ConnectionSocketPtr& socket) -> void {
auto ssl_socket = server_ssl_socket_factory.createTransportSocket(nullptr);
// configureInitialCongestionWindow is an unimplemented empty function, this is just to
// increase code coverage.
ssl_socket->configureInitialCongestionWindow(100, std::chrono::microseconds(123));
server_connection = dispatcher->createServerConnection(std::move(socket),
std::move(ssl_socket), stream_info);
server_connection->addConnectionCallbacks(server_connection_callbacks);
}));
if (options.ocspStaplingEnabled()) {
const SslHandshakerImpl* ssl_socket =
dynamic_cast<const SslHandshakerImpl*>(client_connection->ssl().get());
SSL_enable_ocsp_stapling(ssl_socket->ssl());
}
Network::MockConnectionCallbacks client_connection_callbacks;
client_connection->addConnectionCallbacks(client_connection_callbacks);
client_connection->connect();
size_t connect_count = 0;
auto connect_second_time = [&]() {
if (++connect_count == 2) {
if (!options.expectedSha256Digest().empty()) {
// Assert twice to ensure a cached value is returned and still valid.
EXPECT_EQ(options.expectedSha256Digest(),
server_connection->ssl()->sha256PeerCertificateDigest());
EXPECT_EQ(options.expectedSha256Digest(),
server_connection->ssl()->sha256PeerCertificateDigest());
}
if (!options.expectedSha1Digest().empty()) {
// Assert twice to ensure a cached value is returned and still valid.
EXPECT_EQ(options.expectedSha1Digest(),
server_connection->ssl()->sha1PeerCertificateDigest());
EXPECT_EQ(options.expectedSha1Digest(),
server_connection->ssl()->sha1PeerCertificateDigest());
}
// Assert twice to ensure a cached value is returned and still valid.
EXPECT_EQ(options.expectedClientCertUri(), server_connection->ssl()->uriSanPeerCertificate());
EXPECT_EQ(options.expectedClientCertUri(), server_connection->ssl()->uriSanPeerCertificate());
if (!options.expectedLocalUri().empty()) {
// Assert twice to ensure a cached value is returned and still valid.
EXPECT_EQ(options.expectedLocalUri(), server_connection->ssl()->uriSanLocalCertificate());
EXPECT_EQ(options.expectedLocalUri(), server_connection->ssl()->uriSanLocalCertificate());
}
EXPECT_EQ(options.expectedSerialNumber(),
server_connection->ssl()->serialNumberPeerCertificate());
if (!options.expectedPeerIssuer().empty()) {
EXPECT_EQ(options.expectedPeerIssuer(), server_connection->ssl()->issuerPeerCertificate());
}
if (!options.expectedPeerSubject().empty()) {
EXPECT_EQ(options.expectedPeerSubject(),
server_connection->ssl()->subjectPeerCertificate());
}
if (!options.expectedLocalSubject().empty()) {
EXPECT_EQ(options.expectedLocalSubject(),
server_connection->ssl()->subjectLocalCertificate());
}
if (!options.expectedPeerCert().empty()) {
std::string urlencoded = absl::StrReplaceAll(
options.expectedPeerCert(),
{{"\r", ""}, {"\n", "%0A"}, {" ", "%20"}, {"+", "%2B"}, {"/", "%2F"}, {"=", "%3D"}});
// Assert twice to ensure a cached value is returned and still valid.
EXPECT_EQ(urlencoded, server_connection->ssl()->urlEncodedPemEncodedPeerCertificate());
EXPECT_EQ(urlencoded, server_connection->ssl()->urlEncodedPemEncodedPeerCertificate());
}
if (!options.expectedPeerCertChain().empty()) {
std::string cert_chain = absl::StrReplaceAll(
options.expectedPeerCertChain(),
{{"\r", ""}, {"\n", "%0A"}, {" ", "%20"}, {"+", "%2B"}, {"/", "%2F"}, {"=", "%3D"}});
// Assert twice to ensure a cached value is returned and still valid.
EXPECT_EQ(cert_chain, server_connection->ssl()->urlEncodedPemEncodedPeerCertificateChain());
EXPECT_EQ(cert_chain, server_connection->ssl()->urlEncodedPemEncodedPeerCertificateChain());
}
if (!options.expectedValidFromTimePeerCert().empty()) {
const std::string formatted = TestUtility::formatTime(
server_connection->ssl()->validFromPeerCertificate().value(), "%b %e %H:%M:%S %Y GMT");
EXPECT_EQ(options.expectedValidFromTimePeerCert(), formatted);
}
if (!options.expectedExpirationTimePeerCert().empty()) {
const std::string formatted = TestUtility::formatTime(
server_connection->ssl()->expirationPeerCertificate().value(), "%b %e %H:%M:%S %Y GMT");
EXPECT_EQ(options.expectedExpirationTimePeerCert(), formatted);
}
if (options.expectNoCert()) {
EXPECT_FALSE(server_connection->ssl()->peerCertificatePresented());
EXPECT_FALSE(server_connection->ssl()->validFromPeerCertificate().has_value());
EXPECT_FALSE(server_connection->ssl()->expirationPeerCertificate().has_value());
EXPECT_EQ(EMPTY_STRING, server_connection->ssl()->sha256PeerCertificateDigest());
EXPECT_EQ(EMPTY_STRING, server_connection->ssl()->sha1PeerCertificateDigest());
EXPECT_EQ(EMPTY_STRING, server_connection->ssl()->urlEncodedPemEncodedPeerCertificate());
EXPECT_EQ(EMPTY_STRING, server_connection->ssl()->subjectPeerCertificate());
EXPECT_EQ(std::vector<std::string>{}, server_connection->ssl()->dnsSansPeerCertificate());
}
if (options.expectNoCertChain()) {
EXPECT_EQ(EMPTY_STRING,
server_connection->ssl()->urlEncodedPemEncodedPeerCertificateChain());
}
const SslHandshakerImpl* ssl_socket =
dynamic_cast<const SslHandshakerImpl*>(client_connection->ssl().get());
SSL* client_ssl_socket = ssl_socket->ssl();
const uint8_t* response_head;
size_t response_len;
SSL_get0_ocsp_response(client_ssl_socket, &response_head, &response_len);
std::string ocsp_response{reinterpret_cast<const char*>(response_head), response_len};
EXPECT_EQ(options.expectedOcspResponse(), ocsp_response);
// By default, the session is not created with session resumption. The
// client should see a session ID but the server should not.
EXPECT_EQ(EMPTY_STRING, server_connection->ssl()->sessionId());
EXPECT_NE(EMPTY_STRING, client_connection->ssl()->sessionId());
server_connection->close(Network::ConnectionCloseType::NoFlush);
client_connection->close(Network::ConnectionCloseType::NoFlush);
dispatcher->exit();
}
};
size_t close_count = 0;
auto close_second_time = [&close_count, &dispatcher]() {
if (++close_count == 2) {
dispatcher->exit();
}
};
if (options.expectSuccess()) {
EXPECT_CALL(client_connection_callbacks, onEvent(Network::ConnectionEvent::Connected))
.WillOnce(Invoke([&](Network::ConnectionEvent) -> void { connect_second_time(); }));
EXPECT_CALL(server_connection_callbacks, onEvent(Network::ConnectionEvent::Connected))
.WillOnce(Invoke([&](Network::ConnectionEvent) -> void { connect_second_time(); }));
EXPECT_CALL(client_connection_callbacks, onEvent(Network::ConnectionEvent::LocalClose));
EXPECT_CALL(server_connection_callbacks, onEvent(Network::ConnectionEvent::LocalClose));
} else {
EXPECT_CALL(client_connection_callbacks, onEvent(Network::ConnectionEvent::RemoteClose))
.WillOnce(Invoke([&](Network::ConnectionEvent) -> void { close_second_time(); }));
EXPECT_CALL(server_connection_callbacks, onEvent(options.expectedServerCloseEvent()))
.WillOnce(Invoke([&](Network::ConnectionEvent) -> void { close_second_time(); }));
}
if (options.expectedVerifyErrorCode() != -1) {
EXPECT_LOG_CONTAINS("debug", X509_verify_cert_error_string(options.expectedVerifyErrorCode()),
dispatcher->run(Event::Dispatcher::RunType::Block));
} else {
dispatcher->run(Event::Dispatcher::RunType::Block);
}
if (!options.expectedServerStats().empty()) {
EXPECT_EQ(1UL, server_stats_store.counter(options.expectedServerStats()).value());
}
if (!options.notExpectedClientStats().empty()) {
EXPECT_EQ(0, client_stats_store.counter(options.notExpectedClientStats()).value());
}
if (options.expectSuccess()) {
EXPECT_EQ("", client_connection->transportFailureReason());
EXPECT_EQ("", server_connection->transportFailureReason());
} else {
EXPECT_THAT(std::string(client_connection->transportFailureReason()),
ContainsRegex(options.expectedTransportFailureReasonContains()));
EXPECT_NE("", server_connection->transportFailureReason());
}
}
| 0
|
232,325
|
void gf_isom_box_dump_done(const char *name, GF_Box *ptr, FILE *trace)
{
if (ptr && ptr->child_boxes) {
gf_isom_box_array_dump(ptr->child_boxes, trace);
}
if (name)
gf_fprintf(trace, "</%s>\n", name);
| 0
|
481,262
|
static void mlx5_fpga_conn_free_recv_bufs(struct mlx5_fpga_conn *conn)
{
int ix;
for (ix = 0; ix < conn->qp.rq.size; ix++) {
if (!conn->qp.rq.bufs[ix])
continue;
mlx5_fpga_conn_unmap_buf(conn, conn->qp.rq.bufs[ix]);
kfree(conn->qp.rq.bufs[ix]);
conn->qp.rq.bufs[ix] = NULL;
}
}
| 0
|
316,951
|
static void delayed_superblock_init(struct super_block *sb, void *unused)
{
selinux_set_mnt_opts(sb, NULL, 0, NULL);
}
| 0
|
509,493
|
uint ha_maria::max_supported_key_length() const
{
return maria_max_key_length();
}
| 0
|
261,242
|
int SN_Client_WillTopicUpdate(MqttClient *client, SN_Will *will)
{
int rc = 0, len = 0;
/* Validate required arguments */
if (client == NULL) {
return MQTT_CODE_ERROR_BAD_ARG;
}
if (will->stat == MQTT_MSG_BEGIN) {
#ifdef WOLFMQTT_MULTITHREAD
/* Lock send socket mutex */
rc = wm_SemLock(&client->lockSend);
if (rc != 0) {
return rc;
}
#endif
/* Encode Will Topic Update */
len = rc = SN_Encode_WillTopicUpdate(client->tx_buf,
client->tx_buf_len, will);
#ifdef WOLFMQTT_DEBUG_CLIENT
PRINTF("MqttClient_EncodePacket: Len %d, Type %s (%d)",
rc, SN_Packet_TypeDesc(SN_MSG_TYPE_WILLTOPICUPD),
SN_MSG_TYPE_WILLTOPICUPD);
#endif
if (rc <= 0) {
#ifdef WOLFMQTT_MULTITHREAD
wm_SemUnlock(&client->lockSend);
#endif
return rc;
}
#ifdef WOLFMQTT_MULTITHREAD
rc = wm_SemLock(&client->lockClient);
if (rc == 0) {
/* inform other threads of expected response */
rc = MqttClient_RespList_Add(client,
(MqttPacketType)SN_MSG_TYPE_WILLTOPICRESP,
0, &will->pendResp, &will->resp.topicResp);
wm_SemUnlock(&client->lockClient);
}
if (rc != 0) {
wm_SemUnlock(&client->lockSend);
return rc; /* Error locking client */
}
#endif
/* Send Will Topic Update packet */
rc = MqttPacket_Write(client, client->tx_buf, len);
#ifdef WOLFMQTT_MULTITHREAD
wm_SemUnlock(&client->lockSend);
#endif
if (rc != len) {
#ifdef WOLFMQTT_MULTITHREAD
if (wm_SemLock(&client->lockClient) == 0) {
MqttClient_RespList_Remove(client, &will->pendResp);
wm_SemUnlock(&client->lockClient);
}
#endif
}
will->stat = MQTT_MSG_WAIT;
}
/* Wait for Will Topic Update Response packet */
rc = SN_Client_WaitType(client, &will->resp.topicResp,
SN_MSG_TYPE_WILLTOPICRESP, 0, client->cmd_timeout_ms);
#ifdef WOLFMQTT_NONBLOCK
if (rc == MQTT_CODE_CONTINUE)
return rc;
#endif
#ifdef WOLFMQTT_MULTITHREAD
if (wm_SemLock(&client->lockClient) == 0) {
MqttClient_RespList_Remove(client, &will->pendResp);
wm_SemUnlock(&client->lockClient);
}
#endif
/* reset state */
will->stat = MQTT_MSG_BEGIN;
return rc;
}
| 0
|
270,411
|
static bool ok_png_read_palette(ok_png_decoder *decoder, uint32_t chunk_length) {
ok_png *png = decoder->png;
decoder->palette_length = chunk_length / 3;
if (decoder->palette_length > 256 || decoder->palette_length * 3 != chunk_length) {
ok_png_error(png, OK_PNG_ERROR_INVALID, "Invalid palette chunk length");
return false;
}
const bool src_is_bgr = decoder->is_ios_format;
const bool dst_is_bgr = (decoder->decode_flags & OK_PNG_COLOR_FORMAT_BGRA) != 0;
const bool should_byteswap = src_is_bgr != dst_is_bgr;
uint8_t *dst = decoder->palette;
uint8_t buffer[256 * 3];
if (!ok_read(decoder, buffer, 3 * decoder->palette_length)) {
return false;
}
uint8_t *in = buffer;
if (should_byteswap) {
for (uint32_t i = 0; i < decoder->palette_length; i++, in += 3, dst += 4) {
dst[0] = in[2];
dst[1] = in[1];
dst[2] = in[0];
dst[3] = 0xff;
}
} else {
for (uint32_t i = 0; i < decoder->palette_length; i++, in += 3, dst += 4) {
dst[0] = in[0];
dst[1] = in[1];
dst[2] = in[2];
dst[3] = 0xff;
}
}
return true;
}
| 0
|
199,681
|
static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
unsigned long param)
{
int drive = (long)bdev->bd_disk->private_data;
int type = ITYPE(drive_state[drive].fd_device);
int i;
int ret;
int size;
union inparam {
struct floppy_struct g; /* geometry */
struct format_descr f;
struct floppy_max_errors max_errors;
struct floppy_drive_params dp;
} inparam; /* parameters coming from user space */
const void *outparam; /* parameters passed back to user space */
/* convert compatibility eject ioctls into floppy eject ioctl.
* We do this in order to provide a means to eject floppy disks before
* installing the new fdutils package */
if (cmd == CDROMEJECT || /* CD-ROM eject */
cmd == 0x6470) { /* SunOS floppy eject */
DPRINT("obsolete eject ioctl\n");
DPRINT("please use floppycontrol --eject\n");
cmd = FDEJECT;
}
if (!((cmd & 0xff00) == 0x0200))
return -EINVAL;
/* convert the old style command into a new style command */
ret = normalize_ioctl(&cmd, &size);
if (ret)
return ret;
/* permission checks */
if (((cmd & 0x40) && !(mode & (FMODE_WRITE | FMODE_WRITE_IOCTL))) ||
((cmd & 0x80) && !capable(CAP_SYS_ADMIN)))
return -EPERM;
if (WARN_ON(size < 0 || size > sizeof(inparam)))
return -EINVAL;
/* copyin */
memset(&inparam, 0, sizeof(inparam));
if (_IOC_DIR(cmd) & _IOC_WRITE) {
ret = fd_copyin((void __user *)param, &inparam, size);
if (ret)
return ret;
}
switch (cmd) {
case FDEJECT:
if (drive_state[drive].fd_ref != 1)
/* somebody else has this drive open */
return -EBUSY;
if (lock_fdc(drive))
return -EINTR;
/* do the actual eject. Fails on
* non-Sparc architectures */
ret = fd_eject(UNIT(drive));
set_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags);
set_bit(FD_VERIFY_BIT, &drive_state[drive].flags);
process_fd_request();
return ret;
case FDCLRPRM:
if (lock_fdc(drive))
return -EINTR;
current_type[drive] = NULL;
floppy_sizes[drive] = MAX_DISK_SIZE << 1;
drive_state[drive].keep_data = 0;
return invalidate_drive(bdev);
case FDSETPRM:
case FDDEFPRM:
return set_geometry(cmd, &inparam.g, drive, type, bdev);
case FDGETPRM:
ret = get_floppy_geometry(drive, type,
(struct floppy_struct **)&outparam);
if (ret)
return ret;
memcpy(&inparam.g, outparam,
offsetof(struct floppy_struct, name));
outparam = &inparam.g;
break;
case FDMSGON:
drive_params[drive].flags |= FTD_MSG;
return 0;
case FDMSGOFF:
drive_params[drive].flags &= ~FTD_MSG;
return 0;
case FDFMTBEG:
if (lock_fdc(drive))
return -EINTR;
if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)
return -EINTR;
ret = drive_state[drive].flags;
process_fd_request();
if (ret & FD_VERIFY)
return -ENODEV;
if (!(ret & FD_DISK_WRITABLE))
return -EROFS;
return 0;
case FDFMTTRK:
if (drive_state[drive].fd_ref != 1)
return -EBUSY;
return do_format(drive, &inparam.f);
case FDFMTEND:
case FDFLUSH:
if (lock_fdc(drive))
return -EINTR;
return invalidate_drive(bdev);
case FDSETEMSGTRESH:
drive_params[drive].max_errors.reporting = (unsigned short)(param & 0x0f);
return 0;
case FDGETMAXERRS:
outparam = &drive_params[drive].max_errors;
break;
case FDSETMAXERRS:
drive_params[drive].max_errors = inparam.max_errors;
break;
case FDGETDRVTYP:
outparam = drive_name(type, drive);
SUPBOUND(size, strlen((const char *)outparam) + 1);
break;
case FDSETDRVPRM:
if (!valid_floppy_drive_params(inparam.dp.autodetect,
inparam.dp.native_format))
return -EINVAL;
drive_params[drive] = inparam.dp;
break;
case FDGETDRVPRM:
outparam = &drive_params[drive];
break;
case FDPOLLDRVSTAT:
if (lock_fdc(drive))
return -EINTR;
if (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)
return -EINTR;
process_fd_request();
fallthrough;
case FDGETDRVSTAT:
outparam = &drive_state[drive];
break;
case FDRESET:
return user_reset_fdc(drive, (int)param, true);
case FDGETFDCSTAT:
outparam = &fdc_state[FDC(drive)];
break;
case FDWERRORCLR:
memset(&write_errors[drive], 0, sizeof(write_errors[drive]));
return 0;
case FDWERRORGET:
outparam = &write_errors[drive];
break;
case FDRAWCMD:
if (type)
return -EINVAL;
if (lock_fdc(drive))
return -EINTR;
set_floppy(drive);
i = raw_cmd_ioctl(cmd, (void __user *)param);
if (i == -EINTR)
return -EINTR;
process_fd_request();
return i;
case FDTWADDLE:
if (lock_fdc(drive))
return -EINTR;
twaddle(current_fdc, current_drive);
process_fd_request();
return 0;
default:
return -EINVAL;
}
if (_IOC_DIR(cmd) & _IOC_READ)
return fd_copyout((void __user *)param, outparam, size);
return 0;
}
| 1
|
238,552
|
static bool verifier_state_scratched(const struct bpf_verifier_env *env)
{
return env->scratched_regs || env->scratched_stack_slots;
}
| 0
|
442,803
|
static size_t my_fread(void *buffer, size_t sz, size_t nmemb, void *userp)
{
size_t rc;
struct InStruct *in=(struct InStruct *)userp;
rc = fread(buffer, sz, nmemb, in->stream);
return rc;
}
| 0
|
404,714
|
static void __free_fdtable(struct fdtable *fdt)
{
kvfree(fdt->fd);
kvfree(fdt->open_fds);
kfree(fdt);
}
| 0
|
242,579
|
shim_mem_attrs_to_uefi_mem_attrs (uint64_t attrs)
{
uint64_t ret = EFI_MEMORY_RP |
EFI_MEMORY_RO |
EFI_MEMORY_XP;
if (attrs & MEM_ATTR_R)
ret &= ~EFI_MEMORY_RP;
if (attrs & MEM_ATTR_W)
ret &= ~EFI_MEMORY_RO;
if (attrs & MEM_ATTR_X)
ret &= ~EFI_MEMORY_XP;
return ret;
}
| 0
|
257,000
|
static int route4_delete(struct tcf_proto *tp, void *arg, bool *last,
bool rtnl_held, struct netlink_ext_ack *extack)
{
struct route4_head *head = rtnl_dereference(tp->root);
struct route4_filter *f = arg;
struct route4_filter __rcu **fp;
struct route4_filter *nf;
struct route4_bucket *b;
unsigned int h = 0;
int i, h1;
if (!head || !f)
return -EINVAL;
h = f->handle;
b = f->bkt;
fp = &b->ht[from_hash(h >> 16)];
for (nf = rtnl_dereference(*fp); nf;
fp = &nf->next, nf = rtnl_dereference(*fp)) {
if (nf == f) {
/* unlink it */
RCU_INIT_POINTER(*fp, rtnl_dereference(f->next));
/* Remove any fastmap lookups that might ref filter
* notice we unlink'd the filter so we can't get it
* back in the fastmap.
*/
route4_reset_fastmap(head);
/* Delete it */
tcf_unbind_filter(tp, &f->res);
tcf_exts_get_net(&f->exts);
tcf_queue_work(&f->rwork, route4_delete_filter_work);
/* Strip RTNL protected tree */
for (i = 0; i <= 32; i++) {
struct route4_filter *rt;
rt = rtnl_dereference(b->ht[i]);
if (rt)
goto out;
}
/* OK, session has no flows */
RCU_INIT_POINTER(head->table[to_hash(h)], NULL);
kfree_rcu(b, rcu);
break;
}
}
out:
*last = true;
for (h1 = 0; h1 <= 256; h1++) {
if (rcu_access_pointer(head->table[h1])) {
*last = false;
break;
}
}
return 0;
}
| 0
|
225,474
|
bool CanDedupControlWithRegularInput(const MutableGraphView& graph,
const NodeDef& control_node) {
return !IsIdentityConsumingSwitch(graph, control_node);
}
| 0
|
225,419
|
static int vidioc_g_fmt_out(struct file *file, void *priv,
struct v4l2_format *fmt)
{
struct v4l2_loopback_device *dev;
MARK();
dev = v4l2loopback_getdevice(file);
/*
* LATER: this should return the currently valid format
* gstreamer doesn't like it, if this returns -EINVAL, as it
* then concludes that there is _no_ valid format
* CHECK whether this assumption is wrong,
* or whether we have to always provide a valid format
*/
fmt->fmt.pix = dev->pix_format;
return 0;
}
| 0
|
348,426
|
static void mkiss_put(struct mkiss *ax)
{
if (refcount_dec_and_test(&ax->refcnt))
complete(&ax->dead);
}
| 0
|
348,425
|
static int mkiss_open(struct tty_struct *tty)
{
struct net_device *dev;
struct mkiss *ax;
int err;
if (!capable(CAP_NET_ADMIN))
return -EPERM;
if (tty->ops->write == NULL)
return -EOPNOTSUPP;
dev = alloc_netdev(sizeof(struct mkiss), "ax%d", NET_NAME_UNKNOWN,
ax_setup);
if (!dev) {
err = -ENOMEM;
goto out;
}
ax = netdev_priv(dev);
ax->dev = dev;
spin_lock_init(&ax->buflock);
refcount_set(&ax->refcnt, 1);
init_completion(&ax->dead);
ax->tty = tty;
tty->disc_data = ax;
tty->receive_room = 65535;
tty_driver_flush_buffer(tty);
/* Restore default settings */
dev->type = ARPHRD_AX25;
/* Perform the low-level AX25 initialization. */
err = ax_open(ax->dev);
if (err)
goto out_free_netdev;
err = register_netdev(dev);
if (err)
goto out_free_buffers;
/* after register_netdev() - because else printk smashes the kernel */
switch (crc_force) {
case 3:
ax->crcmode = CRC_MODE_SMACK;
printk(KERN_INFO "mkiss: %s: crc mode smack forced.\n",
ax->dev->name);
break;
case 2:
ax->crcmode = CRC_MODE_FLEX;
printk(KERN_INFO "mkiss: %s: crc mode flexnet forced.\n",
ax->dev->name);
break;
case 1:
ax->crcmode = CRC_MODE_NONE;
printk(KERN_INFO "mkiss: %s: crc mode disabled.\n",
ax->dev->name);
break;
case 0:
default:
crc_force = 0;
printk(KERN_INFO "mkiss: %s: crc mode is auto.\n",
ax->dev->name);
ax->crcmode = CRC_MODE_SMACK_TEST;
}
ax->crcauto = (crc_force ? 0 : 1);
netif_start_queue(dev);
/* Done. We have linked the TTY line to a channel. */
return 0;
out_free_buffers:
kfree(ax->rbuff);
kfree(ax->xbuff);
out_free_netdev:
free_netdev(dev);
out:
return err;
}
| 0
|
197,893
|
TfLiteStatus Gather(const TfLiteGatherParams& params, const TfLiteTensor* input,
const TfLiteTensor* positions, TfLiteTensor* output) {
tflite::GatherParams op_params;
op_params.axis = params.axis;
op_params.batch_dims = params.batch_dims;
optimized_ops::Gather(op_params, GetTensorShape(input),
GetTensorData<InputT>(input), GetTensorShape(positions),
GetTensorData<PositionsT>(positions),
GetTensorShape(output), GetTensorData<InputT>(output));
return kTfLiteOk;
}
| 1
|
225,645
|
void mfra_box_del(GF_Box *s)
{
GF_MovieFragmentRandomAccessBox *ptr = (GF_MovieFragmentRandomAccessBox *)s;
if (ptr == NULL) return;
gf_list_del(ptr->tfra_list);
gf_free(ptr);
}
| 0
|
338,056
|
HeapType WasmBinaryBuilder::getIndexedHeapType() {
auto index = getU32LEB();
if (index >= types.size()) {
throwError("invalid heap type index: " + std::to_string(index));
}
return types[index];
}
| 0
|
473,983
|
utf32le_code_to_mbclen(OnigCodePoint code ARG_UNUSED,
OnigEncoding enc ARG_UNUSED)
{
return 4;
}
| 0
|
459,028
|
http_ForceField(struct http *to, unsigned n, const char *t)
{
int i;
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
assert(n < HTTP_HDR_FIRST);
assert(n == HTTP_HDR_METHOD || n == HTTP_HDR_PROTO);
AN(t);
/* NB: method names and protocol versions are case-sensitive. */
if (to->hd[n].b == NULL || strcmp(to->hd[n].b, t)) {
i = (HTTP_HDR_UNSET - HTTP_HDR_METHOD);
i += to->logtag;
/* XXX: this is a dead branch */
if (n >= HTTP_HDR_FIRST)
VSLbt(to->vsl, (enum VSL_tag_e)i, to->hd[n]);
http_SetH(to, n, t);
}
}
| 0
|
244,263
|
void udta_box_del(GF_Box *s)
{
u32 i;
GF_UserDataMap *map;
GF_UserDataBox *ptr = (GF_UserDataBox *)s;
if (ptr == NULL) return;
i=0;
while ((map = (GF_UserDataMap *)gf_list_enum(ptr->recordList, &i))) {
gf_isom_box_array_del(map->boxes);
gf_free(map);
}
gf_list_del(ptr->recordList);
gf_free(ptr);
}
| 0
|
458,296
|
SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
{
struct task_struct *g, *p;
struct user_struct *user;
struct pid *pgrp;
kuid_t uid;
int ret = -ESRCH;
int tmpio;
rcu_read_lock();
switch (which) {
case IOPRIO_WHO_PROCESS:
if (!who)
p = current;
else
p = find_task_by_vpid(who);
if (p)
ret = get_task_ioprio(p);
break;
case IOPRIO_WHO_PGRP:
if (!who)
pgrp = task_pgrp(current);
else
pgrp = find_vpid(who);
do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
tmpio = get_task_ioprio(p);
if (tmpio < 0)
continue;
if (ret == -ESRCH)
ret = tmpio;
else
ret = ioprio_best(ret, tmpio);
} while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
break;
case IOPRIO_WHO_USER:
uid = make_kuid(current_user_ns(), who);
if (!who)
user = current_user();
else
user = find_user(uid);
if (!user)
break;
do_each_thread(g, p) {
if (!uid_eq(task_uid(p), user->uid) ||
!task_pid_vnr(p))
continue;
tmpio = get_task_ioprio(p);
if (tmpio < 0)
continue;
if (ret == -ESRCH)
ret = tmpio;
else
ret = ioprio_best(ret, tmpio);
} while_each_thread(g, p);
if (who)
free_uid(user);
break;
default:
ret = -EINVAL;
}
rcu_read_unlock();
return ret;
}
| 0
|
90,858
|
void GetTemporaryGlobalQuota() {
quota_status_ = kQuotaStatusUnknown;
quota_ = -1;
quota_manager_->GetTemporaryGlobalQuota(
callback_factory_.NewCallback(
&QuotaManagerTest::DidGetQuota));
}
| 0
|
356,708
|
void Statement::Work_BeginReset(Baton* baton) {
STATEMENT_BEGIN(Reset);
}
| 0
|
500,069
|
kssl_krb5_mk_req_extended (krb5_context CO,
krb5_auth_context * pACO,
krb5_const krb5_flags F,
krb5_data * pD1,
krb5_creds * pC,
krb5_data * pD2)
{
if (!krb5_loaded)
load_krb5_dll();
if ( p_krb5_mk_req_extended )
return(p_krb5_mk_req_extended(CO,pACO,F,pD1,pC,pD2));
else
return KRB5KRB_ERR_GENERIC;
}
| 0
|
503,986
|
static const char *field_get_default(const char *data)
{
const char *p;
p = strchr(data, ':');
if (p == NULL)
return "";
else {
/* default value given */
return p+1;
}
}
| 0
|
512,923
|
bool make_copy_field() const { return m_make_copy_field; }
| 0
|
218,999
|
Status ConstantFolding::RemoveReverse(const GraphProperties& properties,
bool use_shape_info,
GraphDef* optimized_graph,
NodeDef* node) {
if (!use_shape_info || node->op() != "ReverseV2") return Status::OK();
Tensor axis;
if (properties.HasInputProperties(node->name()) &&
GetTensorFromConstNode(node->input(1), &axis)) {
const auto& shape = properties.GetInputProperties(node->name())[0].shape();
if (shape.unknown_rank()) return Status::OK();
std::set<int> target_axes;
for (int j = 0; j < axis.NumElements(); ++j) {
// value of axis can be negative.
if (axis.dtype() == DT_INT64) {
target_axes.insert((axis.vec<int64_t>()(j) + shape.dim_size()) %
shape.dim_size());
} else {
target_axes.insert((axis.vec<int>()(j) + shape.dim_size()) %
shape.dim_size());
}
}
// The node is replaceable iff
// unknown_rank == false &&
// (dim_size == 0 || all dims have size 1 ||
// all dims with > 1 size are not in target_axes)
bool replaceable = true;
for (int j = 0; replaceable && j < shape.dim_size(); ++j) {
replaceable &=
shape.dim(j).size() == 1 || target_axes.find(j) == target_axes.end();
}
if (replaceable) {
ReplaceOperationWithIdentity(0, properties, node, optimized_graph);
}
}
return Status::OK();
}
| 0
|
261,887
|
njs_string_prototype_repeat(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
njs_index_t unused)
{
u_char *p;
int64_t n, max;
uint64_t size, length;
njs_int_t ret;
njs_value_t *this;
njs_string_prop_t string;
this = njs_argument(args, 0);
if (njs_slow_path(njs_is_null_or_undefined(this))) {
njs_type_error(vm, "cannot convert \"%s\"to object",
njs_type_string(this->type));
return NJS_ERROR;
}
ret = njs_value_to_string(vm, this, this);
if (njs_slow_path(ret != NJS_OK)) {
return ret;
}
ret = njs_value_to_integer(vm, njs_arg(args, nargs, 1), &n);
if (njs_slow_path(ret != NJS_OK)) {
return ret;
}
if (njs_slow_path(n < 0 || n == INT64_MAX)) {
njs_range_error(vm, NULL);
return NJS_ERROR;
}
(void) njs_string_prop(&string, this);
if (njs_slow_path(n == 0 || string.size == 0)) {
vm->retval = njs_string_empty;
return NJS_OK;
}
max = NJS_STRING_MAX_LENGTH / string.size;
if (njs_slow_path(n >= max)) {
njs_range_error(vm, NULL);
return NJS_ERROR;
}
size = string.size * n;
length = string.length * n;
p = njs_string_alloc(vm, &vm->retval, size, length);
if (njs_slow_path(p == NULL)) {
return NJS_ERROR;
}
while (n != 0) {
p = memcpy(p, string.start, string.size);
p += string.size;
n--;
}
return NJS_OK;
}
| 0
|
231,656
|
void accept(std::shared_ptr<ServerTransportParametersExtension>) override {}
| 0
|
427,159
|
static l_noret jumpscopeerror (LexState *ls, Labeldesc *gt) {
const char *varname = getstr(getlocalvardesc(ls->fs, gt->nactvar)->vd.name);
const char *msg = "<goto %s> at line %d jumps into the scope of local '%s'";
msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line, varname);
luaK_semerror(ls, msg); /* raise the error */
}
| 0
|
424,947
|
void iwl_trans_pcie_dbgfs_register(struct iwl_trans *trans)
{
struct dentry *dir = trans->dbgfs_dir;
DEBUGFS_ADD_FILE(rx_queue, dir, 0400);
DEBUGFS_ADD_FILE(tx_queue, dir, 0400);
DEBUGFS_ADD_FILE(interrupt, dir, 0600);
DEBUGFS_ADD_FILE(csr, dir, 0200);
DEBUGFS_ADD_FILE(fh_reg, dir, 0400);
DEBUGFS_ADD_FILE(rfkill, dir, 0600);
DEBUGFS_ADD_FILE(monitor_data, dir, 0400);
}
| 0
|
381,878
|
static void udf_merge_extents(struct inode *inode, struct kernel_long_ad *laarr,
int *endnum)
{
int i;
unsigned long blocksize = inode->i_sb->s_blocksize;
unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits;
for (i = 0; i < (*endnum - 1); i++) {
struct kernel_long_ad *li /*l[i]*/ = &laarr[i];
struct kernel_long_ad *lip1 /*l[i plus 1]*/ = &laarr[i + 1];
if (((li->extLength >> 30) == (lip1->extLength >> 30)) &&
(((li->extLength >> 30) ==
(EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) ||
((lip1->extLocation.logicalBlockNum -
li->extLocation.logicalBlockNum) ==
(((li->extLength & UDF_EXTENT_LENGTH_MASK) +
blocksize - 1) >> blocksize_bits)))) {
if (((li->extLength & UDF_EXTENT_LENGTH_MASK) +
(lip1->extLength & UDF_EXTENT_LENGTH_MASK) +
blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) {
lip1->extLength = (lip1->extLength -
(li->extLength &
UDF_EXTENT_LENGTH_MASK) +
UDF_EXTENT_LENGTH_MASK) &
~(blocksize - 1);
li->extLength = (li->extLength &
UDF_EXTENT_FLAG_MASK) +
(UDF_EXTENT_LENGTH_MASK + 1) -
blocksize;
lip1->extLocation.logicalBlockNum =
li->extLocation.logicalBlockNum +
((li->extLength &
UDF_EXTENT_LENGTH_MASK) >>
blocksize_bits);
} else {
li->extLength = lip1->extLength +
(((li->extLength &
UDF_EXTENT_LENGTH_MASK) +
blocksize - 1) & ~(blocksize - 1));
if (*endnum > (i + 2))
memmove(&laarr[i + 1], &laarr[i + 2],
sizeof(struct long_ad) *
(*endnum - (i + 2)));
i--;
(*endnum)--;
}
} else if (((li->extLength >> 30) ==
(EXT_NOT_RECORDED_ALLOCATED >> 30)) &&
((lip1->extLength >> 30) ==
(EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) {
udf_free_blocks(inode->i_sb, inode, &li->extLocation, 0,
((li->extLength &
UDF_EXTENT_LENGTH_MASK) +
blocksize - 1) >> blocksize_bits);
li->extLocation.logicalBlockNum = 0;
li->extLocation.partitionReferenceNum = 0;
if (((li->extLength & UDF_EXTENT_LENGTH_MASK) +
(lip1->extLength & UDF_EXTENT_LENGTH_MASK) +
blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) {
lip1->extLength = (lip1->extLength -
(li->extLength &
UDF_EXTENT_LENGTH_MASK) +
UDF_EXTENT_LENGTH_MASK) &
~(blocksize - 1);
li->extLength = (li->extLength &
UDF_EXTENT_FLAG_MASK) +
(UDF_EXTENT_LENGTH_MASK + 1) -
blocksize;
} else {
li->extLength = lip1->extLength +
(((li->extLength &
UDF_EXTENT_LENGTH_MASK) +
blocksize - 1) & ~(blocksize - 1));
if (*endnum > (i + 2))
memmove(&laarr[i + 1], &laarr[i + 2],
sizeof(struct long_ad) *
(*endnum - (i + 2)));
i--;
(*endnum)--;
}
} else if ((li->extLength >> 30) ==
(EXT_NOT_RECORDED_ALLOCATED >> 30)) {
udf_free_blocks(inode->i_sb, inode,
&li->extLocation, 0,
((li->extLength &
UDF_EXTENT_LENGTH_MASK) +
blocksize - 1) >> blocksize_bits);
li->extLocation.logicalBlockNum = 0;
li->extLocation.partitionReferenceNum = 0;
li->extLength = (li->extLength &
UDF_EXTENT_LENGTH_MASK) |
EXT_NOT_RECORDED_NOT_ALLOCATED;
}
}
}
| 0
|
477,291
|
static char *tipc_key_change_dump(struct tipc_key old, struct tipc_key new,
char *buf)
{
struct tipc_key *key = &old;
int k, i = 0;
char *s;
/* Output format: "[%s %s %s] -> [%s %s %s]", max len = 32 */
again:
i += scnprintf(buf + i, 32 - i, "[");
for (k = KEY_1; k <= KEY_3; k++) {
if (k == key->passive)
s = "pas";
else if (k == key->active)
s = "act";
else if (k == key->pending)
s = "pen";
else
s = "-";
i += scnprintf(buf + i, 32 - i,
(k != KEY_3) ? "%s " : "%s", s);
}
if (key != &new) {
i += scnprintf(buf + i, 32 - i, "] -> ");
key = &new;
goto again;
}
i += scnprintf(buf + i, 32 - i, "]");
return buf;
}
| 0
|
269,513
|
static void TIFFGetGPSProperties(TIFF *tiff,Image *image,
const ImageInfo* image_info,ExceptionInfo *exception)
{
#if defined(MAGICKCORE_HAVE_TIFFREADGPSDIRECTORY)
const char
*option;
tdir_t
directory;
#if defined(TIFF_VERSION_BIG)
uint64
#else
uint32
#endif
offset;
/*
Read GPS properties.
*/
option=GetImageOption(image_info,"tiff:gps-properties");
if (IsStringFalse(option) != MagickFalse)
return;
offset=0;
if (TIFFGetField(tiff,TIFFTAG_GPSIFD,&offset) != 1)
return;
directory=TIFFCurrentDirectory(tiff);
if (TIFFReadGPSDirectory(tiff,offset) == 1)
TIFFSetImageProperties(tiff,image,"exif:GPS",exception);
TIFFSetDirectory(tiff,directory);
#else
magick_unreferenced(tiff);
magick_unreferenced(image);
magick_unreferenced(image_info);
magick_unreferenced(exception);
#endif
}
| 0
|
506,434
|
mech_rpa_auth_phase3(struct auth_request *auth_request,
const unsigned char *data, size_t data_size)
{
static const unsigned char client_ack[3] = { 0x60, 0x01, 0x00 };
if ((data_size != sizeof(client_ack)) ||
(memcmp(data, client_ack, sizeof(client_ack)) != 0)) {
e_info(auth_request->mech_event,
"invalid token 5 or client rejects us");
auth_request_fail(auth_request);
} else {
auth_request_success(auth_request, "", 0);
}
}
| 0
|
221,406
|
static void nested_svm_triple_fault(struct kvm_vcpu *vcpu)
{
nested_svm_simple_vmexit(to_svm(vcpu), SVM_EXIT_SHUTDOWN);
}
| 0
|
231,782
|
TEST_F(QuicServerTransportTest, PingIsTreatedAsRetransmittable) {
PingFrame pingFrame;
ShortHeader header(
ProtectionType::KeyPhaseZero,
*server->getConn().serverConnectionId,
clientNextAppDataPacketNum++);
RegularQuicPacketBuilder builder(
server->getConn().udpSendPacketLen,
std::move(header),
0 /* largestAcked */);
builder.encodePacketHeader();
writeFrame(pingFrame, builder);
auto packet = std::move(builder).buildPacket();
deliverData(packetToBuf(packet));
EXPECT_TRUE(server->getConn().pendingEvents.scheduleAckTimeout);
}
| 0
|
259,616
|
void HierarchicalBitmapRequester::FetchRegion(LONG x,const struct Line *const *line,LONG *buffer)
{
int cnt = 8;
do {
if (*line)
memcpy(buffer,(*line)->m_pData + (x << 3),8 * sizeof(LONG));
buffer += 8;
line++;
} while(--cnt);
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.