idx
int64 | func
string | target
int64 |
|---|---|---|
441,830
|
SProcXkbPerClientFlags(ClientPtr client)
{
REQUEST(xkbPerClientFlagsReq);
swaps(&stuff->length);
REQUEST_SIZE_MATCH(xkbPerClientFlagsReq);
swaps(&stuff->deviceSpec);
swapl(&stuff->change);
swapl(&stuff->value);
swapl(&stuff->ctrlsToChange);
swapl(&stuff->autoCtrls);
swapl(&stuff->autoCtrlValues);
return ProcXkbPerClientFlags(client);
}
| 0
|
223,429
|
static SLJIT_INLINE void set_jumps(jump_list *list, struct sljit_label *label)
{
while (list)
{
/* sljit_set_label is clever enough to do nothing
if either the jump or the label is NULL. */
SET_LABEL(list->jump, label);
list = list->next;
}
}
| 0
|
291,780
|
static void free_clt(struct rtrs_clt_sess *clt)
{
free_permits(clt);
free_percpu(clt->pcpu_path);
/*
* release callback will free clt and destroy mutexes in last put
*/
device_unregister(&clt->dev);
}
| 0
|
387,829
|
InstanceKlass* InstanceKlass::nest_host(Symbol* validationException, TRAPS) {
InstanceKlass* nest_host_k = _nest_host;
if (nest_host_k == NULL) {
// need to resolve and save our nest-host class. This could be attempted
// concurrently but as the result is idempotent and we don't use the class
// then we do not need any synchronization beyond what is implicitly used
// during class loading.
if (_nest_host_index != 0) { // we have a real nest_host
// Before trying to resolve check if we're in a suitable context
if (!THREAD->can_call_java() && !_constants->tag_at(_nest_host_index).is_klass()) {
if (log_is_enabled(Trace, class, nestmates)) {
ResourceMark rm(THREAD);
log_trace(class, nestmates)("Rejected resolution of nest-host of %s in unsuitable thread",
this->external_name());
}
return NULL;
}
if (log_is_enabled(Trace, class, nestmates)) {
ResourceMark rm(THREAD);
log_trace(class, nestmates)("Resolving nest-host of %s using cp entry for %s",
this->external_name(),
_constants->klass_name_at(_nest_host_index)->as_C_string());
}
Klass* k = _constants->klass_at(_nest_host_index, THREAD);
if (HAS_PENDING_EXCEPTION) {
Handle exc_h = Handle(THREAD, PENDING_EXCEPTION);
if (exc_h->is_a(SystemDictionary::NoClassDefFoundError_klass())) {
// throw a new CDNFE with the original as its cause, and a clear msg
ResourceMark rm(THREAD);
char buf[200];
CLEAR_PENDING_EXCEPTION;
jio_snprintf(buf, sizeof(buf),
"Unable to load nest-host class (%s) of %s",
_constants->klass_name_at(_nest_host_index)->as_C_string(),
this->external_name());
log_trace(class, nestmates)("%s - NoClassDefFoundError", buf);
THROW_MSG_CAUSE_NULL(vmSymbols::java_lang_NoClassDefFoundError(), buf, exc_h);
}
// All other exceptions pass through (OOME, StackOverflowError, LinkageErrors etc).
return NULL;
}
// A valid nest-host is an instance class in the current package that lists this
// class as a nest member. If any of these conditions are not met we post the
// requested exception type (if any) and return NULL
const char* error = NULL;
// JVMS 5.4.4 indicates package check comes first
if (is_same_class_package(k)) {
// Now check actual membership. We can't be a member if our "host" is
// not an instance class.
if (k->is_instance_klass()) {
nest_host_k = InstanceKlass::cast(k);
bool is_member = nest_host_k->has_nest_member(this, CHECK_NULL);
if (is_member) {
// save resolved nest-host value
_nest_host = nest_host_k;
if (log_is_enabled(Trace, class, nestmates)) {
ResourceMark rm(THREAD);
log_trace(class, nestmates)("Resolved nest-host of %s to %s",
this->external_name(), k->external_name());
}
return nest_host_k;
}
}
error = "current type is not listed as a nest member";
} else {
error = "types are in different packages";
}
if (log_is_enabled(Trace, class, nestmates)) {
ResourceMark rm(THREAD);
log_trace(class, nestmates)("Type %s is not a nest member of resolved type %s: %s",
this->external_name(),
k->external_name(),
error);
}
if (validationException != NULL && THREAD->can_call_java()) {
ResourceMark rm(THREAD);
Exceptions::fthrow(THREAD_AND_LOCATION,
validationException,
"Type %s is not a nest member of %s: %s",
this->external_name(),
k->external_name(),
error
);
}
return NULL;
} else {
if (log_is_enabled(Trace, class, nestmates)) {
ResourceMark rm(THREAD);
log_trace(class, nestmates)("Type %s is not part of a nest: setting nest-host to self",
this->external_name());
}
// save resolved nest-host value
return (_nest_host = this);
}
}
return nest_host_k;
}
| 0
|
309,985
|
NCURSES_SP_NAME(init_pair) (NCURSES_SP_DCLx
NCURSES_PAIRS_T pair,
NCURSES_COLOR_T f,
NCURSES_COLOR_T b)
{
return _nc_init_pair(SP_PARM, pair, f, b);
}
| 0
|
338,104
|
bool WasmBinaryBuilder::maybeVisitRefCast(Expression*& out, uint32_t code) {
if (code == BinaryConsts::RefCast) {
auto* rtt = popNonVoidExpression();
auto* ref = popNonVoidExpression();
out = Builder(wasm).makeRefCast(ref, rtt);
return true;
} else if (code == BinaryConsts::RefCastStatic) {
auto intendedType = getIndexedHeapType();
auto* ref = popNonVoidExpression();
out = Builder(wasm).makeRefCast(ref, intendedType);
return true;
}
return false;
}
| 0
|
386,485
|
void DL_Dxf::writePolylineEnd(DL_WriterA& dw) {
if (version==DL_VERSION_2000) {
} else {
dw.entity("SEQEND");
}
}
| 0
|
238,771
|
fuzzy_match_func_sort(fuzmatch_str_T *fm, int sz)
{
// Sort the list by the descending order of the match score
qsort((void *)fm, (size_t)sz, sizeof(fuzmatch_str_T),
fuzzy_match_func_compare);
}
| 0
|
386,518
|
void DL_Dxf::writeLayer(DL_WriterA& dw,
const DL_LayerData& data,
const DL_Attributes& attrib) {
if (data.name.empty()) {
std::cerr << "DL_Dxf::writeLayer: "
<< "Layer name must not be empty\n";
return;
}
int color = attrib.getColor();
if (color>=256) {
std::cerr << "Layer color cannot be " << color << ". Changed to 7.\n";
color = 7;
}
if (data.off) {
// negative color value means layer is off:
color = -color;
}
if (data.name == "0") {
dw.tableLayerEntry(0x10);
} else {
dw.tableLayerEntry();
}
dw.dxfString(2, data.name);
dw.dxfInt(70, data.flags);
dw.dxfInt(62, color);
if (version>=DL_VERSION_2000 && attrib.getColor24()!=-1) {
dw.dxfInt(420, attrib.getColor24());
}
dw.dxfString(6, (attrib.getLinetype().length()==0 ?
std::string("CONTINUOUS") : attrib.getLinetype()));
if (version>=DL_VERSION_2000) {
// layer defpoints cannot be plotted
std::string lstr = data.name;
std::transform(lstr.begin(), lstr.end(), lstr.begin(), tolower);
if (lstr=="defpoints") {
dw.dxfInt(290, 0);
}
}
if (version>=DL_VERSION_2000 && attrib.getWidth()!=-1) {
dw.dxfInt(370, attrib.getWidth());
}
if (version>=DL_VERSION_2000) {
dw.dxfHex(390, 0xF);
}
}
| 0
|
270,372
|
static uint32_t ok_png_get_height_for_pass(const ok_png_decoder *decoder) {
const uint32_t h = decoder->png->height;
if (decoder->interlace_method == 0) {
return h;
}
switch (decoder->interlace_pass) {
case 1: return (h + 7) / 8;
case 2: return (h + 7) / 8;
case 3: return (h + 3) / 8;
case 4: return (h + 3) / 4;
case 5: return (h + 1) / 4;
case 6: return (h + 1) / 2;
case 7: return h / 2;
default: return 0;
}
}
| 0
|
222,858
|
Status GraphProperties::UpdateEnter(SymbolicShapeRefiner* shape_refiner,
const NodeDef* node, bool* new_shapes) {
InferenceContext* ic = shape_refiner->GetContext(node);
if (!ic) {
TF_RETURN_IF_ERROR(shape_refiner->UpdateNode(node, new_shapes));
ic = shape_refiner->GetContext(node);
}
GraphView::InputPort port(node, 0);
GraphView::OutputPort fanin = shape_refiner->graph().GetRegularFanin(port);
InferenceContext* src_ic = shape_refiner->GetContext(fanin.node);
ShapeHandle input = src_ic->output(fanin.port_id);
if (!ic->output(0).SameHandle(input)) {
ic->SetInput(0, input);
ic->set_output(0, input);
*new_shapes = true;
}
auto* outputs = src_ic->output_handle_shapes_and_types(fanin.port_id);
if (outputs) {
ic->set_input_handle_shapes_and_types(0, *outputs);
ic->set_output_handle_shapes_and_types(0, *outputs);
*new_shapes = true;
}
return Status::OK();
}
| 0
|
462,243
|
static void PUTVAL16H(pj_uint8_t *buf, unsigned pos, pj_uint16_t hval)
{
buf[pos+0] = (pj_uint8_t) ((hval & 0xFF00) >> 8);
buf[pos+1] = (pj_uint8_t) ((hval & 0x00FF) >> 0);
}
| 0
|
512,735
|
bool Item_func_case::date_op(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
DBUG_ASSERT(fixed == 1);
Item *item= find_item();
if (!item)
return (null_value= true);
Datetime_truncation_not_needed dt(thd, item, fuzzydate);
return (null_value= dt.copy_to_mysql_time(ltime, mysql_timestamp_type()));
}
| 0
|
512,411
|
bool vcol_assignment_allowed_value() const { return vcol_assignment_ok; }
| 0
|
328,921
|
R_API void r_bin_java_bootstrap_method_argument_free(void /*RBinJavaBootStrapArgument*/ *b) {
RBinJavaBootStrapArgument *bsm_arg = b;
if (bsm_arg) {
RBinJavaCPTypeMetas *tm = (RBinJavaCPTypeMetas*)bsm_arg->argument_info_cp_obj;
if (tm) {
if (tm && (size_t)(tm->allocs) > 1024 && tm->allocs->delete_obj) {
tm->allocs->delete_obj (tm);
}
bsm_arg->argument_info_cp_obj = NULL;
}
free (bsm_arg);
}
}
| 0
|
359,558
|
bgp_open_receive (struct peer *peer, bgp_size_t size)
{
int ret;
u_char version;
u_char optlen;
u_int16_t holdtime;
u_int16_t send_holdtime;
as_t remote_as;
struct peer *realpeer;
struct in_addr remote_id;
int capability;
u_int8_t notify_data_remote_as[2];
u_int8_t notify_data_remote_id[4];
realpeer = NULL;
/* Parse open packet. */
version = stream_getc (peer->ibuf);
memcpy (notify_data_remote_as, stream_pnt (peer->ibuf), 2);
remote_as = stream_getw (peer->ibuf);
holdtime = stream_getw (peer->ibuf);
memcpy (notify_data_remote_id, stream_pnt (peer->ibuf), 4);
remote_id.s_addr = stream_get_ipv4 (peer->ibuf);
/* Receive OPEN message log */
if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("%s rcv OPEN, version %d, remote-as %d, holdtime %d, id %s",
peer->host, version, remote_as, holdtime,
inet_ntoa (remote_id));
/* Lookup peer from Open packet. */
if (CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
{
int as = 0;
realpeer = peer_lookup_with_open (&peer->su, remote_as, &remote_id, &as);
if (! realpeer)
{
/* Peer's source IP address is check in bgp_accept(), so this
must be AS number mismatch or remote-id configuration
mismatch. */
if (as)
{
if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("%s bad OPEN, wrong router identifier %s",
peer->host, inet_ntoa (remote_id));
bgp_notify_send_with_data (peer, BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_BAD_BGP_IDENT,
notify_data_remote_id, 4);
}
else
{
if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("%s bad OPEN, remote AS is %d, expected %d",
peer->host, remote_as, peer->as);
bgp_notify_send_with_data (peer, BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_BAD_PEER_AS,
notify_data_remote_as, 2);
}
return -1;
}
}
/* When collision is detected and this peer is closed. Retrun
immidiately. */
ret = bgp_collision_detect (peer, remote_id);
if (ret < 0)
return ret;
/* Hack part. */
if (CHECK_FLAG (peer->sflags, PEER_STATUS_ACCEPT_PEER))
{
if (realpeer->status == Established
&& CHECK_FLAG (realpeer->sflags, PEER_STATUS_NSF_MODE))
{
realpeer->last_reset = PEER_DOWN_NSF_CLOSE_SESSION;
SET_FLAG (realpeer->sflags, PEER_STATUS_NSF_WAIT);
}
else if (ret == 0 && realpeer->status != Active
&& realpeer->status != OpenSent
&& realpeer->status != OpenConfirm)
{
if (BGP_DEBUG (events, EVENTS))
zlog_debug ("%s peer status is %s close connection",
realpeer->host, LOOKUP (bgp_status_msg,
realpeer->status));
bgp_notify_send (peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_CONNECT_REJECT);
return -1;
}
if (BGP_DEBUG (events, EVENTS))
zlog_debug ("%s [Event] Transfer temporary BGP peer to existing one",
peer->host);
bgp_stop (realpeer);
/* Transfer file descriptor. */
realpeer->fd = peer->fd;
peer->fd = -1;
/* Transfer input buffer. */
stream_free (realpeer->ibuf);
realpeer->ibuf = peer->ibuf;
realpeer->packet_size = peer->packet_size;
peer->ibuf = NULL;
/* Transfer status. */
realpeer->status = peer->status;
bgp_stop (peer);
/* peer pointer change. Open packet send to neighbor. */
peer = realpeer;
bgp_open_send (peer);
if (peer->fd < 0)
{
zlog_err ("bgp_open_receive peer's fd is negative value %d",
peer->fd);
return -1;
}
BGP_READ_ON (peer->t_read, bgp_read, peer->fd);
}
/* remote router-id check. */
if (remote_id.s_addr == 0
|| ntohl (remote_id.s_addr) >= 0xe0000000
|| ntohl (peer->local_id.s_addr) == ntohl (remote_id.s_addr))
{
if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("%s bad OPEN, wrong router identifier %s",
peer->host, inet_ntoa (remote_id));
bgp_notify_send_with_data (peer,
BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_BAD_BGP_IDENT,
notify_data_remote_id, 4);
return -1;
}
/* Set remote router-id */
peer->remote_id = remote_id;
/* Peer BGP version check. */
if (version != BGP_VERSION_4)
{
u_int8_t maxver = BGP_VERSION_4;
if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("%s bad protocol version, remote requested %d, local request %d",
peer->host, version, BGP_VERSION_4);
bgp_notify_send_with_data (peer,
BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_UNSUP_VERSION,
&maxver, 1);
return -1;
}
/* Check neighbor as number. */
if (remote_as != peer->as)
{
if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("%s bad OPEN, remote AS is %d, expected %d",
peer->host, remote_as, peer->as);
bgp_notify_send_with_data (peer,
BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_BAD_PEER_AS,
notify_data_remote_as, 2);
return -1;
}
/* From the rfc: Upon receipt of an OPEN message, a BGP speaker MUST
calculate the value of the Hold Timer by using the smaller of its
configured Hold Time and the Hold Time received in the OPEN message.
The Hold Time MUST be either zero or at least three seconds. An
implementation may reject connections on the basis of the Hold Time. */
if (holdtime < 3 && holdtime != 0)
{
bgp_notify_send (peer,
BGP_NOTIFY_OPEN_ERR,
BGP_NOTIFY_OPEN_UNACEP_HOLDTIME);
return -1;
}
/* From the rfc: A reasonable maximum time between KEEPALIVE messages
would be one third of the Hold Time interval. KEEPALIVE messages
MUST NOT be sent more frequently than one per second. An
implementation MAY adjust the rate at which it sends KEEPALIVE
messages as a function of the Hold Time interval. */
if (CHECK_FLAG (peer->config, PEER_CONFIG_TIMER))
send_holdtime = peer->holdtime;
else
send_holdtime = peer->bgp->default_holdtime;
if (holdtime < send_holdtime)
peer->v_holdtime = holdtime;
else
peer->v_holdtime = send_holdtime;
peer->v_keepalive = peer->v_holdtime / 3;
/* Open option part parse. */
capability = 0;
optlen = stream_getc (peer->ibuf);
if (optlen != 0)
{
ret = bgp_open_option_parse (peer, optlen, &capability);
if (ret < 0)
return ret;
}
else
{
if (BGP_DEBUG (normal, NORMAL))
zlog_debug ("%s rcvd OPEN w/ OPTION parameter len: 0",
peer->host);
}
/* Override capability. */
if (! capability || CHECK_FLAG (peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY))
{
peer->afc_nego[AFI_IP][SAFI_UNICAST] = peer->afc[AFI_IP][SAFI_UNICAST];
peer->afc_nego[AFI_IP][SAFI_MULTICAST] = peer->afc[AFI_IP][SAFI_MULTICAST];
peer->afc_nego[AFI_IP6][SAFI_UNICAST] = peer->afc[AFI_IP6][SAFI_UNICAST];
peer->afc_nego[AFI_IP6][SAFI_MULTICAST] = peer->afc[AFI_IP6][SAFI_MULTICAST];
}
/* Get sockname. */
bgp_getsockname (peer);
BGP_EVENT_ADD (peer, Receive_OPEN_message);
peer->packet_size = 0;
if (peer->ibuf)
stream_reset (peer->ibuf);
return 0;
}
| 0
|
451,882
|
static uint_fast32_t jpc_abstorelstepsize(jpc_fix_t absdelta, int scaleexpn)
{
int p;
uint_fast32_t mant;
uint_fast32_t expn;
int n;
if (absdelta < 0) {
return UINT_FAST32_MAX;
}
p = jpc_fix_firstone(absdelta) - JPC_FIX_FRACBITS;
n = 11 - jpc_fix_firstone(absdelta);
mant = ((n < 0) ? (absdelta >> (-n)) : (absdelta << n)) & 0x7ff;
expn = scaleexpn - p;
if (scaleexpn < p) {
return UINT_FAST32_MAX;
}
if (expn >= 0x1f)
return UINT_FAST32_MAX;
return JPC_QCX_EXPN(expn) | JPC_QCX_MANT(mant);
}
| 0
|
343,325
|
static int safe_fd_isset(const int fd, const fd_set * const fds)
{
if (fd == -1) {
return 0;
}
return FD_ISSET(fd, fds);
}
| 0
|
202,082
|
R_API RBinJavaAttrInfo *r_bin_java_bootstrap_methods_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {
ut32 i = 0;
RBinJavaBootStrapMethod *bsm = NULL;
ut64 offset = 0;
RBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);
offset += 6;
if (attr) {
attr->type = R_BIN_JAVA_ATTR_TYPE_BOOTSTRAP_METHODS_ATTR;
attr->info.bootstrap_methods_attr.num_bootstrap_methods = R_BIN_JAVA_USHORT (buffer, offset);
offset += 2;
attr->info.bootstrap_methods_attr.bootstrap_methods = r_list_newf (r_bin_java_bootstrap_method_free);
for (i = 0; i < attr->info.bootstrap_methods_attr.num_bootstrap_methods; i++) {
// bsm = r_bin_java_bootstrap_method_new (bin, bin->b->cur);
if (offset >= sz) {
break;
}
bsm = r_bin_java_bootstrap_method_new (buffer + offset, sz - offset, buf_offset + offset);
if (bsm) {
offset += bsm->size;
r_list_append (attr->info.bootstrap_methods_attr.bootstrap_methods, (void *) bsm);
} else {
// TODO eprintf Failed to read the %d boot strap method.
}
}
attr->size = offset;
}
return attr;
}
| 1
|
226,135
|
GF_Err dmax_box_size(GF_Box *s)
{
s->size += 4;
return GF_OK;
}
| 0
|
253,590
|
smb2_is_status_io_timeout(char *buf)
{
struct smb2_hdr *shdr = (struct smb2_hdr *)buf;
if (shdr->Status == STATUS_IO_TIMEOUT)
return true;
else
return false;
}
| 0
|
282,882
|
int rsi_send_rx_filter_frame(struct rsi_common *common, u16 rx_filter_word)
{
struct rsi_mac_frame *cmd_frame;
struct sk_buff *skb;
rsi_dbg(MGMT_TX_ZONE, "Sending RX filter frame\n");
skb = dev_alloc_skb(FRAME_DESC_SZ);
if (!skb) {
rsi_dbg(ERR_ZONE, "%s: Failed in allocation of skb\n",
__func__);
return -ENOMEM;
}
memset(skb->data, 0, FRAME_DESC_SZ);
cmd_frame = (struct rsi_mac_frame *)skb->data;
cmd_frame->desc_word[0] = cpu_to_le16(RSI_WIFI_MGMT_Q << 12);
cmd_frame->desc_word[1] = cpu_to_le16(SET_RX_FILTER);
cmd_frame->desc_word[4] = cpu_to_le16(rx_filter_word);
skb_put(skb, FRAME_DESC_SZ);
return rsi_send_internal_mgmt_frame(common, skb);
}
| 0
|
267,921
|
char *ogs_nas_5gs_suci_from_mobile_identity(
ogs_nas_5gs_mobile_identity_t *mobile_identity)
{
ogs_nas_5gs_mobile_identity_suci_t *mobile_identity_suci = NULL;
ogs_plmn_id_t plmn_id;
char tmp[OGS_NAS_MAX_SCHEME_OUTPUT_LEN*2+1];
char routing_indicator[5];
char *suci = NULL;
int scheme_output_len = 0;
ogs_assert(mobile_identity);
mobile_identity_suci =
(ogs_nas_5gs_mobile_identity_suci_t *)mobile_identity->buffer;
ogs_assert(mobile_identity_suci);
ogs_expect_or_return_val(mobile_identity_suci->h.supi_format ==
OGS_NAS_5GS_SUPI_FORMAT_IMSI, NULL);
ogs_expect_or_return_val(mobile_identity_suci->protection_scheme_id ==
OGS_NAS_5GS_NULL_SCHEME, NULL);
suci = ogs_msprintf("suci-%d-", mobile_identity_suci->h.supi_format);
ogs_expect_or_return_val(suci, NULL);
ogs_nas_to_plmn_id(&plmn_id, &mobile_identity_suci->nas_plmn_id);
if (ogs_plmn_id_mnc_len(&plmn_id) == 2) {
suci = ogs_mstrcatf(suci, "%03d-%02d-",
ogs_plmn_id_mcc(&plmn_id), ogs_plmn_id_mnc(&plmn_id));
ogs_expect_or_return_val(suci, NULL);
} else {
suci = ogs_mstrcatf(suci, "%03d-%03d-",
ogs_plmn_id_mcc(&plmn_id), ogs_plmn_id_mnc(&plmn_id));
ogs_expect_or_return_val(suci, NULL);
}
memset(routing_indicator, 0, sizeof(routing_indicator));
if (mobile_identity_suci->routing_indicator1 != 0xf) {
routing_indicator[0] =
mobile_identity_suci->routing_indicator1 + '0';
if (mobile_identity_suci->routing_indicator2 != 0xf) {
routing_indicator[1] =
mobile_identity_suci->routing_indicator2 + '0';
if (mobile_identity_suci->routing_indicator3 != 0xf) {
routing_indicator[2] =
mobile_identity_suci->routing_indicator3 + '0';
if (mobile_identity_suci->routing_indicator4 != 0xf)
routing_indicator[3] =
mobile_identity_suci->routing_indicator4 + '0';
}
}
}
scheme_output_len = mobile_identity->length - 8;
ogs_expect_or_return_val(scheme_output_len > 0, NULL);
ogs_expect_or_return_val(
scheme_output_len <= OGS_NAS_MAX_SCHEME_OUTPUT_LEN, NULL);
ogs_buffer_to_bcd(mobile_identity_suci->scheme_output,
scheme_output_len, tmp);
suci = ogs_mstrcatf(suci, "%s-%d-%d-%s",
routing_indicator,
mobile_identity_suci->protection_scheme_id,
mobile_identity_suci->home_network_pki_value,
tmp);
ogs_expect(suci);
return suci;
}
| 0
|
281,135
|
__xfrm4_selector_match(const struct xfrm_selector *sel, const struct flowi *fl)
{
const struct flowi4 *fl4 = &fl->u.ip4;
return addr4_match(fl4->daddr, sel->daddr.a4, sel->prefixlen_d) &&
addr4_match(fl4->saddr, sel->saddr.a4, sel->prefixlen_s) &&
!((xfrm_flowi_dport(fl, &fl4->uli) ^ sel->dport) & sel->dport_mask) &&
!((xfrm_flowi_sport(fl, &fl4->uli) ^ sel->sport) & sel->sport_mask) &&
(fl4->flowi4_proto == sel->proto || !sel->proto) &&
(fl4->flowi4_oif == sel->ifindex || !sel->ifindex);
}
| 0
|
210,571
|
int cx23888_ir_probe(struct cx23885_dev *dev)
{
struct cx23888_ir_state *state;
struct v4l2_subdev *sd;
struct v4l2_subdev_ir_parameters default_params;
int ret;
state = kzalloc(sizeof(struct cx23888_ir_state), GFP_KERNEL);
if (state == NULL)
return -ENOMEM;
spin_lock_init(&state->rx_kfifo_lock);
if (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE, GFP_KERNEL))
return -ENOMEM;
state->dev = dev;
sd = &state->sd;
v4l2_subdev_init(sd, &cx23888_ir_controller_ops);
v4l2_set_subdevdata(sd, state);
/* FIXME - fix the formatting of dev->v4l2_dev.name and use it */
snprintf(sd->name, sizeof(sd->name), "%s/888-ir", dev->name);
sd->grp_id = CX23885_HW_888_IR;
ret = v4l2_device_register_subdev(&dev->v4l2_dev, sd);
if (ret == 0) {
/*
* Ensure no interrupts arrive from '888 specific conditions,
* since we ignore them in this driver to have commonality with
* similar IR controller cores.
*/
cx23888_ir_write4(dev, CX23888_IR_IRQEN_REG, 0);
mutex_init(&state->rx_params_lock);
default_params = default_rx_params;
v4l2_subdev_call(sd, ir, rx_s_parameters, &default_params);
mutex_init(&state->tx_params_lock);
default_params = default_tx_params;
v4l2_subdev_call(sd, ir, tx_s_parameters, &default_params);
} else {
kfifo_free(&state->rx_kfifo);
}
return ret;
}
| 1
|
336,585
|
static red::shared_ptr<RedVDIReadBuf> vdi_read_buf_new(RedCharDeviceVDIPort *dev)
{
auto buf = red::make_shared<RedVDIReadBuf>();
buf->dev = dev;
return buf;
}
| 0
|
202,892
|
void dostor(char *name, const int append, const int autorename)
{
ULHandler ulhandler;
int f;
const char *ul_name = NULL;
const char *atomic_file = NULL;
off_t filesize = (off_t) 0U;
struct stat st;
double started = 0.0;
signed char overwrite = 0;
int overflow = 0;
int ret = -1;
off_t max_filesize = (off_t) -1;
#ifdef QUOTAS
Quota quota;
#endif
const char *name2 = NULL;
if (type < 1 || (type == 1 && restartat > (off_t) 1)) {
addreply_noformat(503, MSG_NO_ASCII_RESUME);
goto end;
}
#ifndef ANON_CAN_RESUME
if (guest != 0 && anon_noupload != 0) {
addreply_noformat(550, MSG_ANON_CANT_OVERWRITE);
goto end;
}
#endif
if (ul_check_free_space(name, -1.0) == 0) {
addreply_noformat(552, MSG_NO_DISK_SPACE);
goto end;
}
if (checknamesanity(name, dot_write_ok) != 0) {
addreply(553, MSG_SANITY_FILE_FAILURE, name);
goto end;
}
if (autorename != 0) {
no_truncate = 1;
}
if (restartat > (off_t) 0 || no_truncate != 0) {
if ((atomic_file = get_atomic_file(name)) == NULL) {
addreply(553, MSG_SANITY_FILE_FAILURE, name);
goto end;
}
if (restartat > (off_t) 0 &&
rename(name, atomic_file) != 0 && errno != ENOENT) {
error(553, MSG_RENAME_FAILURE);
atomic_file = NULL;
goto end;
}
}
if (atomic_file != NULL) {
ul_name = atomic_file;
} else {
ul_name = name;
}
if (atomic_file == NULL &&
(f = open(ul_name, O_WRONLY | O_NOFOLLOW)) != -1) {
overwrite++;
} else if ((f = open(ul_name, O_CREAT | O_WRONLY | O_NOFOLLOW,
(mode_t) 0777 & ~u_mask)) == -1) {
error(553, MSG_OPEN_FAILURE2);
goto end;
}
if (fstat(f, &st) < 0) {
(void) close(f);
error(553, MSG_STAT_FAILURE2);
goto end;
}
if (!S_ISREG(st.st_mode)) {
(void) close(f);
addreply_noformat(550, MSG_NOT_REGULAR_FILE);
goto end;
}
alarm(MAX_SESSION_XFER_IDLE);
/* Anonymous users *CAN* overwrite 0-bytes files - This is the right behavior */
if (st.st_size > (off_t) 0) {
#ifndef ANON_CAN_RESUME
if (guest != 0) {
addreply_noformat(550, MSG_ANON_CANT_OVERWRITE);
(void) close(f);
goto end;
}
#endif
if (append != 0) {
restartat = st.st_size;
}
} else {
restartat = (off_t) 0;
}
if (restartat > st.st_size) {
restartat = st.st_size;
}
if (restartat > (off_t) 0 && lseek(f, restartat, SEEK_SET) < (off_t) 0) {
(void) close(f);
error(451, "seek");
goto end;
}
if (restartat < st.st_size) {
if (ftruncate(f, restartat) < 0) {
(void) close(f);
error(451, "ftruncate");
goto end;
}
#ifdef QUOTAS
if (restartat != st.st_size) {
(void) quota_update(NULL, 0LL,
(long long) (restartat - st.st_size),
&overflow);
}
#endif
}
#ifdef QUOTAS
if (quota_update("a, 0LL, 0LL, &overflow) == 0 &&
(overflow > 0 || quota.files >= user_quota_files ||
quota.size > user_quota_size ||
(max_filesize >= (off_t) 0 &&
(max_filesize = user_quota_size - quota.size) < (off_t) 0))) {
overflow = 1;
(void) close(f);
goto afterquota;
}
#endif
opendata();
if (xferfd == -1) {
(void) close(f);
goto end;
}
doreply();
# ifdef WITH_TLS
if (data_protection_level == CPL_PRIVATE) {
tls_init_data_session(xferfd, passive);
}
# endif
state_needs_update = 1;
setprocessname("pure-ftpd (UPLOAD)");
filesize = restartat;
#ifdef FTPWHO
if (shm_data_cur != NULL) {
const size_t sl = strlen(name);
ftpwho_lock();
shm_data_cur->state = FTPWHO_STATE_UPLOAD;
shm_data_cur->download_total_size = (off_t) 0U;
shm_data_cur->download_current_size = (off_t) filesize;
shm_data_cur->restartat = restartat;
(void) time(&shm_data_cur->xfer_date);
if (sl < sizeof shm_data_cur->filename) {
memcpy(shm_data_cur->filename, name, sl);
shm_data_cur->filename[sl] = 0;
} else {
memcpy(shm_data_cur->filename,
&name[sl - sizeof shm_data_cur->filename - 1U],
sizeof shm_data_cur->filename);
}
ftpwho_unlock();
}
#endif
/* Here starts the real upload code */
started = get_usec_time();
if (ul_init(&ulhandler, clientfd, tls_cnx, xferfd, name, f, tls_data_cnx,
restartat, type == 1, throttling_bandwidth_ul,
max_filesize) == 0) {
ret = ul_send(&ulhandler);
ul_exit(&ulhandler);
} else {
ret = -1;
}
(void) close(f);
closedata();
/* Here ends the real upload code */
#ifdef SHOW_REAL_DISK_SPACE
if (FSTATFS(f, &statfsbuf) == 0) {
double space;
space = (double) STATFS_BAVAIL(statfsbuf) *
(double) STATFS_FRSIZE(statfsbuf);
if (space > 524288.0) {
addreply(0, MSG_SPACE_FREE_M, space / 1048576.0);
} else {
addreply(0, MSG_SPACE_FREE_K, space / 1024.0);
}
}
#endif
uploaded += (unsigned long long) ulhandler.total_uploaded;
{
off_t atomic_file_size;
off_t original_file_size;
int files_count;
if (overwrite == 0) {
files_count = 1;
} else {
files_count = 0;
}
if (autorename != 0 && restartat == (off_t) 0) {
if ((atomic_file_size = get_file_size(atomic_file)) < (off_t) 0) {
goto afterquota;
}
if (tryautorename(atomic_file, name, &name2) != 0) {
error(553, MSG_RENAME_FAILURE);
goto afterquota;
} else {
#ifdef QUOTAS
ul_quota_update(name2 ? name2 : name, 1, atomic_file_size);
#endif
atomic_file = NULL;
}
} else if (atomic_file != NULL) {
if ((atomic_file_size = get_file_size(atomic_file)) < (off_t) 0) {
goto afterquota;
}
if ((original_file_size = get_file_size(name)) < (off_t) 0 ||
restartat > original_file_size) {
original_file_size = restartat;
}
if (rename(atomic_file, name) != 0) {
error(553, MSG_RENAME_FAILURE);
goto afterquota;
} else {
#ifdef QUOTAS
overflow = ul_quota_update
(name, files_count, atomic_file_size - original_file_size);
#endif
atomic_file = NULL;
}
} else {
#ifdef QUOTAS
overflow = ul_quota_update
(name, files_count, ulhandler.total_uploaded);
#endif
}
}
afterquota:
if (overflow > 0) {
addreply(552, MSG_QUOTA_EXCEEDED, name);
} else {
if (ret == 0) {
addreply_noformat(226, MSG_TRANSFER_SUCCESSFUL);
} else {
addreply_noformat(451, MSG_ABORTED);
}
displayrate(MSG_UPLOADED, ulhandler.total_uploaded, started,
name2 ? name2 : name, 1);
}
end:
restartat = (off_t) 0;
if (atomic_file != NULL) {
unlink(atomic_file);
atomic_file = NULL;
}
}
| 1
|
310,177
|
drv_rescol(TERMINAL_CONTROL_BLOCK * TCB)
{
bool result = FALSE;
SCREEN *sp;
AssertTCB();
SetSP();
if (orig_pair != 0) {
NCURSES_PUTP2("orig_pair", orig_pair);
result = TRUE;
}
return result;
}
| 0
|
369,422
|
static inline bool __io_fill_cqe_req(struct io_kiocb *req, s32 res, u32 cflags)
{
trace_io_uring_complete(req->ctx, req, req->user_data, res, cflags);
return __io_fill_cqe(req->ctx, req->user_data, res, cflags);
}
| 0
|
512,763
|
bool val_native_with_conversion_from_item(THD *thd, Item *item, Native *to,
const Type_handler *handler)
{
DBUG_ASSERT(is_fixed());
return null_value= item->val_native_with_conversion(thd, to, handler);
}
| 0
|
448,919
|
int ZEXPORT inflateCopy(dest, source)
z_streamp dest;
z_streamp source;
{
struct inflate_state FAR *state;
struct inflate_state FAR *copy;
unsigned char FAR *window;
unsigned wsize;
/* check input */
if (inflateStateCheck(source) || dest == Z_NULL)
return Z_STREAM_ERROR;
state = (struct inflate_state FAR *)source->state;
/* allocate space */
copy = (struct inflate_state FAR *)
ZALLOC(source, 1, sizeof(struct inflate_state));
if (copy == Z_NULL) return Z_MEM_ERROR;
window = Z_NULL;
if (state->window != Z_NULL) {
window = (unsigned char FAR *)
ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
if (window == Z_NULL) {
ZFREE(source, copy);
return Z_MEM_ERROR;
}
}
/* copy state */
zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
copy->strm = dest;
if (state->lencode >= state->codes &&
state->lencode <= state->codes + ENOUGH - 1) {
copy->lencode = copy->codes + (state->lencode - state->codes);
copy->distcode = copy->codes + (state->distcode - state->codes);
}
copy->next = copy->codes + (state->next - state->codes);
if (window != Z_NULL) {
wsize = 1U << state->wbits;
zmemcpy(window, state->window, wsize);
}
copy->window = window;
dest->state = (struct internal_state FAR *)copy;
return Z_OK;
}
| 0
|
273,931
|
static void handle_TYPE(ctrl_t *ctrl, char *argument)
{
char type[24] = "200 Type set to I.\r\n";
char unknown[] = "501 Invalid argument to TYPE.\r\n";
if (!argument)
argument = "Z";
switch (argument[0]) {
case 'A':
ctrl->type = TYPE_A; /* ASCII */
break;
case 'I':
ctrl->type = TYPE_I; /* IMAGE/BINARY */
break;
default:
send_msg(ctrl->sd, unknown);
return;
}
type[16] = argument[0];
send_msg(ctrl->sd, type);
}
| 0
|
386,562
|
void DL_Dxf::endSequence(DL_CreationInterface* creationInterface) {
creationInterface->endSequence();
}
| 0
|
389,741
|
init_tv(typval_T *varp)
{
if (varp != NULL)
CLEAR_POINTER(varp);
}
| 0
|
474,070
|
koi8_u_is_code_ctype(OnigCodePoint code, unsigned int ctype,
OnigEncoding enc ARG_UNUSED)
{
if (code < 256)
return ENC_IS_KOI8_U_CTYPE(code, ctype);
else
return FALSE;
}
| 0
|
346,417
|
ex_runtime(exarg_T *eap)
{
char_u *arg = eap->arg;
char_u *p = skiptowhite(arg);
int len = (int)(p - arg);
int flags = eap->forceit ? DIP_ALL : 0;
if (STRNCMP(arg, "START", len) == 0)
{
flags += DIP_START + DIP_NORTP;
arg = skipwhite(arg + len);
}
else if (STRNCMP(arg, "OPT", len) == 0)
{
flags += DIP_OPT + DIP_NORTP;
arg = skipwhite(arg + len);
}
else if (STRNCMP(arg, "PACK", len) == 0)
{
flags += DIP_START + DIP_OPT + DIP_NORTP;
arg = skipwhite(arg + len);
}
else if (STRNCMP(arg, "ALL", len) == 0)
{
flags += DIP_START + DIP_OPT;
arg = skipwhite(arg + len);
}
source_runtime(arg, flags);
}
| 0
|
512,512
|
longlong Item_func_between::val_int_cmp_native()
{
THD *thd= current_thd;
const Type_handler *h= m_comparator.type_handler();
NativeBuffer<STRING_BUFFER_USUAL_SIZE> value, a, b;
if (val_native_with_conversion_from_item(thd, args[0], &value, h))
return 0;
bool ra= args[1]->val_native_with_conversion(thd, &a, h);
bool rb= args[2]->val_native_with_conversion(thd, &b, h);
if (!ra && !rb)
return (longlong)
((h->cmp_native(value, a) >= 0 &&
h->cmp_native(value, b) <= 0) != negated);
if (ra && rb)
null_value= true;
else if (ra)
null_value= h->cmp_native(value, b) <= 0;
else
null_value= h->cmp_native(value, a) >= 0;
return (longlong) (!null_value && negated);
}
| 0
|
224,578
|
Status EinsumShape(shape_inference::InferenceContext* c) {
// We assume that the equation has a valid format. Either (x),(y)->(z)
// or (x)->(z), where each of (x), (y) and (z) are concatenation of zero or
// more latin alphabets and contains at most one ellipsis ('...').
string equation;
TF_RETURN_IF_ERROR(c->GetAttr("equation", &equation));
gtl::InlinedVector<string, 2> input_labels;
string output_labels;
TF_RETURN_IF_ERROR(
ParseEinsumEquation(equation, &input_labels, &output_labels));
if (c->num_inputs() == 0 || c->num_inputs() > 2) {
return errors::InvalidArgument("Expected either 1 or 2 inputs but got: ",
c->num_inputs());
}
const int input_labels_size = input_labels.size();
if (c->num_inputs() != input_labels_size) {
return errors::InvalidArgument("Expected ", input_labels.size(),
" inputs for equation ", equation,
" but got: ", c->num_inputs());
}
// Validate input subscripts, build the label to dimension mapping and obtain
// the broadcast shapes that map to ellipsis.
absl::flat_hash_map<char, DimensionHandle> label_to_dimension;
gtl::InlinedVector<ShapeHandle, 2> input_bcast_shapes(c->num_inputs());
for (int i = 0, end = c->num_inputs(); i < end; ++i) {
bool has_ellipsis = false;
TF_RETURN_IF_ERROR(ValidateEinsumEllipsis(input_labels[i], &has_ellipsis));
ShapeHandle input_shape = c->input(i);
// Validate that the input rank is sufficient for the given number of named
// labels.
if (c->RankKnown(input_shape)) {
if (has_ellipsis) {
const int num_named_labels =
static_cast<int>(input_labels[i].size()) - 3;
TF_RETURN_WITH_CONTEXT_IF_ERROR(
c->WithRankAtLeast(input_shape, num_named_labels, &input_shape),
" for ", i, "th input and equation: ", equation);
} else {
const int num_named_labels = static_cast<int>(input_labels[i].size());
TF_RETURN_WITH_CONTEXT_IF_ERROR(
c->WithRank(input_shape, num_named_labels, &input_shape), " for ",
i, "th input and equation: ", equation);
}
}
bool seen_ellipsis = false;
input_bcast_shapes[i] = c->Scalar();
// Run through the input labels; populate label_to_dimension mapping and
// compute the broadcast shapes corresponding to the ellipsis (if present).
for (int label_idx = 0, end = input_labels[i].size(); label_idx < end;
++label_idx) {
const char label = input_labels[i][label_idx];
// Calculate the input axis that the current label is referring to. After
// the ellipsis, the axis may be found by using negative indices; i.e the
// (rank - k)th dimension corresponds to the (num_labels - k)th label.
const int64_t axis_before_ellipsis = label_idx;
const int64_t axis_after_ellipsis =
c->RankKnown(input_shape)
? label_idx + c->Rank(input_shape) - input_labels[i].size()
: -1;
// Populate the input broadcast shape when we encounter an ellipsis (...).
if (label == '.') {
if (!c->RankKnown(input_shape)) {
input_bcast_shapes[i] = c->UnknownShape();
} else {
// The broadcast shape runs till the named label right after the
// ellipsis, the label with index (label_idx + 3).
TF_RETURN_IF_ERROR(c->Subshape(input_shape, axis_before_ellipsis,
axis_after_ellipsis + 3,
&input_bcast_shapes[i]));
}
label_idx += 2; // Skip the rest of the ellipsis.
seen_ellipsis = true;
continue;
}
// Obtain the dimension that the current label corresponds to.
int64_t axis = seen_ellipsis ? axis_after_ellipsis : axis_before_ellipsis;
DimensionHandle new_dim = c->RankKnown(input_shape)
? c->Dim(input_shape, axis)
: c->UnknownDim();
// If we've seen this label before, make sure previous and current
// dimensions are compatible.
if (label_to_dimension.contains(label)) {
DimensionHandle merged;
TF_RETURN_IF_ERROR(
c->Merge(label_to_dimension[label], new_dim, &merged));
label_to_dimension[label] = merged;
} else {
label_to_dimension[label] = new_dim;
}
}
}
// For two inputs, broadcast the two input broadcast shapes to create the
// output broadcast shape. For one input, just copy the single broadcast
// shape.
ShapeHandle output_bcast_shape;
if (input_bcast_shapes.size() == 1) {
output_bcast_shape = input_bcast_shapes[0];
} else if (input_bcast_shapes.size() == 2) {
TF_RETURN_IF_ERROR(BroadcastBinaryOpOutputShapeFnHelper(
c, input_bcast_shapes[0], input_bcast_shapes[1], true,
&output_bcast_shape));
}
bool output_has_ellipsis = false;
TF_RETURN_IF_ERROR(
ValidateEinsumEllipsis(output_labels, &output_has_ellipsis));
if (output_has_ellipsis) {
// If the output subscript has ellipsis and the output broadcast rank is
// unknown, then the output shape should have unknown rank.
if (!c->RankKnown(output_bcast_shape)) {
c->set_output(0, c->UnknownShape());
return Status::OK();
}
} else {
// If the output subscripts don't have ellipsis then make sure the output
// broadcasting shape is empty.
TF_RETURN_WITH_CONTEXT_IF_ERROR(
c->WithRankAtMost(output_bcast_shape, 0, &output_bcast_shape),
" for einsum equation '", equation,
"' without ellipsis (...) in the output subscripts where input(s) have "
"non-empty broadcasting shape");
output_bcast_shape = c->Scalar();
}
// Create the output shape from output labels and label_to_dimension mapping.
std::vector<DimensionHandle> output_dims;
for (int label_idx = 0, end = output_labels.size(); label_idx < end;
++label_idx) {
const char label = output_labels[label_idx];
// Append the output_bcast_shape when the ellipsis is encountered.
if (label == '.') {
for (int k = 0; k < c->Rank(output_bcast_shape); ++k) {
output_dims.push_back(c->Dim(output_bcast_shape, k));
}
label_idx += 2; // Skip the rest of the ellipsis.
continue;
}
auto dimension_it = label_to_dimension.find(label);
if (dimension_it == label_to_dimension.end()) {
return errors::InvalidArgument(
"Einsum output subscripts for equation '", equation, "' has label '",
label, "' which is not present in the input subscripts");
}
output_dims.push_back(dimension_it->second);
}
c->set_output(0, c->MakeShape(output_dims));
return Status::OK();
}
| 0
|
259,612
|
void HierarchicalBitmapRequester::ResetToStartOfImage(void)
{
#if ACCUSOFT_CODE
for(UBYTE i = 0;i < m_ucCount;i++) {
m_pulY[i] = 0;
m_pulReadyLines[i] = 0;
}
//
assert(m_pLargestScale);
// Now iterate through the tree.
m_pLargestScale->ResetToStartOfImage();
#endif
}
| 0
|
313,772
|
nv_abbrev(cmdarg_T *cap)
{
if (cap->cmdchar == K_DEL || cap->cmdchar == K_KDEL)
cap->cmdchar = 'x'; // DEL key behaves like 'x'
// in Visual mode these commands are operators
if (VIsual_active)
v_visop(cap);
else
nv_optrans(cap);
}
| 0
|
270,369
|
static void ok_inflater_make_huffman_tree_from_array(ok_inflater_huffman_tree *tree,
const uint8_t *code_length, int length) {
tree->bits = 1;
// Count the number of codes for each code length.
// Let code_length_count[n] be the number of codes of length n, n >= 1.
unsigned int code_length_count[MAX_CODE_LENGTH];
int i;
for (i = 0; i < MAX_CODE_LENGTH; i++) {
code_length_count[i] = 0;
}
for (i = 0; i < length; i++) {
code_length_count[code_length[i]]++;
}
// Find the numerical value of the smallest code for each code length:
unsigned int next_code[MAX_CODE_LENGTH];
unsigned int code = 0;
for (i = 1; i < MAX_CODE_LENGTH; i++) {
code = (code + code_length_count[i - 1]) << 1;
next_code[i] = code;
if (code_length_count[i] != 0) {
tree->bits = (unsigned int)i;
}
}
// Init lookup table
const unsigned int max = 1 << tree->bits;
memset(tree->lookup_table, 0, sizeof(tree->lookup_table[0]) * max);
// Assign numerical values to all codes, using consecutive values for all
// codes of the same length with the base values determined at step 2.
// Codes that are never used (which have a bit length of zero) must not be
// assigned a value.
for (i = 0; i < length; i++) {
unsigned int len = code_length[i];
if (len != 0) {
code = next_code[len];
next_code[len]++;
unsigned int value = (unsigned int)i | (len << VALUE_BITS);
tree->lookup_table[ok_inflater_reverse_bits(code, len)] = (uint16_t)value;
}
}
// Fill in the missing parts of the lookup table
int next_limit = 1;
int num_bits = 0;
int mask = 0;
for (i = 1; i < (int)max; i++) {
if (i == next_limit) {
mask = (1 << num_bits) - 1;
num_bits++;
next_limit <<= 1;
}
if (tree->lookup_table[i] == 0) {
tree->lookup_table[i] = tree->lookup_table[i & mask];
}
}
}
| 0
|
207,755
|
PHP_FUNCTION(openssl_encrypt)
{
zend_bool raw_output = 0;
char *data, *method, *password, *iv = "";
int data_len, method_len, password_len, iv_len = 0, max_iv_len;
const EVP_CIPHER *cipher_type;
EVP_CIPHER_CTX cipher_ctx;
int i, outlen, keylen;
unsigned char *outbuf, *key;
zend_bool free_iv;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss|bs", &data, &data_len, &method, &method_len, &password, &password_len, &raw_output, &iv, &iv_len) == FAILURE) {
return;
}
cipher_type = EVP_get_cipherbyname(method);
if (!cipher_type) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown cipher algorithm");
RETURN_FALSE;
}
keylen = EVP_CIPHER_key_length(cipher_type);
if (keylen > password_len) {
key = emalloc(keylen);
memset(key, 0, keylen);
memcpy(key, password, password_len);
} else {
key = (unsigned char*)password;
}
max_iv_len = EVP_CIPHER_iv_length(cipher_type);
if (iv_len <= 0 && max_iv_len > 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Using an empty Initialization Vector (iv) is potentially insecure and not recommended");
}
free_iv = php_openssl_validate_iv(&iv, &iv_len, max_iv_len TSRMLS_CC);
outlen = data_len + EVP_CIPHER_block_size(cipher_type);
outbuf = emalloc(outlen + 1);
EVP_EncryptInit(&cipher_ctx, cipher_type, NULL, NULL);
if (password_len > keylen) {
EVP_CIPHER_CTX_set_key_length(&cipher_ctx, password_len);
}
EVP_EncryptInit_ex(&cipher_ctx, NULL, NULL, key, (unsigned char *)iv);
EVP_EncryptUpdate(&cipher_ctx, outbuf, &i, (unsigned char *)data, data_len);
outlen = i;
if (EVP_EncryptFinal(&cipher_ctx, (unsigned char *)outbuf + i, &i)) {
outlen += i;
if (raw_output) {
outbuf[outlen] = '\0';
RETVAL_STRINGL((char *)outbuf, outlen, 0);
} else {
int base64_str_len;
char *base64_str;
base64_str = (char*)php_base64_encode(outbuf, outlen, &base64_str_len);
efree(outbuf);
RETVAL_STRINGL(base64_str, base64_str_len, 0);
}
} else {
efree(outbuf);
RETVAL_FALSE;
}
if (key != (unsigned char*)password) {
efree(key);
}
if (free_iv) {
efree(iv);
}
EVP_CIPHER_CTX_cleanup(&cipher_ctx);
}
| 1
|
225,742
|
void stri_box_del(GF_Box *s)
{
GF_SubTrackInformationBox *ptr = (GF_SubTrackInformationBox *)s;
if (ptr == NULL) return;
if (ptr->attribute_list) gf_free(ptr->attribute_list);
gf_free(ptr);
| 0
|
477,286
|
static inline void tipc_crypto_clone_msg(struct net *net, struct sk_buff *_skb,
struct tipc_bearer *b,
struct tipc_media_addr *dst,
struct tipc_node *__dnode, u8 type)
{
struct sk_buff *skb;
skb = skb_clone(_skb, GFP_ATOMIC);
if (skb) {
TIPC_SKB_CB(skb)->xmit_type = type;
tipc_crypto_xmit(net, &skb, b, dst, __dnode);
if (skb)
b->media->send_msg(net, skb, b, dst);
}
}
| 0
|
246,643
|
static GF_Err naludmx_initialize(GF_Filter *filter)
{
GF_NALUDmxCtx *ctx = gf_filter_get_udta(filter);
ctx->sps = gf_list_new();
ctx->pps = gf_list_new();
switch (ctx->nal_length) {
case 1:
ctx->max_nalu_size_allowed = 0xFF;
break;
case 2:
ctx->max_nalu_size_allowed = 0xFFFF;
break;
case 4:
ctx->max_nalu_size_allowed = 0xFFFFFFFF;
break;
case 0:
ctx->max_nalu_size_allowed = 0xFFFFFFFF;
ctx->nal_length = 4;
ctx->nal_adjusted = GF_TRUE;
break;
default:
GF_LOG(GF_LOG_WARNING, GF_LOG_MEDIA, ("[%s] NAL size length %d is not allowed, defaulting to 4 bytes\n", ctx->log_name));
ctx->max_nalu_size_allowed = 0xFFFFFFFF;
ctx->nal_length = 4;
break;
}
return GF_OK;
}
| 0
|
512,385
|
double val_real()
{
return has_value() ? Time(this).to_double() : 0;
}
| 0
|
349,261
|
void sort_directory(struct dir *dir)
{
struct dir_ent *cur, *l1, *l2, *next;
int len1, len2, stride = 1;
if(dir->dir_count < 2)
return;
/*
* We can consider our linked-list to be made up of stride length
* sublists. Eacn iteration around this loop merges adjacent
* stride length sublists into larger 2*stride sublists. We stop
* when stride becomes equal to the entire list.
*
* Initially stride = 1 (by definition a sublist of 1 is sorted), and
* these 1 element sublists are merged into 2 element sublists, which
* are then merged into 4 element sublists and so on.
*/
do {
l2 = dir->dirs; /* head of current linked list */
cur = NULL; /* empty output list */
/*
* Iterate through the linked list, merging adjacent sublists.
* On each interation l2 points to the next sublist pair to be
* merged (if there's only one sublist left this is simply added
* to the output list)
*/
while(l2) {
l1 = l2;
for(len1 = 0; l2 && len1 < stride; len1 ++, l2 = l2->next);
len2 = stride;
/*
* l1 points to first sublist.
* l2 points to second sublist.
* Merge them onto the output list
*/
while(len1 && l2 && len2) {
if(strcmp(l1->name, l2->name) <= 0) {
next = l1;
l1 = l1->next;
len1 --;
} else {
next = l2;
l2 = l2->next;
len2 --;
}
if(cur) {
cur->next = next;
cur = next;
} else
dir->dirs = cur = next;
}
/*
* One sublist is now empty, copy the other one onto the
* output list
*/
for(; len1; len1 --, l1 = l1->next) {
if(cur) {
cur->next = l1;
cur = l1;
} else
dir->dirs = cur = l1;
}
for(; l2 && len2; len2 --, l2 = l2->next) {
if(cur) {
cur->next = l2;
cur = l2;
} else
dir->dirs = cur = l2;
}
}
cur->next = NULL;
stride = stride << 1;
} while(stride < dir->dir_count);
}
| 0
|
513,362
|
bool open_tmp_table(TABLE *table)
{
int error;
if ((error= table->file->ha_open(table, table->s->path.str, O_RDWR,
HA_OPEN_TMP_TABLE |
HA_OPEN_INTERNAL_TABLE)))
{
table->file->print_error(error, MYF(0)); /* purecov: inspected */
table->db_stat= 0;
return 1;
}
table->db_stat= HA_OPEN_KEYFILE;
(void) table->file->extra(HA_EXTRA_QUICK); /* Faster */
if (!table->is_created())
{
table->set_created();
table->in_use->inc_status_created_tmp_tables();
}
return 0;
}
| 0
|
225,870
|
GF_Box *ccst_box_new()
{
ISOM_DECL_BOX_ALLOC(GF_CodingConstraintsBox, GF_ISOM_BOX_TYPE_CCST);
return (GF_Box *) tmp;
}
| 0
|
473,999
|
parse_enclose(Node** np, OnigToken* tok, int term, UChar** src, UChar* end,
ScanEnv* env)
{
int r, num;
Node *target;
OnigOptionType option;
OnigCodePoint c;
OnigEncoding enc = env->enc;
#ifdef USE_NAMED_GROUP
int list_capture;
#endif
UChar* p = *src;
PFETCH_READY;
*np = NULL;
if (PEND) return ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS;
option = env->option;
if (PPEEK_IS('?') &&
IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_GROUP_EFFECT)) {
PINC;
if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;
PFETCH(c);
switch (c) {
case ':': /* (?:...) grouping only */
group:
r = fetch_token(tok, &p, end, env);
if (r < 0) return r;
r = parse_subexp(np, tok, term, &p, end, env);
if (r < 0) return r;
*src = p;
return 1; /* group */
break;
case '=':
*np = onig_node_new_anchor(ANCHOR_PREC_READ);
break;
case '!': /* preceding read */
*np = onig_node_new_anchor(ANCHOR_PREC_READ_NOT);
break;
case '>': /* (?>...) stop backtrack */
*np = node_new_enclose(ENCLOSE_STOP_BACKTRACK);
break;
#ifdef USE_NAMED_GROUP
case '\'':
if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) {
goto named_group1;
}
else
return ONIGERR_UNDEFINED_GROUP_OPTION;
break;
#endif
case '<': /* look behind (?<=...), (?<!...) */
PFETCH(c);
if (c == '=')
*np = onig_node_new_anchor(ANCHOR_LOOK_BEHIND);
else if (c == '!')
*np = onig_node_new_anchor(ANCHOR_LOOK_BEHIND_NOT);
#ifdef USE_NAMED_GROUP
else {
if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) {
UChar *name;
UChar *name_end;
PUNFETCH;
c = '<';
named_group1:
list_capture = 0;
named_group2:
name = p;
r = fetch_name((OnigCodePoint )c, &p, end, &name_end, env, &num, 0);
if (r < 0) return r;
num = scan_env_add_mem_entry(env);
if (num < 0) return num;
if (list_capture != 0 && num >= (int )BIT_STATUS_BITS_NUM)
return ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY;
r = name_add(env->reg, name, name_end, num, env);
if (r != 0) return r;
*np = node_new_enclose_memory(env->option, 1);
CHECK_NULL_RETURN_MEMERR(*np);
NENCLOSE(*np)->regnum = num;
if (list_capture != 0)
BIT_STATUS_ON_AT_SIMPLE(env->capture_history, num);
env->num_named++;
}
else {
return ONIGERR_UNDEFINED_GROUP_OPTION;
}
}
#else
else {
return ONIGERR_UNDEFINED_GROUP_OPTION;
}
#endif
break;
case '@':
if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_ATMARK_CAPTURE_HISTORY)) {
#ifdef USE_NAMED_GROUP
if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP)) {
PFETCH(c);
if (c == '<' || c == '\'') {
list_capture = 1;
goto named_group2; /* (?@<name>...) */
}
PUNFETCH;
}
#endif
*np = node_new_enclose_memory(env->option, 0);
CHECK_NULL_RETURN_MEMERR(*np);
num = scan_env_add_mem_entry(env);
if (num < 0) {
onig_node_free(*np);
return num;
}
else if (num >= (int )BIT_STATUS_BITS_NUM) {
onig_node_free(*np);
return ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY;
}
NENCLOSE(*np)->regnum = num;
BIT_STATUS_ON_AT_SIMPLE(env->capture_history, num);
}
else {
return ONIGERR_UNDEFINED_GROUP_OPTION;
}
break;
#ifdef USE_POSIXLINE_OPTION
case 'p':
#endif
case '-': case 'i': case 'm': case 's': case 'x':
{
int neg = 0;
while (1) {
switch (c) {
case ':':
case ')':
break;
case '-': neg = 1; break;
case 'x': ONOFF(option, ONIG_OPTION_EXTEND, neg); break;
case 'i': ONOFF(option, ONIG_OPTION_IGNORECASE, neg); break;
case 's':
if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL)) {
ONOFF(option, ONIG_OPTION_MULTILINE, neg);
}
else
return ONIGERR_UNDEFINED_GROUP_OPTION;
break;
case 'm':
if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL)) {
ONOFF(option, ONIG_OPTION_SINGLELINE, (neg == 0 ? 1 : 0));
}
else if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_RUBY)) {
ONOFF(option, ONIG_OPTION_MULTILINE, neg);
}
else
return ONIGERR_UNDEFINED_GROUP_OPTION;
break;
#ifdef USE_POSIXLINE_OPTION
case 'p':
ONOFF(option, ONIG_OPTION_MULTILINE|ONIG_OPTION_SINGLELINE, neg);
break;
#endif
default:
return ONIGERR_UNDEFINED_GROUP_OPTION;
}
if (c == ')') {
*np = node_new_option(option);
CHECK_NULL_RETURN_MEMERR(*np);
*src = p;
return 2; /* option only */
}
else if (c == ':') {
OnigOptionType prev = env->option;
env->option = option;
r = fetch_token(tok, &p, end, env);
if (r < 0) return r;
r = parse_subexp(&target, tok, term, &p, end, env);
env->option = prev;
if (r < 0) return r;
*np = node_new_option(option);
CHECK_NULL_RETURN_MEMERR(*np);
NENCLOSE(*np)->target = target;
*src = p;
return 0;
}
if (PEND) return ONIGERR_END_PATTERN_IN_GROUP;
PFETCH(c);
}
}
break;
default:
return ONIGERR_UNDEFINED_GROUP_OPTION;
}
}
else {
if (ONIG_IS_OPTION_ON(env->option, ONIG_OPTION_DONT_CAPTURE_GROUP))
goto group;
*np = node_new_enclose_memory(env->option, 0);
CHECK_NULL_RETURN_MEMERR(*np);
num = scan_env_add_mem_entry(env);
if (num < 0) return num;
NENCLOSE(*np)->regnum = num;
}
CHECK_NULL_RETURN_MEMERR(*np);
r = fetch_token(tok, &p, end, env);
if (r < 0) return r;
r = parse_subexp(&target, tok, term, &p, end, env);
if (r < 0) {
onig_node_free(target);
return r;
}
if (NTYPE(*np) == NT_ANCHOR)
NANCHOR(*np)->target = target;
else {
NENCLOSE(*np)->target = target;
if (NENCLOSE(*np)->type == ENCLOSE_MEMORY) {
/* Don't move this to previous of parse_subexp() */
r = scan_env_set_mem_node(env, NENCLOSE(*np)->regnum, *np);
if (r != 0) return r;
}
}
*src = p;
return 0;
}
| 0
|
349,889
|
static int hw_atl_utils_fw_upload_dwords(struct aq_hw_s *self, u32 addr, u32 *p,
u32 cnt, enum mcp_area area)
{
int err = 0;
u32 val;
err = readx_poll_timeout_atomic(hw_atl_sem_ram_get, self,
val, val == 1U,
10U, 100000U);
if (err < 0)
goto err_exit;
if (ATL_HW_IS_CHIP_FEATURE(self, REVISION_B1))
err = hw_atl_utils_write_b1_mbox(self, addr, p, cnt, area);
else
err = hw_atl_utils_write_b0_mbox(self, addr, p, cnt);
hw_atl_reg_glb_cpu_sem_set(self, 1U, HW_ATL_FW_SM_RAM);
if (err < 0)
goto err_exit;
err = aq_hw_err_from_flags(self);
err_exit:
return err;
}
| 0
|
101,695
|
void WebProcessProxy::removeMessagePortChannel(uint64_t channelID)
{
if (!isValid())
return;
send(Messages::WebProcess::RemoveMessagePortChannel(channelID), /* destinationID */ 0);
}
| 0
|
434,085
|
alist_add(
alist_T *al,
char_u *fname,
int set_fnum) // 1: set buffer number; 2: re-use curbuf
{
if (fname == NULL) // don't add NULL file names
return;
if (check_arglist_locked() == FAIL)
return;
arglist_locked = TRUE;
#ifdef BACKSLASH_IN_FILENAME
slash_adjust(fname);
#endif
AARGLIST(al)[al->al_ga.ga_len].ae_fname = fname;
if (set_fnum > 0)
AARGLIST(al)[al->al_ga.ga_len].ae_fnum =
buflist_add(fname, BLN_LISTED | (set_fnum == 2 ? BLN_CURBUF : 0));
++al->al_ga.ga_len;
arglist_locked = FALSE;
}
| 0
|
512,638
|
With_sum_func_cache(const Item *a, const Item *b, const Item *c,
const Item *d, const Item *e)
:m_with_sum_func(a->with_sum_func() || b->with_sum_func() ||
c->with_sum_func() || d->with_sum_func() ||
e->with_sum_func())
{ }
| 0
|
328,997
|
R_API char *r_bin_java_get_utf8_from_cp_item_list(RList *cp_list, ut64 idx) {
/*
Search through the Constant Pool list for the given CP Index.
If the idx not found by directly going to the list index,
the list will be walked and then the IDX will be checked.
rvalue: new char* for caller to free.
*/
char *value = NULL;
RListIter *iter;
if (!cp_list) {
return NULL;
}
RBinJavaCPTypeObj *item = (RBinJavaCPTypeObj *) r_list_get_n (cp_list, idx);
if (item && item->tag == R_BIN_JAVA_CP_UTF8 && item->metas->ord == idx) {
value = convert_string ((const char *) item->info.cp_utf8.bytes, item->info.cp_utf8.length);
}
if (!value) {
r_list_foreach (cp_list, iter, item) {
if (item && (item->tag == R_BIN_JAVA_CP_UTF8) && item->metas->ord == idx) {
value = convert_string ((const char *) item->info.cp_utf8.bytes, item->info.cp_utf8.length);
break;
}
}
}
return value;
}
| 0
|
383,368
|
gdImageSaveAlpha (gdImagePtr im, int saveAlphaArg)
{
im->saveAlphaFlag = saveAlphaArg;
}
| 0
|
234,761
|
static noinline int init_first_rw_device(struct btrfs_trans_handle *trans)
{
struct btrfs_fs_info *fs_info = trans->fs_info;
u64 alloc_profile;
struct btrfs_block_group *meta_bg;
struct btrfs_block_group *sys_bg;
/*
* When adding a new device for sprouting, the seed device is read-only
* so we must first allocate a metadata and a system chunk. But before
* adding the block group items to the extent, device and chunk btrees,
* we must first:
*
* 1) Create both chunks without doing any changes to the btrees, as
* otherwise we would get -ENOSPC since the block groups from the
* seed device are read-only;
*
* 2) Add the device item for the new sprout device - finishing the setup
* of a new block group requires updating the device item in the chunk
* btree, so it must exist when we attempt to do it. The previous step
* ensures this does not fail with -ENOSPC.
*
* After that we can add the block group items to their btrees:
* update existing device item in the chunk btree, add a new block group
* item to the extent btree, add a new chunk item to the chunk btree and
* finally add the new device extent items to the devices btree.
*/
alloc_profile = btrfs_metadata_alloc_profile(fs_info);
meta_bg = btrfs_alloc_chunk(trans, alloc_profile);
if (IS_ERR(meta_bg))
return PTR_ERR(meta_bg);
alloc_profile = btrfs_system_alloc_profile(fs_info);
sys_bg = btrfs_alloc_chunk(trans, alloc_profile);
if (IS_ERR(sys_bg))
return PTR_ERR(sys_bg);
return 0;
}
| 0
|
430,409
|
static size_t ovs_nsh_key_attr_size(void)
{
/* Whenever adding new OVS_NSH_KEY_ FIELDS, we should consider
* updating this function.
*/
return nla_total_size(NSH_BASE_HDR_LEN) /* OVS_NSH_KEY_ATTR_BASE */
/* OVS_NSH_KEY_ATTR_MD1 and OVS_NSH_KEY_ATTR_MD2 are
* mutually exclusive, so the bigger one can cover
* the small one.
*/
+ nla_total_size(NSH_CTX_HDRS_MAX_LEN);
}
| 0
|
455,305
|
bash_filename_stat_hook (dirname)
char **dirname;
{
char *local_dirname, *new_dirname, *t;
int should_expand_dirname, return_value;
int global_nounset;
WORD_LIST *wl;
local_dirname = *dirname;
should_expand_dirname = return_value = 0;
if (t = mbschr (local_dirname, '$'))
should_expand_dirname = '$';
else if (t = mbschr (local_dirname, '`')) /* XXX */
should_expand_dirname = '`';
if (should_expand_dirname && directory_exists (local_dirname, 0))
should_expand_dirname = 0;
if (should_expand_dirname)
{
new_dirname = savestring (local_dirname);
/* no error messages, and expand_prompt_string doesn't longjmp so we don't
have to worry about restoring this setting. */
global_nounset = unbound_vars_is_error;
unbound_vars_is_error = 0;
wl = expand_prompt_string (new_dirname, 0, W_NOCOMSUB|W_NOPROCSUB|W_COMPLETE); /* does the right thing */
unbound_vars_is_error = global_nounset;
if (wl)
{
free (new_dirname);
new_dirname = string_list (wl);
/* Tell the completer we actually expanded something and change
*dirname only if we expanded to something non-null -- stat
behaves unpredictably when passed null or empty strings */
if (new_dirname && *new_dirname)
{
free (local_dirname); /* XXX */
local_dirname = *dirname = new_dirname;
return_value = STREQ (local_dirname, *dirname) == 0;
}
else
free (new_dirname);
dispose_words (wl);
}
else
free (new_dirname);
}
/* This is very similar to the code in bash_directory_completion_hook below,
but without spelling correction and not worrying about whether or not
we change relative pathnames. */
if (no_symbolic_links == 0 && (local_dirname[0] != '.' || local_dirname[1]))
{
char *temp1, *temp2;
t = get_working_directory ("symlink-hook");
temp1 = make_absolute (local_dirname, t);
free (t);
temp2 = sh_canonpath (temp1, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
/* If we can't canonicalize, bail. */
if (temp2 == 0)
{
free (temp1);
return return_value;
}
free (local_dirname);
*dirname = temp2;
free (temp1);
}
return (return_value);
}
| 0
|
343,303
|
void donoop(void)
{
#ifdef BORING_MODE
addreply_noformat(200, "dc.w $4E71");
#else
addreply_noformat(200, MSG_SLEEPING);
#endif
}
| 0
|
427,168
|
static void close_func (LexState *ls) {
lua_State *L = ls->L;
FuncState *fs = ls->fs;
Proto *f = fs->f;
luaK_ret(fs, luaY_nvarstack(fs), 0); /* final return */
leaveblock(fs);
lua_assert(fs->bl == NULL);
luaK_finish(fs);
luaM_shrinkvector(L, f->code, f->sizecode, fs->pc, Instruction);
luaM_shrinkvector(L, f->lineinfo, f->sizelineinfo, fs->pc, ls_byte);
luaM_shrinkvector(L, f->abslineinfo, f->sizeabslineinfo,
fs->nabslineinfo, AbsLineInfo);
luaM_shrinkvector(L, f->k, f->sizek, fs->nk, TValue);
luaM_shrinkvector(L, f->p, f->sizep, fs->np, Proto *);
luaM_shrinkvector(L, f->locvars, f->sizelocvars, fs->ndebugvars, LocVar);
luaM_shrinkvector(L, f->upvalues, f->sizeupvalues, fs->nups, Upvaldesc);
ls->fs = fs->prev;
luaC_checkGC(L);
}
| 0
|
225,106
|
Status ValidateAttrValue(const AttrValue& attr_value,
const OpDef::AttrDef& attr) {
// Is it a valid value?
TF_RETURN_WITH_CONTEXT_IF_ERROR(AttrValueHasType(attr_value, attr.type()),
" for attr '", attr.name(), "'");
// Does the value satisfy the minimum constraint in the AttrDef?
if (attr.has_minimum()) {
if (attr.type() == "int") {
if (attr_value.i() < attr.minimum()) {
return errors::InvalidArgument(
"Value for attr '", attr.name(), "' of ", attr_value.i(),
" must be at least minimum ", attr.minimum());
}
} else {
int length = -1;
if (attr.type() == "list(string)") {
length = attr_value.list().s_size();
} else if (attr.type() == "list(int)") {
length = attr_value.list().i_size();
} else if (attr.type() == "list(float)") {
length = attr_value.list().f_size();
} else if (attr.type() == "list(bool)") {
length = attr_value.list().b_size();
} else if (attr.type() == "list(type)") {
length = attr_value.list().type_size();
} else if (attr.type() == "list(shape)") {
length = attr_value.list().shape_size();
} else if (attr.type() == "list(tensor)") {
length = attr_value.list().tensor_size();
} else if (attr.type() == "list(func)") {
length = attr_value.list().func_size();
}
if (length < attr.minimum()) {
return errors::InvalidArgument(
"Length for attr '", attr.name(), "' of ", length,
" must be at least minimum ", attr.minimum());
}
}
}
// Does the value satisfy the allowed_value constraint in the AttrDef?
if (attr.has_allowed_values()) {
if (attr.type() == "type") {
TF_RETURN_IF_ERROR(AllowedTypeValue(attr_value.type(), attr));
} else if (attr.type() == "list(type)") {
for (int dt : attr_value.list().type()) {
TF_RETURN_IF_ERROR(AllowedTypeValue(static_cast<DataType>(dt), attr));
}
} else if (attr.type() == "string") {
TF_RETURN_IF_ERROR(AllowedStringValue(attr_value.s(), attr));
} else if (attr.type() == "list(string)") {
for (const string& str : attr_value.list().s()) {
TF_RETURN_IF_ERROR(AllowedStringValue(str, attr));
}
} else {
return errors::Unimplemented(
"Support for allowed_values not implemented for type ", attr.type());
}
}
return Status::OK();
}
| 0
|
275,929
|
int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key, uECC_Curve curve) {
#if uECC_VLI_NATIVE_LITTLE_ENDIAN
uECC_word_t *_private = (uECC_word_t *)private_key;
uECC_word_t *_public = (uECC_word_t *)public_key;
#else
uECC_word_t _private[uECC_MAX_WORDS];
uECC_word_t _public[uECC_MAX_WORDS * 2];
#endif
#if uECC_VLI_NATIVE_LITTLE_ENDIAN == 0
uECC_vli_bytesToNative(_private, private_key, BITS_TO_BYTES(curve->num_n_bits));
#endif
/* Make sure the private key is in the range [1, n-1]. */
if (uECC_vli_isZero(_private, BITS_TO_WORDS(curve->num_n_bits))) {
return 0;
}
if (uECC_vli_cmp(curve->n, _private, BITS_TO_WORDS(curve->num_n_bits)) != 1) {
return 0;
}
/* Compute public key. */
if (!EccPoint_compute_public_key(_public, _private, curve)) {
return 0;
}
#if uECC_VLI_NATIVE_LITTLE_ENDIAN == 0
uECC_vli_nativeToBytes(public_key, curve->num_bytes, _public);
uECC_vli_nativeToBytes(
public_key + curve->num_bytes, curve->num_bytes, _public + curve->num_words);
#endif
return 1;
}
| 0
|
244,300
|
void dfla_box_del(GF_Box *s)
{
GF_FLACConfigBox *ptr = (GF_FLACConfigBox *) s;
if (ptr->data) gf_free(ptr->data);
gf_free(ptr);
}
| 0
|
437,327
|
optimize_nodes(Node* node, NodeOpt* opt, OptEnv* env)
{
int i;
int r;
NodeOpt xo;
OnigEncoding enc;
r = 0;
enc = env->enc;
clear_node_opt_info(opt);
set_bound_node_opt_info(opt, &env->mmd);
switch (NODE_TYPE(node)) {
case NODE_LIST:
{
OptEnv nenv;
Node* nd = node;
copy_opt_env(&nenv, env);
do {
r = optimize_nodes(NODE_CAR(nd), &xo, &nenv);
if (r == 0) {
add_mml(&nenv.mmd, &xo.len);
concat_left_node_opt_info(enc, opt, &xo);
}
} while (r == 0 && IS_NOT_NULL(nd = NODE_CDR(nd)));
}
break;
case NODE_ALT:
{
Node* nd = node;
do {
r = optimize_nodes(NODE_CAR(nd), &xo, env);
if (r == 0) {
if (nd == node) copy_node_opt_info(opt, &xo);
else alt_merge_node_opt_info(opt, &xo, env);
}
} while ((r == 0) && IS_NOT_NULL(nd = NODE_CDR(nd)));
}
break;
case NODE_STRING:
{
StrNode* sn = STR_(node);
int slen = (int )(sn->end - sn->s);
/* int is_raw = NODE_STRING_IS_RAW(node); */
if (! NODE_STRING_IS_AMBIG(node)) {
concat_opt_exact_str(&opt->exb, sn->s, sn->end, enc);
if (slen > 0) {
add_char_opt_map(&opt->map, *(sn->s), enc);
}
set_mml(&opt->len, slen, slen);
}
else {
int max;
if (NODE_STRING_IS_DONT_GET_OPT_INFO(node)) {
int n = onigenc_strlen(enc, sn->s, sn->end);
max = ONIGENC_MBC_MAXLEN_DIST(enc) * n;
}
else {
concat_opt_exact_str(&opt->exb, sn->s, sn->end, enc);
opt->exb.ignore_case = 1;
if (slen > 0) {
r = add_char_amb_opt_map(&opt->map, sn->s, sn->end,
enc, env->case_fold_flag);
if (r != 0) break;
}
max = slen;
}
set_mml(&opt->len, slen, max);
}
if (opt->exb.len == slen)
opt->exb.reach_end = 1;
}
break;
case NODE_CCLASS:
{
int z;
CClassNode* cc = CCLASS_(node);
/* no need to check ignore case. (set in setup_tree()) */
if (IS_NOT_NULL(cc->mbuf) || IS_NCCLASS_NOT(cc)) {
OnigLen min = ONIGENC_MBC_MINLEN(enc);
OnigLen max = ONIGENC_MBC_MAXLEN_DIST(enc);
set_mml(&opt->len, min, max);
}
else {
for (i = 0; i < SINGLE_BYTE_SIZE; i++) {
z = BITSET_AT(cc->bs, i);
if ((z && ! IS_NCCLASS_NOT(cc)) || (! z && IS_NCCLASS_NOT(cc))) {
add_char_opt_map(&opt->map, (UChar )i, enc);
}
}
set_mml(&opt->len, 1, 1);
}
}
break;
case NODE_CTYPE:
{
int min, max;
int range;
max = ONIGENC_MBC_MAXLEN_DIST(enc);
if (max == 1) {
min = 1;
switch (CTYPE_(node)->ctype) {
case CTYPE_ANYCHAR:
break;
case ONIGENC_CTYPE_WORD:
range = CTYPE_(node)->ascii_mode != 0 ? 128 : SINGLE_BYTE_SIZE;
if (CTYPE_(node)->not != 0) {
for (i = 0; i < range; i++) {
if (! ONIGENC_IS_CODE_WORD(enc, i)) {
add_char_opt_map(&opt->map, (UChar )i, enc);
}
}
for (i = range; i < SINGLE_BYTE_SIZE; i++) {
add_char_opt_map(&opt->map, (UChar )i, enc);
}
}
else {
for (i = 0; i < range; i++) {
if (ONIGENC_IS_CODE_WORD(enc, i)) {
add_char_opt_map(&opt->map, (UChar )i, enc);
}
}
}
break;
}
}
else {
min = ONIGENC_MBC_MINLEN(enc);
}
set_mml(&opt->len, min, max);
}
break;
case NODE_ANCHOR:
switch (ANCHOR_(node)->type) {
case ANCHOR_BEGIN_BUF:
case ANCHOR_BEGIN_POSITION:
case ANCHOR_BEGIN_LINE:
case ANCHOR_END_BUF:
case ANCHOR_SEMI_END_BUF:
case ANCHOR_END_LINE:
case ANCHOR_PREC_READ_NOT:
case ANCHOR_LOOK_BEHIND:
add_opt_anc_info(&opt->anc, ANCHOR_(node)->type);
break;
case ANCHOR_PREC_READ:
{
r = optimize_nodes(NODE_BODY(node), &xo, env);
if (r == 0) {
if (xo.exb.len > 0)
copy_opt_exact(&opt->expr, &xo.exb);
else if (xo.exm.len > 0)
copy_opt_exact(&opt->expr, &xo.exm);
opt->expr.reach_end = 0;
if (xo.map.value > 0)
copy_opt_map(&opt->map, &xo.map);
}
}
break;
case ANCHOR_LOOK_BEHIND_NOT:
break;
}
break;
case NODE_BACKREF:
if (! NODE_IS_CHECKER(node)) {
int* backs;
OnigLen min, max, tmin, tmax;
MemEnv* mem_env = SCANENV_MEMENV(env->scan_env);
BackRefNode* br = BACKREF_(node);
if (NODE_IS_RECURSION(node)) {
set_mml(&opt->len, 0, INFINITE_LEN);
break;
}
backs = BACKREFS_P(br);
min = tree_min_len(mem_env[backs[0]].node, env->scan_env);
max = tree_max_len(mem_env[backs[0]].node, env->scan_env);
for (i = 1; i < br->back_num; i++) {
tmin = tree_min_len(mem_env[backs[i]].node, env->scan_env);
tmax = tree_max_len(mem_env[backs[i]].node, env->scan_env);
if (min > tmin) min = tmin;
if (max < tmax) max = tmax;
}
set_mml(&opt->len, min, max);
}
break;
#ifdef USE_CALL
case NODE_CALL:
if (NODE_IS_RECURSION(node))
set_mml(&opt->len, 0, INFINITE_LEN);
else {
OnigOptionType save = env->options;
env->options = ENCLOSURE_(NODE_BODY(node))->o.options;
r = optimize_nodes(NODE_BODY(node), opt, env);
env->options = save;
}
break;
#endif
case NODE_QUANT:
{
OnigLen min, max;
QuantNode* qn = QUANT_(node);
r = optimize_nodes(NODE_BODY(node), &xo, env);
if (r != 0) break;
if (qn->lower > 0) {
copy_node_opt_info(opt, &xo);
if (xo.exb.len > 0) {
if (xo.exb.reach_end) {
for (i = 2; i <= qn->lower && ! is_full_opt_exact(&opt->exb); i++) {
int rc = concat_opt_exact(&opt->exb, &xo.exb, enc);
if (rc > 0) break;
}
if (i < qn->lower) opt->exb.reach_end = 0;
}
}
if (qn->lower != qn->upper) {
opt->exb.reach_end = 0;
opt->exm.reach_end = 0;
}
if (qn->lower > 1)
opt->exm.reach_end = 0;
}
if (IS_REPEAT_INFINITE(qn->upper)) {
if (env->mmd.max == 0 &&
NODE_IS_ANYCHAR(NODE_BODY(node)) && qn->greedy != 0) {
if (IS_MULTILINE(CTYPE_OPTION(NODE_QUANT_BODY(qn), env)))
add_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_INF_ML);
else
add_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_INF);
}
max = (xo.len.max > 0 ? INFINITE_LEN : 0);
}
else {
max = distance_multiply(xo.len.max, qn->upper);
}
min = distance_multiply(xo.len.min, qn->lower);
set_mml(&opt->len, min, max);
}
break;
case NODE_ENCLOSURE:
{
EnclosureNode* en = ENCLOSURE_(node);
switch (en->type) {
case ENCLOSURE_OPTION:
{
OnigOptionType save = env->options;
env->options = en->o.options;
r = optimize_nodes(NODE_BODY(node), opt, env);
env->options = save;
}
break;
case ENCLOSURE_MEMORY:
#ifdef USE_CALL
en->opt_count++;
if (en->opt_count > MAX_NODE_OPT_INFO_REF_COUNT) {
OnigLen min, max;
min = 0;
max = INFINITE_LEN;
if (NODE_IS_MIN_FIXED(node)) min = en->min_len;
if (NODE_IS_MAX_FIXED(node)) max = en->max_len;
set_mml(&opt->len, min, max);
}
else
#endif
{
r = optimize_nodes(NODE_BODY(node), opt, env);
if (is_set_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_INF_MASK)) {
if (MEM_STATUS_AT0(env->scan_env->backrefed_mem, en->m.regnum))
remove_opt_anc_info(&opt->anc, ANCHOR_ANYCHAR_INF_MASK);
}
}
break;
case ENCLOSURE_STOP_BACKTRACK:
r = optimize_nodes(NODE_BODY(node), opt, env);
break;
case ENCLOSURE_IF_ELSE:
{
OptEnv nenv;
copy_opt_env(&nenv, env);
r = optimize_nodes(NODE_ENCLOSURE_BODY(en), &xo, &nenv);
if (r == 0) {
add_mml(&nenv.mmd, &xo.len);
concat_left_node_opt_info(enc, opt, &xo);
if (IS_NOT_NULL(en->te.Then)) {
r = optimize_nodes(en->te.Then, &xo, &nenv);
if (r == 0) {
concat_left_node_opt_info(enc, opt, &xo);
}
}
if (IS_NOT_NULL(en->te.Else)) {
r = optimize_nodes(en->te.Else, &xo, env);
if (r == 0)
alt_merge_node_opt_info(opt, &xo, env);
}
}
}
break;
}
}
break;
case NODE_GIMMICK:
break;
default:
#ifdef ONIG_DEBUG
fprintf(stderr, "optimize_nodes: undefined node type %d\n", NODE_TYPE(node));
#endif
r = ONIGERR_TYPE_BUG;
break;
}
return r;
}
| 0
|
197,565
|
static int MqttClient_WaitType(MqttClient *client, void *packet_obj,
byte wait_type, word16 wait_packet_id, int timeout_ms)
{
int rc;
word16 packet_id;
MqttPacketType packet_type;
#ifdef WOLFMQTT_MULTITHREAD
MqttPendResp *pendResp;
int readLocked;
#endif
MqttMsgStat* mms_stat;
int waitMatchFound;
if (client == NULL || packet_obj == NULL) {
return MQTT_CODE_ERROR_BAD_ARG;
}
/* all packet type structures must have MqttMsgStat at top */
mms_stat = (MqttMsgStat*)packet_obj;
wait_again:
/* initialize variables */
packet_id = 0;
packet_type = MQTT_PACKET_TYPE_RESERVED;
#ifdef WOLFMQTT_MULTITHREAD
pendResp = NULL;
readLocked = 0;
#endif
waitMatchFound = 0;
#ifdef WOLFMQTT_DEBUG_CLIENT
PRINTF("MqttClient_WaitType: Type %s (%d), ID %d",
MqttPacket_TypeDesc((MqttPacketType)wait_type),
wait_type, wait_packet_id);
#endif
switch ((int)*mms_stat)
{
case MQTT_MSG_BEGIN:
{
#ifdef WOLFMQTT_MULTITHREAD
/* Lock recv socket mutex */
rc = wm_SemLock(&client->lockRecv);
if (rc != 0) {
PRINTF("MqttClient_WaitType: recv lock error!");
return rc;
}
readLocked = 1;
#endif
/* reset the packet state */
client->packet.stat = MQTT_PK_BEGIN;
}
FALL_THROUGH;
#ifdef WOLFMQTT_V5
case MQTT_MSG_AUTH:
#endif
case MQTT_MSG_WAIT:
{
#ifdef WOLFMQTT_MULTITHREAD
/* Check to see if packet type and id have already completed */
pendResp = NULL;
rc = wm_SemLock(&client->lockClient);
if (rc == 0) {
if (MqttClient_RespList_Find(client, (MqttPacketType)wait_type,
wait_packet_id, &pendResp)) {
if (pendResp->packetDone) {
/* pending response is already done, so return */
rc = pendResp->packet_ret;
#ifdef WOLFMQTT_DEBUG_CLIENT
PRINTF("PendResp already Done %p: Rc %d", pendResp, rc);
#endif
MqttClient_RespList_Remove(client, pendResp);
wm_SemUnlock(&client->lockClient);
wm_SemUnlock(&client->lockRecv);
return rc;
}
}
wm_SemUnlock(&client->lockClient);
}
else {
break; /* error */
}
#endif /* WOLFMQTT_MULTITHREAD */
*mms_stat = MQTT_MSG_WAIT;
/* Wait for packet */
rc = MqttPacket_Read(client, client->rx_buf, client->rx_buf_len,
timeout_ms);
/* handle failure */
if (rc <= 0) {
break;
}
/* capture length read */
client->packet.buf_len = rc;
/* Decode Packet - get type and id */
rc = MqttClient_DecodePacket(client, client->rx_buf,
client->packet.buf_len, NULL, &packet_type, NULL, &packet_id);
if (rc < 0) {
break;
}
#ifdef WOLFMQTT_DEBUG_CLIENT
PRINTF("Read Packet: Len %d, Type %d, ID %d",
client->packet.buf_len, packet_type, packet_id);
#endif
*mms_stat = MQTT_MSG_READ;
}
FALL_THROUGH;
case MQTT_MSG_READ:
case MQTT_MSG_READ_PAYLOAD:
{
MqttPacketType use_packet_type;
void* use_packet_obj;
#ifdef WOLFMQTT_MULTITHREAD
readLocked = 1; /* if in this state read is locked */
#endif
/* read payload state only happens for publish messages */
if (*mms_stat == MQTT_MSG_READ_PAYLOAD) {
packet_type = MQTT_PACKET_TYPE_PUBLISH;
}
/* Determine if we received data for this request */
if ((wait_type == MQTT_PACKET_TYPE_ANY ||
wait_type == packet_type ||
MqttIsPubRespPacket(packet_type) == MqttIsPubRespPacket(wait_type)) &&
(wait_packet_id == 0 || wait_packet_id == packet_id))
{
use_packet_obj = packet_obj;
waitMatchFound = 1;
}
else {
/* use generic packet object */
use_packet_obj = &client->msg;
}
use_packet_type = packet_type;
#ifdef WOLFMQTT_MULTITHREAD
/* Check to see if we have a pending response for this packet */
pendResp = NULL;
rc = wm_SemLock(&client->lockClient);
if (rc == 0) {
if (MqttClient_RespList_Find(client, packet_type, packet_id,
&pendResp)) {
/* we found packet match this incoming read packet */
pendResp->packetProcessing = 1;
use_packet_obj = pendResp->packet_obj;
use_packet_type = pendResp->packet_type;
/* req from another thread... not a match */
waitMatchFound = 0;
}
wm_SemUnlock(&client->lockClient);
}
else {
break; /* error */
}
#endif /* WOLFMQTT_MULTITHREAD */
/* Perform packet handling for publish callback and QoS */
rc = MqttClient_HandlePacket(client, use_packet_type,
use_packet_obj, timeout_ms);
#ifdef WOLFMQTT_NONBLOCK
if (rc == MQTT_CODE_CONTINUE) {
/* we have received some data, so keep the recv
mutex lock active and return */
return rc;
}
#endif
/* handle success case */
if (rc >= 0) {
rc = MQTT_CODE_SUCCESS;
}
#ifdef WOLFMQTT_MULTITHREAD
if (pendResp) {
/* Mark pending response entry done */
if (wm_SemLock(&client->lockClient) == 0) {
pendResp->packetDone = 1;
pendResp->packet_ret = rc;
#ifdef WOLFMQTT_DEBUG_CLIENT
PRINTF("PendResp Done %p", pendResp);
#endif
pendResp = NULL;
wm_SemUnlock(&client->lockClient);
}
}
#endif /* WOLFMQTT_MULTITHREAD */
break;
}
case MQTT_MSG_WRITE:
case MQTT_MSG_WRITE_PAYLOAD:
default:
{
#ifdef WOLFMQTT_DEBUG_CLIENT
PRINTF("MqttClient_WaitType: Invalid state %d!", *mms_stat);
#endif
rc = MQTT_CODE_ERROR_STAT;
break;
}
} /* switch (*mms_stat) */
#ifdef WOLFMQTT_NONBLOCK
if (rc != MQTT_CODE_CONTINUE)
#endif
{
/* reset state */
*mms_stat = MQTT_MSG_BEGIN;
}
#ifdef WOLFMQTT_MULTITHREAD
if (readLocked) {
wm_SemUnlock(&client->lockRecv);
}
#endif
if (rc < 0) {
#ifdef WOLFMQTT_DEBUG_CLIENT
PRINTF("MqttClient_WaitType: Failure: %s (%d)",
MqttClient_ReturnCodeToString(rc), rc);
#endif
return rc;
}
if (!waitMatchFound) {
/* if we get here, then the we are still waiting for a packet */
goto wait_again;
}
return rc;
}
| 1
|
204,495
|
static int __io_sync_cancel(struct io_uring_task *tctx,
struct io_cancel_data *cd, int fd)
{
struct io_ring_ctx *ctx = cd->ctx;
/* fixed must be grabbed every time since we drop the uring_lock */
if ((cd->flags & IORING_ASYNC_CANCEL_FD) &&
(cd->flags & IORING_ASYNC_CANCEL_FD_FIXED)) {
unsigned long file_ptr;
if (unlikely(fd > ctx->nr_user_files))
return -EBADF;
fd = array_index_nospec(fd, ctx->nr_user_files);
file_ptr = io_fixed_file_slot(&ctx->file_table, fd)->file_ptr;
cd->file = (struct file *) (file_ptr & FFS_MASK);
if (!cd->file)
return -EBADF;
}
return __io_async_cancel(cd, tctx, 0);
}
| 1
|
513,156
|
bool sys_var_pluginvar::global_update(THD *thd, set_var *var)
{
DBUG_ASSERT(!is_readonly());
mysql_mutex_assert_owner(&LOCK_global_system_variables);
void *tgt= real_value_ptr(thd, OPT_GLOBAL);
const void *src= &var->save_result;
if (!var->value)
src= var_def_ptr(plugin_var);
plugin_var->update(thd, plugin_var, tgt, src);
return false;
}
| 0
|
387,788
|
Klass* InstanceKlass::find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const {
// search order according to newest JVM spec (5.4.3.2, p.167).
// 1) search for field in current klass
if (find_local_field(name, sig, fd)) {
return const_cast<InstanceKlass*>(this);
}
// 2) search for field recursively in direct superinterfaces
{ Klass* intf = find_interface_field(name, sig, fd);
if (intf != NULL) return intf;
}
// 3) apply field lookup recursively if superclass exists
{ Klass* supr = super();
if (supr != NULL) return InstanceKlass::cast(supr)->find_field(name, sig, fd);
}
// 4) otherwise field lookup fails
return NULL;
}
| 0
|
208,673
|
handle_spawn (PortalFlatpak *object,
GDBusMethodInvocation *invocation,
GUnixFDList *fd_list,
const gchar *arg_cwd_path,
const gchar *const *arg_argv,
GVariant *arg_fds,
GVariant *arg_envs,
guint arg_flags,
GVariant *arg_options)
{
g_autoptr(GError) error = NULL;
ChildSetupData child_setup_data = { NULL };
GPid pid;
PidData *pid_data;
InstanceIdReadData *instance_id_read_data = NULL;
gsize i, j, n_fds, n_envs;
const gint *fds = NULL;
gint fds_len = 0;
g_autofree FdMapEntry *fd_map = NULL;
gchar **env;
gint32 max_fd;
GKeyFile *app_info;
g_autoptr(GPtrArray) flatpak_argv = g_ptr_array_new_with_free_func (g_free);
g_autofree char *app_id = NULL;
g_autofree char *branch = NULL;
g_autofree char *arch = NULL;
g_autofree char *app_commit = NULL;
g_autofree char *runtime_ref = NULL;
g_auto(GStrv) runtime_parts = NULL;
g_autofree char *runtime_commit = NULL;
g_autofree char *instance_path = NULL;
g_auto(GStrv) extra_args = NULL;
g_auto(GStrv) shares = NULL;
g_auto(GStrv) sockets = NULL;
g_auto(GStrv) devices = NULL;
g_auto(GStrv) sandbox_expose = NULL;
g_auto(GStrv) sandbox_expose_ro = NULL;
g_autoptr(GVariant) sandbox_expose_fd = NULL;
g_autoptr(GVariant) sandbox_expose_fd_ro = NULL;
g_autoptr(GOutputStream) instance_id_out_stream = NULL;
guint sandbox_flags = 0;
gboolean sandboxed;
gboolean expose_pids;
gboolean share_pids;
gboolean notify_start;
gboolean devel;
g_autoptr(GString) env_string = g_string_new ("");
child_setup_data.instance_id_fd = -1;
child_setup_data.env_fd = -1;
if (fd_list != NULL)
fds = g_unix_fd_list_peek_fds (fd_list, &fds_len);
app_info = g_object_get_data (G_OBJECT (invocation), "app-info");
g_assert (app_info != NULL);
app_id = g_key_file_get_string (app_info,
FLATPAK_METADATA_GROUP_APPLICATION,
FLATPAK_METADATA_KEY_NAME, NULL);
g_assert (app_id != NULL);
g_debug ("spawn() called from app: '%s'", app_id);
if (*app_id == 0)
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_INVALID_ARGS,
"org.freedesktop.portal.Flatpak.Spawn only works in a flatpak");
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
if (*arg_cwd_path == 0)
arg_cwd_path = NULL;
if (arg_argv == NULL || *arg_argv == NULL)
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_INVALID_ARGS,
"No command given");
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
if ((arg_flags & ~FLATPAK_SPAWN_FLAGS_ALL) != 0)
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
"Unsupported flags enabled: 0x%x", arg_flags & ~FLATPAK_SPAWN_FLAGS_ALL);
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
runtime_ref = g_key_file_get_string (app_info,
FLATPAK_METADATA_GROUP_APPLICATION,
FLATPAK_METADATA_KEY_RUNTIME, NULL);
if (runtime_ref == NULL)
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
"No runtime found");
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
runtime_parts = g_strsplit (runtime_ref, "/", -1);
branch = g_key_file_get_string (app_info,
FLATPAK_METADATA_GROUP_INSTANCE,
FLATPAK_METADATA_KEY_BRANCH, NULL);
instance_path = g_key_file_get_string (app_info,
FLATPAK_METADATA_GROUP_INSTANCE,
FLATPAK_METADATA_KEY_INSTANCE_PATH, NULL);
arch = g_key_file_get_string (app_info,
FLATPAK_METADATA_GROUP_INSTANCE,
FLATPAK_METADATA_KEY_ARCH, NULL);
extra_args = g_key_file_get_string_list (app_info,
FLATPAK_METADATA_GROUP_INSTANCE,
FLATPAK_METADATA_KEY_EXTRA_ARGS, NULL, NULL);
app_commit = g_key_file_get_string (app_info,
FLATPAK_METADATA_GROUP_INSTANCE,
FLATPAK_METADATA_KEY_APP_COMMIT, NULL);
runtime_commit = g_key_file_get_string (app_info,
FLATPAK_METADATA_GROUP_INSTANCE,
FLATPAK_METADATA_KEY_RUNTIME_COMMIT, NULL);
shares = g_key_file_get_string_list (app_info, FLATPAK_METADATA_GROUP_CONTEXT,
FLATPAK_METADATA_KEY_SHARED, NULL, NULL);
sockets = g_key_file_get_string_list (app_info, FLATPAK_METADATA_GROUP_CONTEXT,
FLATPAK_METADATA_KEY_SOCKETS, NULL, NULL);
devices = g_key_file_get_string_list (app_info, FLATPAK_METADATA_GROUP_CONTEXT,
FLATPAK_METADATA_KEY_DEVICES, NULL, NULL);
devel = g_key_file_get_boolean (app_info, FLATPAK_METADATA_GROUP_INSTANCE,
FLATPAK_METADATA_KEY_DEVEL, NULL);
g_variant_lookup (arg_options, "sandbox-expose", "^as", &sandbox_expose);
g_variant_lookup (arg_options, "sandbox-expose-ro", "^as", &sandbox_expose_ro);
g_variant_lookup (arg_options, "sandbox-flags", "u", &sandbox_flags);
sandbox_expose_fd = g_variant_lookup_value (arg_options, "sandbox-expose-fd", G_VARIANT_TYPE ("ah"));
sandbox_expose_fd_ro = g_variant_lookup_value (arg_options, "sandbox-expose-fd-ro", G_VARIANT_TYPE ("ah"));
if ((sandbox_flags & ~FLATPAK_SPAWN_SANDBOX_FLAGS_ALL) != 0)
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
"Unsupported sandbox flags enabled: 0x%x", arg_flags & ~FLATPAK_SPAWN_SANDBOX_FLAGS_ALL);
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
if (instance_path == NULL &&
((sandbox_expose != NULL && sandbox_expose[0] != NULL) ||
(sandbox_expose_ro != NULL && sandbox_expose_ro[0] != NULL)))
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_INVALID_ARGS,
"Invalid sandbox expose, caller has no instance path");
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
for (i = 0; sandbox_expose != NULL && sandbox_expose[i] != NULL; i++)
{
const char *expose = sandbox_expose[i];
g_debug ("exposing %s", expose);
if (!is_valid_expose (expose, &error))
{
g_dbus_method_invocation_return_gerror (invocation, error);
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
}
for (i = 0; sandbox_expose_ro != NULL && sandbox_expose_ro[i] != NULL; i++)
{
const char *expose = sandbox_expose_ro[i];
g_debug ("exposing %s", expose);
if (!is_valid_expose (expose, &error))
{
g_dbus_method_invocation_return_gerror (invocation, error);
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
}
g_debug ("Running spawn command %s", arg_argv[0]);
n_fds = 0;
if (fds != NULL)
n_fds = g_variant_n_children (arg_fds);
fd_map = g_new0 (FdMapEntry, n_fds);
child_setup_data.fd_map = fd_map;
child_setup_data.fd_map_len = n_fds;
max_fd = -1;
for (i = 0; i < n_fds; i++)
{
gint32 handle, dest_fd;
int handle_fd;
g_variant_get_child (arg_fds, i, "{uh}", &dest_fd, &handle);
if (handle >= fds_len || handle < 0)
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_INVALID_ARGS,
"No file descriptor for handle %d",
handle);
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
handle_fd = fds[handle];
fd_map[i].to = dest_fd;
fd_map[i].from = handle_fd;
fd_map[i].final = fd_map[i].to;
/* If stdin/out/err is a tty we try to set it as the controlling
tty for the app, this way we can use this to run in a terminal. */
if ((dest_fd == 0 || dest_fd == 1 || dest_fd == 2) &&
!child_setup_data.set_tty &&
isatty (handle_fd))
{
child_setup_data.set_tty = TRUE;
child_setup_data.tty = handle_fd;
}
max_fd = MAX (max_fd, fd_map[i].to);
max_fd = MAX (max_fd, fd_map[i].from);
}
/* We make a second pass over the fds to find if any "to" fd index
overlaps an already in use fd (i.e. one in the "from" category
that are allocated randomly). If a fd overlaps "to" fd then its
a caller issue and not our fault, so we ignore that. */
for (i = 0; i < n_fds; i++)
{
int to_fd = fd_map[i].to;
gboolean conflict = FALSE;
/* At this point we're fine with using "from" values for this
value (because we handle to==from in the code), or values
that are before "i" in the fd_map (because those will be
closed at this point when dup:ing). However, we can't
reuse a fd that is in "from" for j > i. */
for (j = i + 1; j < n_fds; j++)
{
int from_fd = fd_map[j].from;
if (from_fd == to_fd)
{
conflict = TRUE;
break;
}
}
if (conflict)
fd_map[i].to = ++max_fd;
}
/* TODO: Ideally we should let `flatpak run` inherit the portal's
* environment, in case e.g. a LD_LIBRARY_PATH is needed to be able
* to run `flatpak run`, but tell it to start from a blank environment
* when running the Flatpak app; but this isn't currently possible, so
* for now we preserve existing behaviour. */
if (arg_flags & FLATPAK_SPAWN_FLAGS_CLEAR_ENV)
{
char *empty[] = { NULL };
env = g_strdupv (empty);
}
else
env = g_get_environ ();
/* Let the environment variables given by the caller override the ones
* from extra_args. Don't add them to @env, because they are controlled
* by our caller, which might be trying to use them to inject code into
* flatpak(1); add them to the environment block instead.
*
* We don't use --env= here, so that if the values are something that
* should not be exposed to other uids, they can remain confidential. */
n_envs = g_variant_n_children (arg_envs);
for (i = 0; i < n_envs; i++)
{
const char *var = NULL;
const char *val = NULL;
g_variant_get_child (arg_envs, i, "{&s&s}", &var, &val);
if (var[0] == '\0')
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_INVALID_ARGS,
"Environment variable cannot have empty name");
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
if (strchr (var, '=') != NULL)
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_INVALID_ARGS,
"Environment variable name cannot contain '='");
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
g_string_append (env_string, var);
g_string_append_c (env_string, '=');
g_string_append (env_string, val);
g_string_append_c (env_string, '\0');
}
g_ptr_array_add (flatpak_argv, g_strdup ("flatpak"));
g_ptr_array_add (flatpak_argv, g_strdup ("run"));
sandboxed = (arg_flags & FLATPAK_SPAWN_FLAGS_SANDBOX) != 0;
if (sandboxed)
{
g_ptr_array_add (flatpak_argv, g_strdup ("--sandbox"));
if (sandbox_flags & FLATPAK_SPAWN_SANDBOX_FLAGS_SHARE_DISPLAY)
{
if (sockets != NULL && g_strv_contains ((const char * const *) sockets, "wayland"))
g_ptr_array_add (flatpak_argv, g_strdup ("--socket=wayland"));
if (sockets != NULL && g_strv_contains ((const char * const *) sockets, "fallback-x11"))
g_ptr_array_add (flatpak_argv, g_strdup ("--socket=fallback-x11"));
if (sockets != NULL && g_strv_contains ((const char * const *) sockets, "x11"))
g_ptr_array_add (flatpak_argv, g_strdup ("--socket=x11"));
if (shares != NULL && g_strv_contains ((const char * const *) shares, "ipc") &&
sockets != NULL && (g_strv_contains ((const char * const *) sockets, "fallback-x11") ||
g_strv_contains ((const char * const *) sockets, "x11")))
g_ptr_array_add (flatpak_argv, g_strdup ("--share=ipc"));
}
if (sandbox_flags & FLATPAK_SPAWN_SANDBOX_FLAGS_SHARE_SOUND)
{
if (sockets != NULL && g_strv_contains ((const char * const *) sockets, "pulseaudio"))
g_ptr_array_add (flatpak_argv, g_strdup ("--socket=pulseaudio"));
}
if (sandbox_flags & FLATPAK_SPAWN_SANDBOX_FLAGS_SHARE_GPU)
{
if (devices != NULL &&
(g_strv_contains ((const char * const *) devices, "dri") ||
g_strv_contains ((const char * const *) devices, "all")))
g_ptr_array_add (flatpak_argv, g_strdup ("--device=dri"));
}
if (sandbox_flags & FLATPAK_SPAWN_SANDBOX_FLAGS_ALLOW_DBUS)
g_ptr_array_add (flatpak_argv, g_strdup ("--session-bus"));
if (sandbox_flags & FLATPAK_SPAWN_SANDBOX_FLAGS_ALLOW_A11Y)
g_ptr_array_add (flatpak_argv, g_strdup ("--a11y-bus"));
}
else
{
for (i = 0; extra_args != NULL && extra_args[i] != NULL; i++)
{
if (g_str_has_prefix (extra_args[i], "--env="))
{
const char *var_val = extra_args[i] + strlen ("--env=");
if (var_val[0] == '\0' || var_val[0] == '=')
{
g_warning ("Environment variable in extra-args has empty name");
continue;
}
if (strchr (var_val, '=') == NULL)
{
g_warning ("Environment variable in extra-args has no value");
continue;
}
g_string_append (env_string, var_val);
g_string_append_c (env_string, '\0');
}
else
{
g_ptr_array_add (flatpak_argv, g_strdup (extra_args[i]));
}
}
}
if (env_string->len > 0)
{
g_auto(GLnxTmpfile) env_tmpf = { 0, };
if (!flatpak_buffer_to_sealed_memfd_or_tmpfile (&env_tmpf, "environ",
env_string->str,
env_string->len, &error))
{
g_dbus_method_invocation_return_gerror (invocation, error);
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
child_setup_data.env_fd = glnx_steal_fd (&env_tmpf.fd);
g_ptr_array_add (flatpak_argv,
g_strdup_printf ("--env-fd=%d",
child_setup_data.env_fd));
}
expose_pids = (arg_flags & FLATPAK_SPAWN_FLAGS_EXPOSE_PIDS) != 0;
share_pids = (arg_flags & FLATPAK_SPAWN_FLAGS_SHARE_PIDS) != 0;
if (expose_pids || share_pids)
{
g_autofree char *instance_id = NULL;
int sender_pid1 = 0;
if (!(supports & FLATPAK_SPAWN_SUPPORT_FLAGS_EXPOSE_PIDS))
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_NOT_SUPPORTED,
"Expose pids not supported with setuid bwrap");
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
instance_id = g_key_file_get_string (app_info,
FLATPAK_METADATA_GROUP_INSTANCE,
FLATPAK_METADATA_KEY_INSTANCE_ID, NULL);
if (instance_id)
{
g_autoptr(FlatpakInstance) instance = flatpak_instance_new_for_id (instance_id);
sender_pid1 = flatpak_instance_get_child_pid (instance);
}
if (sender_pid1 == 0)
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_INVALID_ARGS,
"Could not find requesting pid");
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
g_ptr_array_add (flatpak_argv, g_strdup_printf ("--parent-pid=%d", sender_pid1));
if (share_pids)
g_ptr_array_add (flatpak_argv, g_strdup ("--parent-share-pids"));
else
g_ptr_array_add (flatpak_argv, g_strdup ("--parent-expose-pids"));
}
notify_start = (arg_flags & FLATPAK_SPAWN_FLAGS_NOTIFY_START) != 0;
if (notify_start)
{
int pipe_fds[2];
if (pipe (pipe_fds) == -1)
{
int errsv = errno;
g_dbus_method_invocation_return_error (invocation, G_IO_ERROR,
g_io_error_from_errno (errsv),
"Failed to create instance ID pipe: %s",
g_strerror (errsv));
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
GInputStream *in_stream = G_INPUT_STREAM (g_unix_input_stream_new (pipe_fds[0], TRUE));
/* This is saved to ensure the portal's end gets closed after the exec. */
instance_id_out_stream = G_OUTPUT_STREAM (g_unix_output_stream_new (pipe_fds[1], TRUE));
instance_id_read_data = g_new0 (InstanceIdReadData, 1);
g_input_stream_read_async (in_stream, instance_id_read_data->buffer,
INSTANCE_ID_BUFFER_SIZE - 1, G_PRIORITY_DEFAULT, NULL,
instance_id_read_finish, instance_id_read_data);
g_ptr_array_add (flatpak_argv, g_strdup_printf ("--instance-id-fd=%d", pipe_fds[1]));
child_setup_data.instance_id_fd = pipe_fds[1];
}
if (devel)
g_ptr_array_add (flatpak_argv, g_strdup ("--devel"));
/* Inherit launcher network access from launcher, unless
NO_NETWORK set. */
if (shares != NULL && g_strv_contains ((const char * const *) shares, "network") &&
!(arg_flags & FLATPAK_SPAWN_FLAGS_NO_NETWORK))
g_ptr_array_add (flatpak_argv, g_strdup ("--share=network"));
else
g_ptr_array_add (flatpak_argv, g_strdup ("--unshare=network"));
if (instance_path)
{
for (i = 0; sandbox_expose != NULL && sandbox_expose[i] != NULL; i++)
g_ptr_array_add (flatpak_argv,
filesystem_sandbox_arg (instance_path, sandbox_expose[i], FALSE));
for (i = 0; sandbox_expose_ro != NULL && sandbox_expose_ro[i] != NULL; i++)
g_ptr_array_add (flatpak_argv,
filesystem_sandbox_arg (instance_path, sandbox_expose_ro[i], TRUE));
}
for (i = 0; sandbox_expose_ro != NULL && sandbox_expose_ro[i] != NULL; i++)
{
const char *expose = sandbox_expose_ro[i];
g_debug ("exposing %s", expose);
}
if (sandbox_expose_fd != NULL)
{
gsize len = g_variant_n_children (sandbox_expose_fd);
for (i = 0; i < len; i++)
{
gint32 handle;
g_variant_get_child (sandbox_expose_fd, i, "h", &handle);
if (handle >= 0 && handle < fds_len)
{
int handle_fd = fds[handle];
g_autofree char *path = NULL;
gboolean writable = FALSE;
path = get_path_for_fd (handle_fd, &writable, &error);
if (path)
{
g_ptr_array_add (flatpak_argv, filesystem_arg (path, !writable));
}
else
{
g_debug ("unable to get path for sandbox-exposed fd %d, ignoring: %s",
handle_fd, error->message);
g_clear_error (&error);
}
}
else
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_INVALID_ARGS,
"No file descriptor for handle %d",
handle);
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
}
}
if (sandbox_expose_fd_ro != NULL)
{
gsize len = g_variant_n_children (sandbox_expose_fd_ro);
for (i = 0; i < len; i++)
{
gint32 handle;
g_variant_get_child (sandbox_expose_fd_ro, i, "h", &handle);
if (handle >= 0 && handle < fds_len)
{
int handle_fd = fds[handle];
g_autofree char *path = NULL;
gboolean writable = FALSE;
path = get_path_for_fd (handle_fd, &writable, &error);
if (path)
{
g_ptr_array_add (flatpak_argv, filesystem_arg (path, TRUE));
}
else
{
g_debug ("unable to get path for sandbox-exposed fd %d, ignoring: %s",
handle_fd, error->message);
g_clear_error (&error);
}
}
else
{
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR,
G_DBUS_ERROR_INVALID_ARGS,
"No file descriptor for handle %d",
handle);
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
}
}
g_ptr_array_add (flatpak_argv, g_strdup_printf ("--runtime=%s", runtime_parts[1]));
g_ptr_array_add (flatpak_argv, g_strdup_printf ("--runtime-version=%s", runtime_parts[3]));
if ((arg_flags & FLATPAK_SPAWN_FLAGS_LATEST_VERSION) == 0)
{
if (app_commit)
g_ptr_array_add (flatpak_argv, g_strdup_printf ("--commit=%s", app_commit));
if (runtime_commit)
g_ptr_array_add (flatpak_argv, g_strdup_printf ("--runtime-commit=%s", runtime_commit));
}
if (arg_cwd_path != NULL)
g_ptr_array_add (flatpak_argv, g_strdup_printf ("--cwd=%s", arg_cwd_path));
if (arg_argv[0][0] != 0)
g_ptr_array_add (flatpak_argv, g_strdup_printf ("--command=%s", arg_argv[0]));
g_ptr_array_add (flatpak_argv, g_strdup_printf ("%s/%s/%s", app_id, arch ? arch : "", branch ? branch : ""));
for (i = 1; arg_argv[i] != NULL; i++)
g_ptr_array_add (flatpak_argv, g_strdup (arg_argv[i]));
g_ptr_array_add (flatpak_argv, NULL);
if (opt_verbose)
{
g_autoptr(GString) cmd = g_string_new ("");
for (i = 0; flatpak_argv->pdata[i] != NULL; i++)
{
if (i > 0)
g_string_append (cmd, " ");
g_string_append (cmd, flatpak_argv->pdata[i]);
}
g_debug ("Starting: %s\n", cmd->str);
}
/* We use LEAVE_DESCRIPTORS_OPEN to work around dead-lock, see flatpak_close_fds_workaround */
if (!g_spawn_async_with_pipes (NULL,
(char **) flatpak_argv->pdata,
env,
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_LEAVE_DESCRIPTORS_OPEN,
child_setup_func, &child_setup_data,
&pid,
NULL,
NULL,
NULL,
&error))
{
gint code = G_DBUS_ERROR_FAILED;
if (g_error_matches (error, G_SPAWN_ERROR, G_SPAWN_ERROR_ACCES))
code = G_DBUS_ERROR_ACCESS_DENIED;
else if (g_error_matches (error, G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT))
code = G_DBUS_ERROR_FILE_NOT_FOUND;
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, code,
"Failed to start command: %s",
error->message);
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
if (instance_id_read_data)
instance_id_read_data->pid = pid;
pid_data = g_new0 (PidData, 1);
pid_data->pid = pid;
pid_data->client = g_strdup (g_dbus_method_invocation_get_sender (invocation));
pid_data->watch_bus = (arg_flags & FLATPAK_SPAWN_FLAGS_WATCH_BUS) != 0;
pid_data->expose_or_share_pids = (expose_pids || share_pids);
pid_data->child_watch = g_child_watch_add_full (G_PRIORITY_DEFAULT,
pid,
child_watch_died,
pid_data,
NULL);
g_debug ("Client Pid is %d", pid_data->pid);
g_hash_table_replace (client_pid_data_hash, GUINT_TO_POINTER (pid_data->pid),
pid_data);
portal_flatpak_complete_spawn (object, invocation, NULL, pid);
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
| 1
|
391,652
|
static bool file_has_brlocks(files_struct *fsp)
{
struct byte_range_lock *br_lck;
br_lck = brl_get_locks_readonly(fsp);
if (!br_lck)
return false;
return (brl_num_locks(br_lck) > 0);
}
| 0
|
272,372
|
is_valid_cert(CERTCertificate *cert, void *data)
{
struct validity_cbdata *cbd = (struct validity_cbdata *)data;
PK11SlotInfo *slot = cbd->slot;
SECKEYPrivateKey *privkey = NULL;
int errnum;
errnum = PORT_GetError();
if (errnum == SEC_ERROR_EXTENSION_NOT_FOUND) {
dprintf("Got SEC_ERROR_EXTENSION_NOT_FOUND; clearing");
PORT_SetError(0);
errnum = 0;
}
if (cert == NULL) {
if (!errnum)
PORT_SetError(SEC_ERROR_UNKNOWN_CERT);
return SECFailure;
}
privkey = PK11_FindPrivateKeyFromCert(slot, cert, cbd->cms);
if (privkey != NULL) {
if (cbd->cert)
CERT_DestroyCertificate(cbd->cert);
cbd->cert = CERT_DupCertificate(cert);
CERT_DestroyCertificate(cert);
SECKEY_DestroyPrivateKey(privkey);
PORT_SetError(0);
return SECSuccess;
}
return SECFailure;
}
| 0
|
293,547
|
PJ_DEF(void) pj_scan_restore_state( pj_scanner *scanner,
pj_scan_state *state)
{
scanner->curptr = state->curptr;
scanner->line = state->line;
scanner->start_line = state->start_line;
}
| 0
|
477,802
|
static int pfkey_process(struct sock *sk, struct sk_buff *skb, const struct sadb_msg *hdr)
{
void *ext_hdrs[SADB_EXT_MAX];
int err;
/* Non-zero return value of pfkey_broadcast() does not always signal
* an error and even on an actual error we may still want to process
* the message so rather ignore the return value.
*/
pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL,
BROADCAST_PROMISC_ONLY, NULL, sock_net(sk));
memset(ext_hdrs, 0, sizeof(ext_hdrs));
err = parse_exthdrs(skb, hdr, ext_hdrs);
if (!err) {
err = -EOPNOTSUPP;
if (pfkey_funcs[hdr->sadb_msg_type])
err = pfkey_funcs[hdr->sadb_msg_type](sk, skb, hdr, ext_hdrs);
}
return err;
}
| 0
|
244,338
|
GF_Err stsg_box_size(GF_Box *s)
{
GF_SubTrackSampleGroupBox *ptr = (GF_SubTrackSampleGroupBox *)s;
ptr->size += 6 + 4 * ptr->nb_groups;
return GF_OK;
}
| 0
|
463,134
|
static int write_entry(struct mailbox *mailbox,
unsigned int uid,
const char *entry,
const char *userid,
const struct buf *value,
int ignorequota,
int silent,
const struct annotate_metadata *mdata,
int maywrite)
{
char key[MAX_MAILBOX_PATH+1];
int keylen, r;
annotate_db_t *d = NULL;
struct buf oldval = BUF_INITIALIZER;
const char *mboxname = mailbox ? mailbox->name : "";
modseq_t modseq = mdata ? mdata->modseq : 0;
r = _annotate_getdb(mboxname, uid, CYRUSDB_CREATE, &d);
if (r)
return r;
/* must be in a transaction to modify the db */
annotate_begin(d);
keylen = make_key(mboxname, uid, entry, userid, key, sizeof(key));
struct annotate_metadata oldmdata;
r = read_old_value(d, key, keylen, &oldval, &oldmdata);
if (r) goto out;
/* if the value is identical, don't touch the mailbox */
if (oldval.len == value->len && (!value->len || !memcmp(oldval.s, value->s, value->len)))
goto out;
if (!maywrite) {
r = IMAP_PERMISSION_DENIED;
if (r) goto out;
}
if (mailbox) {
if (!ignorequota) {
quota_t qdiffs[QUOTA_NUMRESOURCES] = QUOTA_DIFFS_DONTCARE_INITIALIZER;
qdiffs[QUOTA_ANNOTSTORAGE] = value->len - (quota_t)oldval.len;
r = mailbox_quota_check(mailbox, qdiffs);
if (r) goto out;
}
/* do the annot-changed here before altering the DB */
mailbox_annot_changed(mailbox, uid, entry, userid, &oldval, value, silent);
/* grab the message annotation modseq, if not overridden */
if (uid && !mdata) {
modseq = mailbox->i.highestmodseq;
}
}
/* zero length annotation is deletion.
* keep tombstones for message annotations */
if (!value->len && !uid) {
#if DEBUG
syslog(LOG_ERR, "write_entry: deleting key %s from %s",
key_as_string(d, key, keylen), d->filename);
#endif
do {
r = cyrusdb_delete(d->db, key, keylen, tid(d), /*force*/1);
} while (r == CYRUSDB_AGAIN);
}
else {
struct buf data = BUF_INITIALIZER;
unsigned char flags = 0;
if (!value->len || value->s == NULL) {
flags |= ANNOTATE_FLAG_DELETED;
}
else {
// this is only here to allow cleanup of invalid values in the past...
// the calling of this API with a NULL "userid" is bogus, because that's
// supposed to be reserved for the make_key of prefixes - but there has
// been API abuse in the past, so some of these are in the wild. *sigh*.
// Don't allow new ones to be written
if (!userid) goto out;
}
make_entry(&data, value, modseq, flags);
#if DEBUG
syslog(LOG_ERR, "write_entry: storing key %s (value: %s) to %s (modseq=" MODSEQ_FMT ")",
key_as_string(d, key, keylen), value->s, d->filename, modseq);
#endif
do {
r = cyrusdb_store(d->db, key, keylen, data.s, data.len, tid(d));
} while (r == CYRUSDB_AGAIN);
buf_free(&data);
}
if (!mailbox)
sync_log_annotation("");
out:
annotate_putdb(&d);
buf_free(&oldval);
return r;
}
| 0
|
273,927
|
static void handle_MKD(ctrl_t *ctrl, char *arg)
{
char *path;
path = compose_abspath(ctrl, arg);
if (!path) {
INFO("Invalid path for %s: %m", arg);
goto fail;
}
if (mkdir(path, 0755)) {
if (EPERM == errno)
fail: send_msg(ctrl->sd, "550 Not allowed to create directory.\r\n");
else
send_msg(ctrl->sd, "550 Unknown error.\r\n");
return;
}
send_msg(ctrl->sd, "200 Command OK\r\n");
}
| 0
|
508,879
|
TABLE_LIST* st_select_lex::get_table_list()
{
return table_list.first;
}
| 0
|
248,237
|
DLLIMPORT char *cfg_opt_getnstr(cfg_opt_t *opt, unsigned int index)
{
if (!opt || opt->type != CFGT_STR) {
errno = EINVAL;
return NULL;
}
if (opt->values && index < opt->nvalues)
return opt->values[index]->string;
if (opt->simple_value.string)
return *opt->simple_value.string;
return NULL;
}
| 0
|
201,384
|
ga_concat_shorten_esc(garray_T *gap, char_u *str)
{
char_u *p;
char_u *s;
int c;
int clen;
char_u buf[NUMBUFLEN];
int same_len;
if (str == NULL)
{
ga_concat(gap, (char_u *)"NULL");
return;
}
for (p = str; *p != NUL; ++p)
{
same_len = 1;
s = p;
c = mb_ptr2char_adv(&s);
clen = s - p;
while (*s != NUL && c == mb_ptr2char(s))
{
++same_len;
s += clen;
}
if (same_len > 20)
{
ga_concat(gap, (char_u *)"\\[");
ga_concat_esc(gap, p, clen);
ga_concat(gap, (char_u *)" occurs ");
vim_snprintf((char *)buf, NUMBUFLEN, "%d", same_len);
ga_concat(gap, buf);
ga_concat(gap, (char_u *)" times]");
p = s - 1;
}
else
ga_concat_esc(gap, p, clen);
}
}
| 1
|
413,691
|
static bool esilbreak_mem_write(RAnalEsil *esil, ut64 addr, const ut8 *buf, int len) {
handle_var_stack_access (esil, addr, R_ANAL_VAR_ACCESS_TYPE_WRITE, len);
return true;
}
| 0
|
90,189
|
static std::string ToHtmlTableRow(Network* network) {
std::string str;
if (network->type() == TYPE_WIFI || network->type() == TYPE_CELLULAR) {
WirelessNetwork* wireless = static_cast<WirelessNetwork*>(network);
str += WrapWithTD(wireless->name()) +
WrapWithTD(base::IntToString(wireless->auto_connect())) +
WrapWithTD(base::IntToString(wireless->strength()));
if (network->type() == TYPE_WIFI) {
WifiNetwork* wifi = static_cast<WifiNetwork*>(network);
str += WrapWithTD(wifi->GetEncryptionString()) +
WrapWithTD(std::string(wifi->passphrase().length(), '*')) +
WrapWithTD(wifi->identity()) + WrapWithTD(wifi->cert_path());
}
}
str += WrapWithTD(network->GetStateString()) +
WrapWithTD(network->failed() ? network->GetErrorString() : "") +
WrapWithTD(network->ip_address());
return str;
}
| 0
|
221,661
|
int Socket::readFromSocketn(char *buff, int len, unsigned int flags, int timeout)
{
return readFromSocket(buff, len, flags, timeout, true, false);
#ifdef NODEF
if (!isssl) {
return BaseSocket::readFromSocketn(buff, len, flags, timeout);
}
int cnt, rc;
cnt = len;
// first, return what's left from the previous buffer read, if anything
if ((bufflen - buffstart) > 0) {
#ifdef NETDEBUG
std::cout << thread_id << "Socket::readFromSocketn: data already in buffer; bufflen: " << bufflen << " buffstart: " << buffstart << std::endl;
#endif
int tocopy = len;
if ((bufflen - buffstart) < len)
tocopy = bufflen - buffstart;
memcpy(buff, buffer + buffstart, tocopy);
cnt -= tocopy;
buffstart += tocopy;
buff += tocopy;
if (cnt == 0)
return len;
}
while (cnt > 0) {
// try {
//bcheckSForInput(timeout); // this may be wrong - why is data not being read into socket buffer????
// } catch (std::exception &e) {
// return -1;
// }
ERR_clear_error();
rc = SSL_read(ssl, buff, cnt);
#ifdef NETDEBUG
std::cout << thread_id << "ssl read said: " << rc << std::endl;
#endif
if (rc < 0) {
// if (errno == EINTR) {
// continue;
// }
log_ssl_errors("ssl_read failed %s", "");
s_errno = errno;
return -1;
}
if (rc == 0) { // eof
ishup = true;
return len - cnt;
}
buff += rc;
cnt -= rc;
}
return len;
#endif
}
| 0
|
232,828
|
void Compute(OpKernelContext* context) override {
ResourceHandle handle;
OP_REQUIRES_OK(context,
HandleFromInput(context, kResourceHandleName, &handle));
core::RefCountPtr<QuantileStreamResource> stream_resource;
// Create a reference to the underlying resource using the handle.
OP_REQUIRES_OK(context, LookupResource(context, handle, &stream_resource));
// Remove the reference at the end of this scope.
mutex_lock l(*stream_resource->mutex());
const Tensor* num_buckets_t;
OP_REQUIRES_OK(context, context->input(kNumBucketsName, &num_buckets_t));
const int64_t num_buckets = num_buckets_t->scalar<int64>()();
const int64_t num_streams = stream_resource->num_streams();
auto do_quantile_flush = [&](const int64_t begin, const int64_t end) {
// Iterating over all streams.
for (int64_t stream_idx = begin; stream_idx < end; ++stream_idx) {
QuantileStream* stream = stream_resource->stream(stream_idx);
stream->Finalize();
stream_resource->set_boundaries(
generate_quantiles_ ? GenerateQuantiles(*stream, num_buckets)
: GenerateBoundaries(*stream, num_buckets),
stream_idx);
}
};
// TODO(tanzheny): comment on the magic number.
const int64_t kCostPerUnit = 500 * num_streams;
const DeviceBase::CpuWorkerThreads& worker_threads =
*context->device()->tensorflow_cpu_worker_threads();
Shard(worker_threads.num_threads, worker_threads.workers, num_streams,
kCostPerUnit, do_quantile_flush);
stream_resource->ResetStreams();
stream_resource->set_buckets_ready(true);
}
| 0
|
492,670
|
_vte_terminal_scroll_text (VteTerminal *terminal, int scroll_amount)
{
long start, end, i;
VteScreen *screen;
screen = terminal->pvt->screen;
if (screen->scrolling_restricted) {
start = screen->insert_delta + screen->scrolling_region.start;
end = screen->insert_delta + screen->scrolling_region.end;
} else {
start = screen->insert_delta;
end = start + terminal->row_count - 1;
}
while (_vte_ring_next(screen->row_data) <= end)
_vte_terminal_ring_append (terminal, FALSE);
if (scroll_amount > 0) {
for (i = 0; i < scroll_amount; i++) {
_vte_terminal_ring_remove (terminal, end);
_vte_terminal_ring_insert (terminal, start, TRUE);
}
} else {
for (i = 0; i < -scroll_amount; i++) {
_vte_terminal_ring_remove (terminal, start);
_vte_terminal_ring_insert (terminal, end, TRUE);
}
}
/* Update the display. */
_vte_terminal_scroll_region(terminal, start, end - start + 1,
scroll_amount);
/* Adjust the scrollbars if necessary. */
_vte_terminal_adjust_adjustments(terminal);
/* We've modified the display. Make a note of it. */
terminal->pvt->text_inserted_flag = TRUE;
terminal->pvt->text_deleted_flag = TRUE;
}
| 0
|
222,920
|
DisjointSet<Handle>::GetMergedValue(Handle value) {
Rep* rep = Find(value);
if (!rep) {
// We don't know anything about this handle.
return HandleToObject<Handle>::Unknown();
}
return rep->value;
}
| 0
|
261,907
|
njs_string_truncate(njs_value_t *value, uint32_t size, uint32_t length)
{
u_char *dst, *src;
uint32_t n;
if (size <= NJS_STRING_SHORT) {
if (value->short_string.size == NJS_STRING_LONG) {
dst = value->short_string.start;
src = value->long_string.data->start;
n = size;
while (n != 0) {
/* The maximum size is just 14 bytes. */
njs_pragma_loop_disable_vectorization;
*dst++ = *src++;
n--;
}
}
value->short_string.size = size;
value->short_string.length = length;
} else {
value->long_string.size = size;
value->long_string.data->length = length;
}
}
| 0
|
462,238
|
PJ_DEF(pj_status_t) pj_stun_uint64_attr_create(pj_pool_t *pool,
int attr_type,
const pj_timestamp *value,
pj_stun_uint64_attr **p_attr)
{
pj_stun_uint64_attr *attr;
PJ_ASSERT_RETURN(pool && p_attr, PJ_EINVAL);
attr = PJ_POOL_ZALLOC_T(pool, pj_stun_uint64_attr);
INIT_ATTR(attr, attr_type, 8);
if (value) {
attr->value.u32.hi = value->u32.hi;
attr->value.u32.lo = value->u32.lo;
}
*p_attr = attr;
return PJ_SUCCESS;
}
| 0
|
261,239
|
int SN_Client_Connect(MqttClient *client, SN_Connect *mc_connect)
{
int rc = 0, len = 0;
static byte will_done;
/* Validate required arguments */
if ((client == NULL) || (mc_connect == NULL)) {
return MQTT_CODE_ERROR_BAD_ARG;
}
if (mc_connect->stat == MQTT_MSG_BEGIN) {
will_done = 0;
#ifdef WOLFMQTT_MULTITHREAD
/* Lock send socket mutex */
rc = wm_SemLock(&client->lockSend);
if (rc != 0) {
return rc;
}
#endif
/* Encode the connect packet */
rc = SN_Encode_Connect(client->tx_buf, client->tx_buf_len, mc_connect);
#ifdef WOLFMQTT_DEBUG_CLIENT
PRINTF("MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d, QoS %d",
rc, SN_Packet_TypeDesc(SN_MSG_TYPE_CONNECT),
SN_MSG_TYPE_CONNECT, 0, 0);
#endif
if (rc <= 0) {
#ifdef WOLFMQTT_MULTITHREAD
wm_SemUnlock(&client->lockSend);
#endif
return rc;
}
len = 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_CONNACK, 0,
&mc_connect->pendResp, &mc_connect->ack);
wm_SemUnlock(&client->lockClient);
}
if (rc != 0) {
wm_SemUnlock(&client->lockSend);
return rc; /* Error locking client */
}
#endif
/* Send connect packet */
rc = MqttPacket_Write(client, client->tx_buf, len);
#ifdef WOLFMQTT_MULTITHREAD
wm_SemUnlock(&client->lockSend);
#endif
if (rc != len) {
return rc;
}
mc_connect->stat = MQTT_MSG_WAIT;
}
if ((mc_connect->enable_lwt == 1) && (will_done != 1)) {
/* If the will is enabled, then the gateway requests the topic and
message in separate packets. */
rc = SN_WillTopic(client, &mc_connect->will);
if (rc != 0) {
return rc;
}
rc = SN_WillMessage(client, &mc_connect->will);
if (rc != 0) {
return rc;
}
will_done = 1;
}
/* Wait for connect ack packet */
rc = SN_Client_WaitType(client, &mc_connect->ack,
SN_MSG_TYPE_CONNACK, 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, &mc_connect->pendResp);
wm_SemUnlock(&client->lockClient);
}
#endif
/* reset state */
mc_connect->stat = MQTT_MSG_BEGIN;
return rc;
}
| 0
|
275,965
|
static bitcount_t smax(bitcount_t a, bitcount_t b) {
return (a > b ? a : b);
}
| 0
|
291,789
|
static int rtrs_clt_failover_req(struct rtrs_clt_sess *clt,
struct rtrs_clt_io_req *fail_req)
{
struct rtrs_clt_path *alive_path;
struct rtrs_clt_io_req *req;
int err = -ECONNABORTED;
struct path_it it;
rcu_read_lock();
for (path_it_init(&it, clt);
(alive_path = it.next_path(&it)) && it.i < it.clt->paths_num;
it.i++) {
if (READ_ONCE(alive_path->state) != RTRS_CLT_CONNECTED)
continue;
req = rtrs_clt_get_copy_req(alive_path, fail_req);
if (req->dir == DMA_TO_DEVICE)
err = rtrs_clt_write_req(req);
else
err = rtrs_clt_read_req(req);
if (err) {
req->in_use = false;
continue;
}
/* Success path */
rtrs_clt_inc_failover_cnt(alive_path->stats);
break;
}
path_it_deinit(&it);
rcu_read_unlock();
return err;
}
| 0
|
309,817
|
initialize_mousetype(SCREEN *sp)
{
T((T_CALLED("initialize_mousetype()")));
/* Try gpm first, because gpm may be configured to run in xterm */
#if USE_GPM_SUPPORT
if (allow_gpm_mouse(sp)) {
if (!sp->_mouse_gpm_loaded) {
#ifdef HAVE_LIBDL
load_gpm_library(sp);
#else /* !HAVE_LIBDL */
sp->_mouse_gpm_found = TRUE;
sp->_mouse_gpm_loaded = TRUE;
#endif
}
/*
* The gpm_fd file-descriptor may be negative (xterm). So we have to
* maintain our notion of whether the mouse connection is active
* without testing the file-descriptor.
*/
if (sp->_mouse_gpm_found && enable_gpm_mouse(sp, TRUE)) {
sp->_mouse_type = M_GPM;
sp->_mouse_fd = *(my_gpm_fd);
T(("GPM mouse_fd %d", sp->_mouse_fd));
returnVoid;
}
}
#endif /* USE_GPM_SUPPORT */
/* OS/2 VIO */
#if USE_EMX_MOUSE
if (!sp->_emxmouse_thread
&& strstr(SP_TERMTYPE term_names, "xterm") == 0
&& NonEmpty(key_mouse)) {
int handles[2];
if (pipe(handles) < 0) {
perror("mouse pipe error");
returnVoid;
} else {
int rc;
if (!sp->_emxmouse_buttons[0]) {
const char *s = getenv("MOUSE_BUTTONS_123");
sp->_emxmouse_buttons[0] = 1;
if (s && strlen(s) >= 3) {
sp->_emxmouse_buttons[1] = s[0] - '0';
sp->_emxmouse_buttons[2] = s[1] - '0';
sp->_emxmouse_buttons[3] = s[2] - '0';
} else {
sp->_emxmouse_buttons[1] = 1;
sp->_emxmouse_buttons[2] = 3;
sp->_emxmouse_buttons[3] = 2;
}
}
sp->_emxmouse_wfd = handles[1];
M_FD(sp) = handles[0];
/* Needed? */
setmode(handles[0], O_BINARY);
setmode(handles[1], O_BINARY);
/* Do not use CRT functions, we may single-threaded. */
rc = DosCreateThread((unsigned long *) &sp->_emxmouse_thread,
mouse_server, (long) sp, 0, 8192);
if (rc) {
printf("mouse thread error %d=%#x", rc, rc);
} else {
sp->_mouse_type = M_XTERM;
}
returnVoid;
}
}
#endif /* USE_EMX_MOUSE */
#if USE_SYSMOUSE
{
static char dev_tty[] = "/dev/tty";
struct mouse_info the_mouse;
char *the_device = 0;
if (NC_ISATTY(sp->_ifd))
the_device = ttyname(sp->_ifd);
if (the_device == 0)
the_device = dev_tty;
sp->_mouse_fd = open(the_device, O_RDWR);
if (sp->_mouse_fd >= 0) {
/*
* sysmouse does not have a usable user interface for obtaining
* mouse events. The logical way to proceed (reading data on a
* stream) only works if one opens the device as root. Even in
* that mode, careful examination shows we lose events
* occasionally. The interface provided for user programs is to
* establish a signal handler. really.
*
* Take over SIGUSR2 for this purpose since SIGUSR1 is more
* likely to be used by an application. getch() will have to
* handle the misleading EINTR's.
*/
signal(SIGUSR2, SIG_IGN);
the_mouse.operation = MOUSE_MODE;
the_mouse.u.mode.mode = 0;
the_mouse.u.mode.signal = SIGUSR2;
if (ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse) != -1) {
signal(SIGUSR2, handle_sysmouse);
the_mouse.operation = MOUSE_SHOW;
ioctl(sp->_mouse_fd, CONS_MOUSECTL, &the_mouse);
#if defined(FBIO_MODEINFO) || defined(CONS_MODEINFO) /* FreeBSD > 2.x */
{
#ifndef FBIO_GETMODE /* FreeBSD 3.x */
#define FBIO_GETMODE CONS_GET
#define FBIO_MODEINFO CONS_MODEINFO
#endif /* FBIO_GETMODE */
video_info_t the_video;
if (ioctl(sp->_mouse_fd,
FBIO_GETMODE,
&the_video.vi_mode) != -1
&& ioctl(sp->_mouse_fd,
FBIO_MODEINFO,
&the_video) != -1) {
sp->_sysmouse_char_width = the_video.vi_cwidth;
sp->_sysmouse_char_height = the_video.vi_cheight;
}
}
#endif /* defined(FBIO_MODEINFO) || defined(CONS_MODEINFO) */
if (sp->_sysmouse_char_width <= 0)
sp->_sysmouse_char_width = 8;
if (sp->_sysmouse_char_height <= 0)
sp->_sysmouse_char_height = 16;
sp->_mouse_type = M_SYSMOUSE;
returnVoid;
}
}
}
#endif /* USE_SYSMOUSE */
#ifdef USE_TERM_DRIVER
CallDriver(sp, td_initmouse);
#else
/* we know how to recognize mouse events under "xterm" */
if (NonEmpty(key_mouse)) {
init_xterm_mouse(sp);
} else if (strstr(SP_TERMTYPE term_names, "xterm") != 0) {
if (_nc_add_to_try(&(sp->_keytry), xterm_kmous, KEY_MOUSE) == OK)
init_xterm_mouse(sp);
}
#endif
returnVoid;
}
| 0
|
512,343
|
Item *Item_func_ge::negated_item(THD *thd) /* a >= b -> a < b */
{
return new (thd->mem_root) Item_func_lt(thd, args[0], args[1]);
}
| 0
|
436,114
|
static int io_send(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_sr_msg *sr = &req->sr_msg;
struct msghdr msg;
struct iovec iov;
struct socket *sock;
unsigned flags;
int min_ret = 0;
int ret;
sock = sock_from_file(req->file);
if (unlikely(!sock))
return -ENOTSOCK;
ret = import_single_range(WRITE, sr->buf, sr->len, &iov, &msg.msg_iter);
if (unlikely(ret))
return ret;
msg.msg_name = NULL;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_namelen = 0;
flags = req->sr_msg.msg_flags;
if (issue_flags & IO_URING_F_NONBLOCK)
flags |= MSG_DONTWAIT;
if (flags & MSG_WAITALL)
min_ret = iov_iter_count(&msg.msg_iter);
msg.msg_flags = flags;
ret = sock_sendmsg(sock, &msg);
if ((issue_flags & IO_URING_F_NONBLOCK) && ret == -EAGAIN)
return -EAGAIN;
if (ret == -ERESTARTSYS)
ret = -EINTR;
if (ret < min_ret)
req_set_fail(req);
__io_req_complete(req, issue_flags, ret, 0);
return 0;
}
| 0
|
390,537
|
XkbWriteKeyTypes( XkbDescPtr xkb,
xkbGetMapReply * rep,
char * buf,
ClientPtr client)
{
XkbKeyTypePtr type;
unsigned i;
xkbKeyTypeWireDesc *wire;
type= &xkb->map->types[rep->firstType];
for (i=0;i<rep->nTypes;i++,type++) {
register unsigned n;
wire= (xkbKeyTypeWireDesc *)buf;
wire->mask = type->mods.mask;
wire->realMods = type->mods.real_mods;
wire->virtualMods = type->mods.vmods;
wire->numLevels = type->num_levels;
wire->nMapEntries = type->map_count;
wire->preserve = (type->preserve!=NULL);
if (client->swapped) {
register int n;
swaps(&wire->virtualMods,n);
}
buf= (char *)&wire[1];
if (wire->nMapEntries>0) {
xkbKTMapEntryWireDesc * wire;
XkbKTMapEntryPtr entry;
wire= (xkbKTMapEntryWireDesc *)buf;
entry= type->map;
for (n=0;n<type->map_count;n++,wire++,entry++) {
wire->active= entry->active;
wire->mask= entry->mods.mask;
wire->level= entry->level;
wire->realMods= entry->mods.real_mods;
wire->virtualMods= entry->mods.vmods;
if (client->swapped) {
register int n;
swaps(&wire->virtualMods,n);
}
}
buf= (char *)wire;
if (type->preserve!=NULL) {
xkbModsWireDesc * pwire;
XkbModsPtr preserve;
pwire= (xkbModsWireDesc *)buf;
preserve= type->preserve;
for (n=0;n<type->map_count;n++,pwire++,preserve++) {
pwire->mask= preserve->mask;
pwire->realMods= preserve->real_mods;
pwire->virtualMods= preserve->vmods;
if (client->swapped) {
register int n;
swaps(&pwire->virtualMods,n);
}
}
buf= (char *)pwire;
}
}
}
return buf;
}
| 0
|
488,334
|
static int __init vdso_do_func_patch64(struct lib32_elfinfo *v32,
struct lib64_elfinfo *v64,
const char *orig, const char *fix)
{
Elf64_Sym *sym64_gen, *sym64_fix;
sym64_gen = find_symbol64(v64, orig);
if (sym64_gen == NULL) {
printk(KERN_ERR "vDSO64: Can't find symbol %s !\n", orig);
return -1;
}
if (fix == NULL) {
sym64_gen->st_name = 0;
return 0;
}
sym64_fix = find_symbol64(v64, fix);
if (sym64_fix == NULL) {
printk(KERN_ERR "vDSO64: Can't find symbol %s !\n", fix);
return -1;
}
sym64_gen->st_value = sym64_fix->st_value;
sym64_gen->st_size = sym64_fix->st_size;
sym64_gen->st_info = sym64_fix->st_info;
sym64_gen->st_other = sym64_fix->st_other;
sym64_gen->st_shndx = sym64_fix->st_shndx;
return 0;
}
| 0
|
455,319
|
split_ignorespec (s, ip)
char *s;
int *ip;
{
char *t;
int n, i;
if (s == 0)
return 0;
i = *ip;
if (s[i] == 0)
return 0;
n = skip_to_delim (s, i, ":", SD_NOJMP|SD_EXTGLOB|SD_GLOB);
t = substring (s, i, n);
if (s[n] == ':')
n++;
*ip = n;
return t;
}
| 0
|
338,207
|
bool WasmBinaryBuilder::getBasicType(int32_t code, Type& out) {
switch (code) {
case BinaryConsts::EncodedType::i32:
out = Type::i32;
return true;
case BinaryConsts::EncodedType::i64:
out = Type::i64;
return true;
case BinaryConsts::EncodedType::f32:
out = Type::f32;
return true;
case BinaryConsts::EncodedType::f64:
out = Type::f64;
return true;
case BinaryConsts::EncodedType::v128:
out = Type::v128;
return true;
case BinaryConsts::EncodedType::funcref:
out = Type::funcref;
return true;
case BinaryConsts::EncodedType::externref:
out = Type::externref;
return true;
case BinaryConsts::EncodedType::anyref:
out = Type::anyref;
return true;
case BinaryConsts::EncodedType::eqref:
out = Type::eqref;
return true;
case BinaryConsts::EncodedType::i31ref:
out = Type(HeapType::i31, NonNullable);
return true;
case BinaryConsts::EncodedType::dataref:
out = Type(HeapType::data, NonNullable);
return true;
default:
return false;
}
}
| 0
|
356,691
|
template <class T> void Statement::Error(T* baton) {
Statement* stmt = baton->stmt;
Napi::Env env = stmt->Env();
Napi::HandleScope scope(env);
// Fail hard on logic errors.
assert(stmt->status != 0);
EXCEPTION(Napi::String::New(env, stmt->message.c_str()), stmt->status, exception);
Napi::Function cb = baton->callback.Value();
if (!cb.IsUndefined() && cb.IsFunction()) {
Napi::Value argv[] = { exception };
TRY_CATCH_CALL(stmt->Value(), cb, 1, argv);
}
else {
Napi::Value argv[] = { Napi::String::New(env, "error"), exception };
EMIT_EVENT(stmt->Value(), 2, argv);
}
}
| 0
|
512,897
|
const Type_handler *real_type_handler() const
{
if (field->is_created_from_null_item)
return &type_handler_null;
return field->type_handler();
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.