unique_id
int64 13
189k
| target
int64 0
1
| code
stringlengths 20
241k
| __index_level_0__
int64 0
18.9k
|
---|---|---|---|
184,489 | 1 | void PPB_URLLoader_Impl::RunCallback(int32_t result) {
if (!pending_callback_.get()) {
CHECK(main_document_loader_);
return;
}
TrackedCallback::ClearAndRun(&pending_callback_, result);
}
| 4,800 |
98,919 | 0 | bool hasImpliedEndTag(Element* element)
{
return element->hasTagName(ddTag)
|| element->hasTagName(dtTag)
|| element->hasTagName(liTag)
|| element->hasTagName(optionTag)
|| element->hasTagName(optgroupTag)
|| element->hasTagName(pTag)
|| element->hasTagName(rpTag)
|| element->hasTagName(rtTag);
}
| 4,801 |
115,057 | 0 | void TestingAutomationProvider::WaitForBrowserWindowCountToBecome(
int target_count,
IPC::Message* reply_message) {
if (static_cast<int>(BrowserList::size()) == target_count) {
AutomationMsg_WaitForBrowserWindowCountToBecome::WriteReplyParams(
reply_message, true);
Send(reply_message);
return;
}
new BrowserCountChangeNotificationObserver(target_count, this, reply_message);
}
| 4,802 |
151,828 | 0 | TestBackgroundLoaderOffliner::TestBackgroundLoaderOffliner(
content::BrowserContext* browser_context,
const OfflinerPolicy* policy,
OfflinePageModel* offline_page_model,
std::unique_ptr<LoadTerminationListener> load_termination_listener)
: BackgroundLoaderOffliner(browser_context,
policy,
offline_page_model,
std::move(load_termination_listener)) {}
| 4,803 |
22,010 | 0 | raptor_rdfxml_end_element_handler(void *user_data,
raptor_xml_element* xml_element)
{
raptor_parser* rdf_parser;
raptor_rdfxml_parser* rdf_xml_parser;
raptor_rdfxml_element* element;
rdf_parser = (raptor_parser*)user_data;
rdf_xml_parser = (raptor_rdfxml_parser*)rdf_parser->context;
if(!rdf_parser->failed) {
raptor_rdfxml_update_document_locator(rdf_parser);
raptor_rdfxml_end_element_grammar(rdf_parser,
rdf_xml_parser->current_element);
}
element = raptor_rdfxml_element_pop(rdf_xml_parser);
if(element) {
if(element->parent) {
/* Do not change this; PROPERTYELT will turn into MEMBER if necessary
* See the switch case for MEMBER / PROPERTYELT where the test is done.
*
* PARSETYPE_RESOURCE should never be propogated up since it
* will turn the next child (node) element into a property
*/
if(element->state != RAPTOR_STATE_MEMBER_PROPERTYELT &&
element->state != RAPTOR_STATE_PARSETYPE_RESOURCE)
element->parent->child_state = element->state;
}
raptor_free_rdfxml_element(element);
}
}
| 4,804 |
117,986 | 0 | int V8Proxy::contextDebugId(v8::Handle<v8::Context> context)
{
v8::HandleScope scope;
if (!context->GetData()->IsString())
return -1;
v8::String::AsciiValue ascii(context->GetData());
char* comma = strnstr(*ascii, ",", ascii.length());
if (!comma)
return -1;
return atoi(comma + 1);
}
| 4,805 |
159,121 | 0 | const std::string& DownloadItemImpl::GetETag() const {
return etag_;
}
| 4,806 |
42,909 | 0 | static void sctp_free_local_addr_list(struct net *net)
{
struct sctp_sockaddr_entry *addr;
struct list_head *pos, *temp;
list_for_each_safe(pos, temp, &net->sctp.local_addr_list) {
addr = list_entry(pos, struct sctp_sockaddr_entry, list);
list_del(pos);
kfree(addr);
}
}
| 4,807 |
100,714 | 0 | xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
const xmlChar *ID, xmlNodePtr *lst) {
xmlParserCtxtPtr ctxt;
xmlDocPtr newDoc;
xmlNodePtr newRoot;
xmlSAXHandlerPtr oldsax = NULL;
int ret = 0;
xmlChar start[4];
xmlCharEncoding enc;
if (ctx == NULL) return(-1);
if (((ctx->depth > 40) && ((ctx->options & XML_PARSE_HUGE) == 0)) ||
(ctx->depth > 1024)) {
return(XML_ERR_ENTITY_LOOP);
}
if (lst != NULL)
*lst = NULL;
if ((URL == NULL) && (ID == NULL))
return(-1);
if (ctx->myDoc == NULL) /* @@ relax but check for dereferences */
return(-1);
ctxt = xmlCreateEntityParserCtxtInternal(URL, ID, NULL, ctx);
if (ctxt == NULL) {
return(-1);
}
oldsax = ctxt->sax;
ctxt->sax = ctx->sax;
xmlDetectSAX2(ctxt);
newDoc = xmlNewDoc(BAD_CAST "1.0");
if (newDoc == NULL) {
xmlFreeParserCtxt(ctxt);
return(-1);
}
newDoc->properties = XML_DOC_INTERNAL;
if (ctx->myDoc->dict) {
newDoc->dict = ctx->myDoc->dict;
xmlDictReference(newDoc->dict);
}
if (ctx->myDoc != NULL) {
newDoc->intSubset = ctx->myDoc->intSubset;
newDoc->extSubset = ctx->myDoc->extSubset;
}
if (ctx->myDoc->URL != NULL) {
newDoc->URL = xmlStrdup(ctx->myDoc->URL);
}
newRoot = xmlNewDocNode(newDoc, NULL, BAD_CAST "pseudoroot", NULL);
if (newRoot == NULL) {
ctxt->sax = oldsax;
xmlFreeParserCtxt(ctxt);
newDoc->intSubset = NULL;
newDoc->extSubset = NULL;
xmlFreeDoc(newDoc);
return(-1);
}
xmlAddChild((xmlNodePtr) newDoc, newRoot);
nodePush(ctxt, newDoc->children);
if (ctx->myDoc == NULL) {
ctxt->myDoc = newDoc;
} else {
ctxt->myDoc = ctx->myDoc;
newDoc->children->doc = ctx->myDoc;
}
/*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
*/
GROW
if ((ctxt->input->end - ctxt->input->cur) >= 4) {
start[0] = RAW;
start[1] = NXT(1);
start[2] = NXT(2);
start[3] = NXT(3);
enc = xmlDetectCharEncoding(start, 4);
if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
}
}
/*
* Parse a possible text declaration first
*/
if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
xmlParseTextDecl(ctxt);
/*
* An XML-1.0 document can't reference an entity not XML-1.0
*/
if ((xmlStrEqual(ctx->version, BAD_CAST "1.0")) &&
(!xmlStrEqual(ctxt->input->version, BAD_CAST "1.0"))) {
xmlFatalErrMsg(ctxt, XML_ERR_VERSION_MISMATCH,
"Version mismatch between document and entity\n");
}
}
/*
* Doing validity checking on chunk doesn't make sense
*/
ctxt->instate = XML_PARSER_CONTENT;
ctxt->validate = ctx->validate;
ctxt->valid = ctx->valid;
ctxt->loadsubset = ctx->loadsubset;
ctxt->depth = ctx->depth + 1;
ctxt->replaceEntities = ctx->replaceEntities;
if (ctxt->validate) {
ctxt->vctxt.error = ctx->vctxt.error;
ctxt->vctxt.warning = ctx->vctxt.warning;
} else {
ctxt->vctxt.error = NULL;
ctxt->vctxt.warning = NULL;
}
ctxt->vctxt.nodeTab = NULL;
ctxt->vctxt.nodeNr = 0;
ctxt->vctxt.nodeMax = 0;
ctxt->vctxt.node = NULL;
if (ctxt->dict != NULL) xmlDictFree(ctxt->dict);
ctxt->dict = ctx->dict;
ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3);
ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
ctxt->dictNames = ctx->dictNames;
ctxt->attsDefault = ctx->attsDefault;
ctxt->attsSpecial = ctx->attsSpecial;
ctxt->linenumbers = ctx->linenumbers;
xmlParseContent(ctxt);
ctx->validate = ctxt->validate;
ctx->valid = ctxt->valid;
if ((RAW == '<') && (NXT(1) == '/')) {
xmlFatalErr(ctxt, XML_ERR_NOT_WELL_BALANCED, NULL);
} else if (RAW != 0) {
xmlFatalErr(ctxt, XML_ERR_EXTRA_CONTENT, NULL);
}
if (ctxt->node != newDoc->children) {
xmlFatalErr(ctxt, XML_ERR_NOT_WELL_BALANCED, NULL);
}
if (!ctxt->wellFormed) {
if (ctxt->errNo == 0)
ret = 1;
else
ret = ctxt->errNo;
} else {
if (lst != NULL) {
xmlNodePtr cur;
/*
* Return the newly created nodeset after unlinking it from
* they pseudo parent.
*/
cur = newDoc->children->children;
*lst = cur;
while (cur != NULL) {
cur->parent = NULL;
cur = cur->next;
}
newDoc->children->children = NULL;
}
ret = 0;
}
ctxt->sax = oldsax;
ctxt->dict = NULL;
ctxt->attsDefault = NULL;
ctxt->attsSpecial = NULL;
xmlFreeParserCtxt(ctxt);
newDoc->intSubset = NULL;
newDoc->extSubset = NULL;
xmlFreeDoc(newDoc);
return(ret);
}
| 4,808 |
29,942 | 0 | void __init udp_init(void)
{
unsigned long limit;
udp_table_init(&udp_table, "UDP");
limit = nr_free_buffer_pages() / 8;
limit = max(limit, 128UL);
sysctl_udp_mem[0] = limit / 4 * 3;
sysctl_udp_mem[1] = limit;
sysctl_udp_mem[2] = sysctl_udp_mem[0] * 2;
sysctl_udp_rmem_min = SK_MEM_QUANTUM;
sysctl_udp_wmem_min = SK_MEM_QUANTUM;
}
| 4,809 |
32,260 | 0 | static void dx_sort_map (struct dx_map_entry *map, unsigned count)
{
struct dx_map_entry *p, *q, *top = map + count - 1;
int more;
/* Combsort until bubble sort doesn't suck */
while (count > 2) {
count = count*10/13;
if (count - 9 < 2) /* 9, 10 -> 11 */
count = 11;
for (p = top, q = p - count; q >= map; p--, q--)
if (p->hash < q->hash)
swap(*p, *q);
}
/* Garden variety bubble sort */
do {
more = 0;
q = top;
while (q-- > map) {
if (q[1].hash >= q[0].hash)
continue;
swap(*(q+1), *q);
more = 1;
}
} while(more);
}
| 4,810 |
186,849 | 1 | void MojoJpegDecodeAccelerator::Decode(
const BitstreamBuffer& bitstream_buffer,
const scoped_refptr<VideoFrame>& video_frame) {
DCHECK(io_task_runner_->BelongsToCurrentThread());
DCHECK(jpeg_decoder_.is_bound());
DCHECK(
base::SharedMemory::IsHandleValid(video_frame->shared_memory_handle()));
base::SharedMemoryHandle output_handle =
base::SharedMemory::DuplicateHandle(video_frame->shared_memory_handle());
if (!base::SharedMemory::IsHandleValid(output_handle)) {
DLOG(ERROR) << "Failed to duplicate handle of VideoFrame";
return;
}
size_t output_buffer_size = VideoFrame::AllocationSize(
video_frame->format(), video_frame->coded_size());
mojo::ScopedSharedBufferHandle output_frame_handle =
mojo::WrapSharedMemoryHandle(output_handle, output_buffer_size,
false /* read_only */);
// base::Unretained is safe because |this| owns |jpeg_decoder_|.
jpeg_decoder_->Decode(bitstream_buffer, video_frame->coded_size(),
std::move(output_frame_handle),
base::checked_cast<uint32_t>(output_buffer_size),
base::Bind(&MojoJpegDecodeAccelerator::OnDecodeAck,
base::Unretained(this)));
}
| 4,811 |
87,618 | 0 | static unsigned writeSignature(ucvector* out)
{
/*8 bytes PNG signature, aka the magic bytes*/
if (!ucvector_push_back(out, 137)) return 83;
if (!ucvector_push_back(out, 80)) return 83;
if (!ucvector_push_back(out, 78)) return 83;
if (!ucvector_push_back(out, 71)) return 83;
if (!ucvector_push_back(out, 13)) return 83;
if (!ucvector_push_back(out, 10)) return 83;
if (!ucvector_push_back(out, 26)) return 83;
if (!ucvector_push_back(out, 10)) return 83;
return 0;
}
| 4,812 |
106,466 | 0 | void WebPageProxy::didChangeBackForwardList(WebBackForwardListItem* added, Vector<RefPtr<APIObject> >* removed)
{
m_loaderClient.didChangeBackForwardList(this, added, removed);
}
| 4,813 |
15,251 | 0 | PHP_FUNCTION(stream_socket_client)
{
char *host;
int host_len;
zval *zerrno = NULL, *zerrstr = NULL, *zcontext = NULL;
double timeout = FG(default_socket_timeout);
php_timeout_ull conv;
struct timeval tv;
char *hashkey = NULL;
php_stream *stream = NULL;
int err;
long flags = PHP_STREAM_CLIENT_CONNECT;
char *errstr = NULL;
php_stream_context *context = NULL;
RETVAL_FALSE;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|zzdlr", &host, &host_len, &zerrno, &zerrstr, &timeout, &flags, &zcontext) == FAILURE) {
RETURN_FALSE;
}
context = php_stream_context_from_zval(zcontext, flags & PHP_FILE_NO_DEFAULT_CONTEXT);
if (flags & PHP_STREAM_CLIENT_PERSISTENT) {
spprintf(&hashkey, 0, "stream_socket_client__%s", host);
}
/* prepare the timeout value for use */
conv = (php_timeout_ull) (timeout * 1000000.0);
#ifdef PHP_WIN32
tv.tv_sec = (long)(conv / 1000000);
tv.tv_usec =(long)(conv % 1000000);
#else
tv.tv_sec = conv / 1000000;
tv.tv_usec = conv % 1000000;
#endif
if (zerrno) {
zval_dtor(zerrno);
ZVAL_LONG(zerrno, 0);
}
if (zerrstr) {
zval_dtor(zerrstr);
ZVAL_STRING(zerrstr, "", 1);
}
stream = php_stream_xport_create(host, host_len, REPORT_ERRORS,
STREAM_XPORT_CLIENT | (flags & PHP_STREAM_CLIENT_CONNECT ? STREAM_XPORT_CONNECT : 0) |
(flags & PHP_STREAM_CLIENT_ASYNC_CONNECT ? STREAM_XPORT_CONNECT_ASYNC : 0),
hashkey, &tv, context, &errstr, &err);
if (stream == NULL) {
/* host might contain binary characters */
char *quoted_host = php_addslashes(host, host_len, NULL, 0 TSRMLS_CC);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to connect to %s (%s)", quoted_host, errstr == NULL ? "Unknown error" : errstr);
efree(quoted_host);
}
if (hashkey) {
efree(hashkey);
}
if (stream == NULL) {
if (zerrno) {
zval_dtor(zerrno);
ZVAL_LONG(zerrno, err);
}
if (zerrstr && errstr) {
/* no need to dup; we need to efree buf anyway */
zval_dtor(zerrstr);
ZVAL_STRING(zerrstr, errstr, 0);
} else if (errstr) {
efree(errstr);
}
RETURN_FALSE;
}
if (errstr) {
efree(errstr);
}
php_stream_to_zval(stream, return_value);
}
| 4,814 |
115,722 | 0 | Encoder* ScreenRecorder::encoder() {
DCHECK_EQ(encode_loop_, MessageLoop::current());
DCHECK(encoder_.get());
return encoder_.get();
}
| 4,815 |
20,748 | 0 | int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
{
int r;
vcpu->arch.mtrr_state.have_fixed = 1;
vcpu_load(vcpu);
r = kvm_arch_vcpu_reset(vcpu);
if (r == 0)
r = kvm_mmu_setup(vcpu);
vcpu_put(vcpu);
return r;
}
| 4,816 |
11,345 | 0 | fbCombineConjointInReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
{
fbCombineConjointGeneralC (dest, src, mask, width, CombineBIn);
}
| 4,817 |
105,292 | 0 | void DOMPatchSupport::patchDocument(Document* document, const String& markup)
{
InspectorHistory history;
DOMEditor domEditor(&history);
DOMPatchSupport patchSupport(&domEditor, document);
patchSupport.patchDocument(markup);
}
| 4,818 |
66,140 | 0 | static void saa7164_bus_dumpmsg(struct saa7164_dev *dev, struct tmComResInfo *m,
void *buf)
{
dprintk(DBGLVL_BUS, "Dumping msg structure:\n");
dprintk(DBGLVL_BUS, " .id = %d\n", m->id);
dprintk(DBGLVL_BUS, " .flags = 0x%x\n", m->flags);
dprintk(DBGLVL_BUS, " .size = 0x%x\n", m->size);
dprintk(DBGLVL_BUS, " .command = 0x%x\n", m->command);
dprintk(DBGLVL_BUS, " .controlselector = 0x%x\n", m->controlselector);
dprintk(DBGLVL_BUS, " .seqno = %d\n", m->seqno);
if (buf)
dprintk(DBGLVL_BUS, " .buffer (ignored)\n");
}
| 4,819 |
28,665 | 0 | static int aac_get_pci_info(struct aac_dev* dev, void __user *arg)
{
struct aac_pci_info pci_info;
pci_info.bus = dev->pdev->bus->number;
pci_info.slot = PCI_SLOT(dev->pdev->devfn);
if (copy_to_user(arg, &pci_info, sizeof(struct aac_pci_info))) {
dprintk((KERN_DEBUG "aacraid: Could not copy pci info\n"));
return -EFAULT;
}
return 0;
}
| 4,820 |
46,674 | 0 | static int setkey_fallback_cip(struct crypto_tfm *tfm, const u8 *in_key,
unsigned int key_len)
{
struct s390_aes_ctx *sctx = crypto_tfm_ctx(tfm);
int ret;
sctx->fallback.cip->base.crt_flags &= ~CRYPTO_TFM_REQ_MASK;
sctx->fallback.cip->base.crt_flags |= (tfm->crt_flags &
CRYPTO_TFM_REQ_MASK);
ret = crypto_cipher_setkey(sctx->fallback.cip, in_key, key_len);
if (ret) {
tfm->crt_flags &= ~CRYPTO_TFM_RES_MASK;
tfm->crt_flags |= (sctx->fallback.cip->base.crt_flags &
CRYPTO_TFM_RES_MASK);
}
return ret;
}
| 4,821 |
146,216 | 0 | void WebGL2RenderingContextBase::uniformMatrix2fv(
const WebGLUniformLocation* location,
GLboolean transpose,
Vector<GLfloat>& v) {
WebGLRenderingContextBase::uniformMatrix2fv(location, transpose, v);
}
| 4,822 |
33,107 | 0 | static int copy_to_user_policy_type(u8 type, struct sk_buff *skb)
{
struct xfrm_userpolicy_type upt = {
.type = type,
};
return nla_put(skb, XFRMA_POLICY_TYPE, sizeof(upt), &upt);
}
| 4,823 |
181,555 | 1 | receive_carbon(void **state)
{
prof_input("/carbons on");
prof_connect();
assert_true(stbbr_received(
"<iq id='*' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>"
));
stbbr_send(
"<presence to='stabber@localhost' from='buddy1@localhost/mobile'>"
"<priority>10</priority>"
"<status>On my mobile</status>"
"</presence>"
);
assert_true(prof_output_exact("Buddy1 (mobile) is online, \"On my mobile\""));
prof_input("/msg Buddy1");
assert_true(prof_output_exact("unencrypted"));
stbbr_send(
"<message type='chat' to='stabber@localhost/profanity' from='buddy1@localhost'>"
"<received xmlns='urn:xmpp:carbons:2'>"
"<forwarded xmlns='urn:xmpp:forward:0'>"
"<message id='prof_msg_7' xmlns='jabber:client' type='chat' lang='en' to='stabber@localhost/profanity' from='buddy1@localhost/mobile'>"
"<body>test carbon from recipient</body>"
"</message>"
"</forwarded>"
"</received>"
"</message>"
);
assert_true(prof_output_regex("Buddy1/mobile: .+test carbon from recipient"));
}
| 4,824 |
103,015 | 0 | virtual TabContentsWrapper* AddBlankTabAt(int index, bool foreground) {
return NULL;
}
| 4,825 |
166,009 | 0 | void RTCPeerConnectionHandler::OnModifyTransceivers(
std::vector<RtpTransceiverState> transceiver_states,
bool is_remote_description) {
DCHECK_EQ(configuration_.sdp_semantics, webrtc::SdpSemantics::kUnifiedPlan);
std::vector<std::unique_ptr<blink::WebRTCRtpTransceiver>> web_transceivers(
transceiver_states.size());
PeerConnectionTracker::TransceiverUpdatedReason update_reason =
!is_remote_description ? PeerConnectionTracker::TransceiverUpdatedReason::
kSetLocalDescription
: PeerConnectionTracker::TransceiverUpdatedReason::
kSetRemoteDescription;
for (size_t i = 0; i < transceiver_states.size(); ++i) {
uintptr_t transceiver_id = RTCRtpTransceiver::GetId(
transceiver_states[i].webrtc_transceiver().get());
auto it = FindTransceiver(transceiver_id);
bool transceiver_is_new = (it == rtp_transceivers_.end());
bool transceiver_was_modified = false;
if (!transceiver_is_new) {
const auto& previous_state = (*it)->state();
transceiver_was_modified =
previous_state.mid() != transceiver_states[i].mid() ||
previous_state.stopped() != transceiver_states[i].stopped() ||
previous_state.direction() != transceiver_states[i].direction() ||
previous_state.current_direction() !=
transceiver_states[i].current_direction();
}
web_transceivers[i] =
CreateOrUpdateTransceiver(std::move(transceiver_states[i]));
if (peer_connection_tracker_ &&
(transceiver_is_new || transceiver_was_modified)) {
size_t transceiver_index = GetTransceiverIndex(*web_transceivers[i]);
if (transceiver_is_new) {
peer_connection_tracker_->TrackAddTransceiver(
this, update_reason, *web_transceivers[i].get(), transceiver_index);
} else if (transceiver_was_modified) {
peer_connection_tracker_->TrackModifyTransceiver(
this, update_reason, *web_transceivers[i].get(), transceiver_index);
}
}
}
if (!is_closed_) {
client_->DidModifyTransceivers(std::move(web_transceivers),
is_remote_description);
}
}
| 4,826 |
132,667 | 0 | WebURL BlinkTestRunner::RewriteLayoutTestsURL(const std::string& utf8_url) {
const char kPrefix[] = "file:///tmp/LayoutTests/";
const int kPrefixLen = arraysize(kPrefix) - 1;
if (utf8_url.compare(0, kPrefixLen, kPrefix, kPrefixLen))
return WebURL(GURL(utf8_url));
base::FilePath replace_path =
LayoutTestRenderProcessObserver::GetInstance()->webkit_source_dir()
.Append(FILE_PATH_LITERAL("LayoutTests/"));
#if defined(OS_WIN)
std::string utf8_path = base::WideToUTF8(replace_path.value());
#else
std::string utf8_path =
base::WideToUTF8(base::SysNativeMBToWide(replace_path.value()));
#endif
std::string new_url =
std::string("file://") + utf8_path + utf8_url.substr(kPrefixLen);
return WebURL(GURL(new_url));
}
| 4,827 |
174,022 | 0 | Chapters::Atom::~Atom() {}
| 4,828 |
56,344 | 0 | gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees,
const int bgColor)
{
float _angle = ((float) (-degrees / 180.0f) * (float)M_PI);
const int src_w = gdImageSX(src);
const int src_h = gdImageSY(src);
const unsigned int new_width = (unsigned int)(abs((int)(src_w * cos(_angle))) + abs((int)(src_h * sin(_angle))) + 0.5f);
const unsigned int new_height = (unsigned int)(abs((int)(src_w * sin(_angle))) + abs((int)(src_h * cos(_angle))) + 0.5f);
const gdFixed f_0_5 = gd_ftofx(0.5f);
const gdFixed f_H = gd_itofx(src_h/2);
const gdFixed f_W = gd_itofx(src_w/2);
const gdFixed f_cos = gd_ftofx(cos(-_angle));
const gdFixed f_sin = gd_ftofx(sin(-_angle));
unsigned int dst_offset_x;
unsigned int dst_offset_y = 0;
unsigned int i;
gdImagePtr dst;
/* impact perf a bit, but not that much. Implementation for palette
images can be done at a later point.
*/
if (src->trueColor == 0) {
gdImagePaletteToTrueColor(src);
}
dst = gdImageCreateTrueColor(new_width, new_height);
if (!dst) {
return NULL;
}
dst->saveAlphaFlag = 1;
for (i = 0; i < new_height; i++) {
unsigned int j;
dst_offset_x = 0;
for (j = 0; j < new_width; j++) {
gdFixed f_i = gd_itofx((int)i - (int)new_height / 2);
gdFixed f_j = gd_itofx((int)j - (int)new_width / 2);
gdFixed f_m = gd_mulfx(f_j,f_sin) + gd_mulfx(f_i,f_cos) + f_0_5 + f_H;
gdFixed f_n = gd_mulfx(f_j,f_cos) - gd_mulfx(f_i,f_sin) + f_0_5 + f_W;
long m = gd_fxtoi(f_m);
long n = gd_fxtoi(f_n);
if ((m > 0) && (m < src_h-1) && (n > 0) && (n < src_w-1)) {
if (dst_offset_y < new_height) {
dst->tpixels[dst_offset_y][dst_offset_x++] = src->tpixels[m][n];
}
} else {
if (dst_offset_y < new_height) {
dst->tpixels[dst_offset_y][dst_offset_x++] = bgColor;
}
}
}
dst_offset_y++;
}
return dst;
}
| 4,829 |
163,351 | 0 | bool RenderThreadImpl::IsAsyncWorkerContextEnabled() {
return is_async_worker_context_enabled_;
}
| 4,830 |
178,827 | 1 | int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
void *data, struct drm_file *file_priv)
{
struct drm_clip_rect __user *clips_ptr;
struct drm_clip_rect *clips = NULL;
struct drm_mode_fb_dirty_cmd *r = data;
struct drm_mode_object *obj;
struct drm_framebuffer *fb;
unsigned flags;
int num_clips;
int ret = 0;
if (!drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL;
mutex_lock(&dev->mode_config.mutex);
obj = drm_mode_object_find(dev, r->fb_id, DRM_MODE_OBJECT_FB);
if (!obj) {
DRM_ERROR("invalid framebuffer id\n");
ret = -EINVAL;
goto out_err1;
}
fb = obj_to_fb(obj);
num_clips = r->num_clips;
clips_ptr = (struct drm_clip_rect *)(unsigned long)r->clips_ptr;
if (!num_clips != !clips_ptr) {
ret = -EINVAL;
goto out_err1;
}
flags = DRM_MODE_FB_DIRTY_FLAGS & r->flags;
/* If userspace annotates copy, clips must come in pairs */
if (flags & DRM_MODE_FB_DIRTY_ANNOTATE_COPY && (num_clips % 2)) {
ret = -EINVAL;
goto out_err1;
}
if (num_clips && clips_ptr) {
clips = kzalloc(num_clips * sizeof(*clips), GFP_KERNEL);
if (!clips) {
ret = -ENOMEM;
goto out_err1;
}
ret = copy_from_user(clips, clips_ptr,
num_clips * sizeof(*clips));
if (ret) {
ret = -EFAULT;
goto out_err2;
}
}
if (fb->funcs->dirty) {
ret = fb->funcs->dirty(fb, file_priv, flags, r->color,
clips, num_clips);
} else {
ret = -ENOSYS;
goto out_err2;
}
out_err2:
kfree(clips);
out_err1:
mutex_unlock(&dev->mode_config.mutex);
return ret;
}
| 4,831 |
60,970 | 0 | nautilus_directory_is_anyone_monitoring_file_list (NautilusDirectory *directory)
{
if (directory->details->call_when_ready_counters[REQUEST_FILE_LIST] > 0)
{
return TRUE;
}
if (directory->details->monitor_counters[REQUEST_FILE_LIST] > 0)
{
return TRUE;
}
return FALSE;
}
| 4,832 |
139,651 | 0 | void AudioContext::derefFinishedSourceNodes()
{
ASSERT(isGraphOwner());
ASSERT(isAudioThread());
for (unsigned i = 0; i < m_finishedNodes.size(); i++)
derefNode(m_finishedNodes[i]);
m_finishedNodes.clear();
}
| 4,833 |
77,515 | 0 | ofputil_decode_nxst_flow_request(struct ofputil_flow_stats_request *fsr,
struct ofpbuf *b, bool aggregate,
const struct tun_table *tun_table,
const struct vl_mff_map *vl_mff_map)
{
const struct nx_flow_stats_request *nfsr;
enum ofperr error;
nfsr = ofpbuf_pull(b, sizeof *nfsr);
error = nx_pull_match(b, ntohs(nfsr->match_len), &fsr->match,
&fsr->cookie, &fsr->cookie_mask, tun_table,
vl_mff_map);
if (error) {
return error;
}
if (b->size) {
return OFPERR_OFPBRC_BAD_LEN;
}
fsr->aggregate = aggregate;
fsr->out_port = u16_to_ofp(ntohs(nfsr->out_port));
fsr->out_group = OFPG_ANY;
fsr->table_id = nfsr->table_id;
return 0;
}
| 4,834 |
24,572 | 0 | static inline int request_slot(struct b43_dmaring *ring)
{
int slot;
B43_WARN_ON(!ring->tx);
B43_WARN_ON(ring->stopped);
B43_WARN_ON(free_slots(ring) == 0);
slot = next_slot(ring, ring->current_slot);
ring->current_slot = slot;
ring->used_slots++;
update_max_used_slots(ring, ring->used_slots);
return slot;
}
| 4,835 |
180,438 | 1 | void cJSON_AddItemReferenceToObject( cJSON *object, const char *string, cJSON *item )
{
cJSON_AddItemToObject( object, string, create_reference( item ) );
}
| 4,836 |
64,240 | 0 | static int do_nothing(request_rec *r) { return OK; }
| 4,837 |
87,680 | 0 | struct hsr_node *hsr_get_node(struct hsr_port *port, struct sk_buff *skb,
bool is_sup)
{
struct list_head *node_db = &port->hsr->node_db;
struct hsr_node *node;
struct ethhdr *ethhdr;
u16 seq_out;
if (!skb_mac_header_was_set(skb))
return NULL;
ethhdr = (struct ethhdr *) skb_mac_header(skb);
list_for_each_entry_rcu(node, node_db, mac_list) {
if (ether_addr_equal(node->MacAddressA, ethhdr->h_source))
return node;
if (ether_addr_equal(node->MacAddressB, ethhdr->h_source))
return node;
}
/* Everyone may create a node entry, connected node to a HSR device. */
if (ethhdr->h_proto == htons(ETH_P_PRP)
|| ethhdr->h_proto == htons(ETH_P_HSR)) {
/* Use the existing sequence_nr from the tag as starting point
* for filtering duplicate frames.
*/
seq_out = hsr_get_skb_sequence_nr(skb) - 1;
} else {
/* this is called also for frames from master port and
* so warn only for non master ports
*/
if (port->type != HSR_PT_MASTER)
WARN_ONCE(1, "%s: Non-HSR frame\n", __func__);
seq_out = HSR_SEQNR_START;
}
return hsr_add_node(node_db, ethhdr->h_source, seq_out);
}
| 4,838 |
16,182 | 0 | GahpClient::getErrorString()
{
static std::string output;
output = "";
unsigned int i = 0;
unsigned int input_len = error_string.length();
for (i=0; i < input_len; i++) {
switch (error_string[i]) {
case '\n':
output += "\\n";
break;
case '\r':
output += "\\r";
break;
default:
output += error_string[i];
break;
}
}
return output.c_str();
}
| 4,839 |
69,011 | 0 | int FLTIsTemporalFilterType(const char *pszValue)
{
if (pszValue) {
if ( strcasecmp(pszValue, "During") == 0 )
return MS_TRUE;
}
return MS_FALSE;
}
| 4,840 |
103,953 | 0 | bool RenderBuffer::AllocateStorage(const gfx::Size& size, GLenum format,
GLsizei samples) {
ScopedGLErrorSuppressor suppressor(decoder_);
ScopedRenderBufferBinder binder(decoder_, id_);
if (samples <= 1) {
glRenderbufferStorageEXT(GL_RENDERBUFFER,
format,
size.width(),
size.height());
} else {
if (IsAngle()) {
glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER,
samples,
format,
size.width(),
size.height());
} else {
glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER,
samples,
format,
size.width(),
size.height());
}
}
return glGetError() == GL_NO_ERROR;
}
| 4,841 |
45,514 | 0 | static void authenc_request_complete(struct aead_request *req, int err)
{
if (err != -EINPROGRESS)
aead_request_complete(req, err);
}
| 4,842 |
170,468 | 0 | int Parcel::readFileDescriptor() const
{
const flat_binder_object* flat = readObject(true);
if (flat) {
switch (flat->type) {
case BINDER_TYPE_FD:
return flat->handle;
}
}
return BAD_TYPE;
}
| 4,843 |
105,338 | 0 | const AutofillManager::GUIDPair AutofillManager::IDToGUID(int id) {
if (id == 0)
return GUIDPair(std::string(), 0);
std::map<int, GUIDPair>::const_iterator iter = id_guid_map_.find(id);
if (iter == id_guid_map_.end()) {
NOTREACHED();
return GUIDPair(std::string(), 0);
}
return iter->second;
}
| 4,844 |
149,094 | 0 | static TriggerPrg *codeRowTrigger(
Parse *pParse, /* Current parse context */
Trigger *pTrigger, /* Trigger to code */
Table *pTab, /* The table pTrigger is attached to */
int orconf /* ON CONFLICT policy to code trigger program with */
){
Parse *pTop = sqlite3ParseToplevel(pParse);
sqlite3 *db = pParse->db; /* Database handle */
TriggerPrg *pPrg; /* Value to return */
Expr *pWhen = 0; /* Duplicate of trigger WHEN expression */
Vdbe *v; /* Temporary VM */
NameContext sNC; /* Name context for sub-vdbe */
SubProgram *pProgram = 0; /* Sub-vdbe for trigger program */
Parse *pSubParse; /* Parse context for sub-vdbe */
int iEndTrigger = 0; /* Label to jump to if WHEN is false */
assert( pTrigger->zName==0 || pTab==tableOfTrigger(pTrigger) );
assert( pTop->pVdbe );
/* Allocate the TriggerPrg and SubProgram objects. To ensure that they
** are freed if an error occurs, link them into the Parse.pTriggerPrg
** list of the top-level Parse object sooner rather than later. */
pPrg = sqlite3DbMallocZero(db, sizeof(TriggerPrg));
if( !pPrg ) return 0;
pPrg->pNext = pTop->pTriggerPrg;
pTop->pTriggerPrg = pPrg;
pPrg->pProgram = pProgram = sqlite3DbMallocZero(db, sizeof(SubProgram));
if( !pProgram ) return 0;
sqlite3VdbeLinkSubProgram(pTop->pVdbe, pProgram);
pPrg->pTrigger = pTrigger;
pPrg->orconf = orconf;
pPrg->aColmask[0] = 0xffffffff;
pPrg->aColmask[1] = 0xffffffff;
/* Allocate and populate a new Parse context to use for coding the
** trigger sub-program. */
pSubParse = sqlite3StackAllocZero(db, sizeof(Parse));
if( !pSubParse ) return 0;
memset(&sNC, 0, sizeof(sNC));
sNC.pParse = pSubParse;
pSubParse->db = db;
pSubParse->pTriggerTab = pTab;
pSubParse->pToplevel = pTop;
pSubParse->zAuthContext = pTrigger->zName;
pSubParse->eTriggerOp = pTrigger->op;
pSubParse->nQueryLoop = pParse->nQueryLoop;
v = sqlite3GetVdbe(pSubParse);
if( v ){
VdbeComment((v, "Start: %s.%s (%s %s%s%s ON %s)",
pTrigger->zName, onErrorText(orconf),
(pTrigger->tr_tm==TRIGGER_BEFORE ? "BEFORE" : "AFTER"),
(pTrigger->op==TK_UPDATE ? "UPDATE" : ""),
(pTrigger->op==TK_INSERT ? "INSERT" : ""),
(pTrigger->op==TK_DELETE ? "DELETE" : ""),
pTab->zName
));
#ifndef SQLITE_OMIT_TRACE
sqlite3VdbeChangeP4(v, -1,
sqlite3MPrintf(db, "-- TRIGGER %s", pTrigger->zName), P4_DYNAMIC
);
#endif
/* If one was specified, code the WHEN clause. If it evaluates to false
** (or NULL) the sub-vdbe is immediately halted by jumping to the
** OP_Halt inserted at the end of the program. */
if( pTrigger->pWhen ){
pWhen = sqlite3ExprDup(db, pTrigger->pWhen, 0);
if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen)
&& db->mallocFailed==0
){
iEndTrigger = sqlite3VdbeMakeLabel(v);
sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL);
}
sqlite3ExprDelete(db, pWhen);
}
/* Code the trigger program into the sub-vdbe. */
codeTriggerProgram(pSubParse, pTrigger->step_list, orconf);
/* Insert an OP_Halt at the end of the sub-program. */
if( iEndTrigger ){
sqlite3VdbeResolveLabel(v, iEndTrigger);
}
sqlite3VdbeAddOp0(v, OP_Halt);
VdbeComment((v, "End: %s.%s", pTrigger->zName, onErrorText(orconf)));
transferParseError(pParse, pSubParse);
if( db->mallocFailed==0 ){
pProgram->aOp = sqlite3VdbeTakeOpArray(v, &pProgram->nOp, &pTop->nMaxArg);
}
pProgram->nMem = pSubParse->nMem;
pProgram->nCsr = pSubParse->nTab;
pProgram->token = (void *)pTrigger;
pPrg->aColmask[0] = pSubParse->oldmask;
pPrg->aColmask[1] = pSubParse->newmask;
sqlite3VdbeDelete(v);
}
assert( !pSubParse->pAinc && !pSubParse->pZombieTab );
assert( !pSubParse->pTriggerPrg && !pSubParse->nMaxArg );
sqlite3ParserReset(pSubParse);
sqlite3StackFree(db, pSubParse);
return pPrg;
}
| 4,845 |
33,814 | 0 | static void vhost_vq_reset(struct vhost_dev *dev,
struct vhost_virtqueue *vq)
{
vq->num = 1;
vq->desc = NULL;
vq->avail = NULL;
vq->used = NULL;
vq->last_avail_idx = 0;
vq->avail_idx = 0;
vq->last_used_idx = 0;
vq->signalled_used = 0;
vq->signalled_used_valid = false;
vq->used_flags = 0;
vq->log_used = false;
vq->log_addr = -1ull;
vq->vhost_hlen = 0;
vq->sock_hlen = 0;
vq->private_data = NULL;
vq->log_base = NULL;
vq->error_ctx = NULL;
vq->error = NULL;
vq->kick = NULL;
vq->call_ctx = NULL;
vq->call = NULL;
vq->log_ctx = NULL;
vq->upend_idx = 0;
vq->done_idx = 0;
vq->ubufs = NULL;
}
| 4,846 |
186,713 | 1 | IDNSpoofChecker::IDNSpoofChecker() {
UErrorCode status = U_ZERO_ERROR;
checker_ = uspoof_open(&status);
if (U_FAILURE(status)) {
checker_ = nullptr;
return;
}
// At this point, USpoofChecker has all the checks enabled except
// for USPOOF_CHAR_LIMIT (USPOOF_{RESTRICTION_LEVEL, INVISIBLE,
// MIXED_SCRIPT_CONFUSABLE, WHOLE_SCRIPT_CONFUSABLE, MIXED_NUMBERS, ANY_CASE})
// This default configuration is adjusted below as necessary.
// Set the restriction level to high. It allows mixing Latin with one logical
// CJK script (+ COMMON and INHERITED), but does not allow any other script
// mixing (e.g. Latin + Cyrillic, Latin + Armenian, Cyrillic + Greek). Note
// that each of {Han + Bopomofo} for Chinese, {Hiragana, Katakana, Han} for
// Japanese, and {Hangul, Han} for Korean is treated as a single logical
// script.
// See http://www.unicode.org/reports/tr39/#Restriction_Level_Detection
uspoof_setRestrictionLevel(checker_, USPOOF_HIGHLY_RESTRICTIVE);
// Sets allowed characters in IDN labels and turns on USPOOF_CHAR_LIMIT.
SetAllowedUnicodeSet(&status);
// Enable the return of auxillary (non-error) information.
// We used to disable WHOLE_SCRIPT_CONFUSABLE check explicitly, but as of
// ICU 58.1, WSC is a no-op in a single string check API.
int32_t checks = uspoof_getChecks(checker_, &status) | USPOOF_AUX_INFO;
uspoof_setChecks(checker_, checks, &status);
// Four characters handled differently by IDNA 2003 and IDNA 2008. UTS46
// transitional processing treats them as IDNA 2003 does; maps U+00DF and
// U+03C2 and drops U+200[CD].
deviation_characters_ = icu::UnicodeSet(
UNICODE_STRING_SIMPLE("[\\u00df\\u03c2\\u200c\\u200d]"), status);
deviation_characters_.freeze();
// Latin letters outside ASCII. 'Script_Extensions=Latin' is not necessary
// because additional characters pulled in with scx=Latn are not included in
// the allowed set.
non_ascii_latin_letters_ =
icu::UnicodeSet(UNICODE_STRING_SIMPLE("[[:Latin:] - [a-zA-Z]]"), status);
non_ascii_latin_letters_.freeze();
// The following two sets are parts of |dangerous_patterns_|.
kana_letters_exceptions_ = icu::UnicodeSet(
UNICODE_STRING_SIMPLE("[\\u3078-\\u307a\\u30d8-\\u30da\\u30fb-\\u30fe]"),
status);
kana_letters_exceptions_.freeze();
combining_diacritics_exceptions_ =
icu::UnicodeSet(UNICODE_STRING_SIMPLE("[\\u0300-\\u0339]"), status);
combining_diacritics_exceptions_.freeze();
// These Cyrillic letters look like Latin. A domain label entirely made of
// these letters is blocked as a simplified whole-script-spoofable.
cyrillic_letters_latin_alike_ = icu::UnicodeSet(
icu::UnicodeString::fromUTF8("[асԁеһіјӏорԛѕԝхуъЬҽпгѵѡ]"), status);
cyrillic_letters_latin_alike_.freeze();
cyrillic_letters_ =
icu::UnicodeSet(UNICODE_STRING_SIMPLE("[[:Cyrl:]]"), status);
cyrillic_letters_.freeze();
DCHECK(U_SUCCESS(status));
// This set is used to determine whether or not to apply a slow
// transliteration to remove diacritics to a given hostname before the
// confusable skeleton calculation for comparison with top domain names. If
// it has any character outside the set, the expensive step will be skipped
// because it cannot match any of top domain names.
// The last ([\u0300-\u0339] is a shorthand for "[:Identifier_Status=Allowed:]
// & [:Script_Extensions=Inherited:] - [\\u200C\\u200D]". The latter is a
// subset of the former but it does not matter because hostnames with
// characters outside the latter set would be rejected in an earlier step.
lgc_letters_n_ascii_ = icu::UnicodeSet(
UNICODE_STRING_SIMPLE("[[:Latin:][:Greek:][:Cyrillic:][0-9\\u002e_"
"\\u002d][\\u0300-\\u0339]]"),
status);
lgc_letters_n_ascii_.freeze();
// Used for diacritics-removal before the skeleton calculation. Add
// "ł > l; ø > o; đ > d" that are not handled by "NFD; Nonspacing mark
// removal; NFC".
// TODO(jshin): Revisit "ł > l; ø > o" mapping.
UParseError parse_error;
diacritic_remover_.reset(icu::Transliterator::createFromRules(
UNICODE_STRING_SIMPLE("DropAcc"),
icu::UnicodeString::fromUTF8("::NFD; ::[:Nonspacing Mark:] Remove; ::NFC;"
" ł > l; ø > o; đ > d;"),
UTRANS_FORWARD, parse_error, status));
// Supplement the Unicode confusable list by the following mapping.
// - {U+00FE (þ), U+03FC (ϼ), U+048F (ҏ)} => p
// - {U+0127 (ħ), U+043D (н), U+045B (ћ), U+04A3 (ң), U+04A5 (ҥ),
// U+04C8 (ӈ), U+04CA (ӊ), U+0527 (ԧ), U+0529 (ԩ)} => h
// - {U+0138 (ĸ), U+03BA (κ), U+043A (к), U+049B (қ), U+049D (ҝ),
// U+049F (ҟ), U+04A1(ҡ), U+04C4 (ӄ), U+051F (ԟ)} => k
// - {U+014B (ŋ), U+043F (п)} => n
// - {U+0167 (ŧ), U+0442 (т), U+04AD (ҭ)} => t
// - {U+0185 (ƅ), U+044C (ь), U+048D (ҍ), U+0432 (в)} => b
// - {U+03C9 (ω), U+0448 (ш), U+0449 (щ), U+0E1F (ฟ)} => w
// - {U+043C (м), U+04CE (ӎ)} => m
// - {U+0454 (є), U+04BD (ҽ), U+04BF (ҿ), U+1054 (ၔ)} => e
// - U+0491 (ґ) => r
// - U+0493 (ғ) => f
// - {U+04AB (ҫ), U+1004 (င)} => c
// - U+04B1 (ұ) => y
// - U+03C7 (χ), U+04B3 (ҳ), U+04FD (ӽ), U+04FF (ӿ) => x
// - U+04CF (ӏ) => i (on Windows), l (elsewhere)
// - U+0503 (ԃ) => d
// - {U+050D (ԍ), U+100c (ဌ)} => g
// - {U+0D1F (ട), U+0E23 (ร)} => s
// - U+1042 (၂) => j
extra_confusable_mapper_.reset(icu::Transliterator::createFromRules(
UNICODE_STRING_SIMPLE("ExtraConf"),
icu::UnicodeString::fromUTF8("[þϼҏ] > p; [ħнћңҥӈӊԧԩ] > h;"
"[ĸκкқҝҟҡӄԟ] > k; [ŋп] > n; [ŧтҭ] > t;"
"[ƅьҍв] > b; [ωшщฟ] > w; [мӎ] > m;"
"[єҽҿၔ] > e; ґ > r; ғ > f; [ҫင] > c;"
"ұ > y; [χҳӽӿ] > x;"
#if defined(OS_WIN)
"ӏ > i;"
#else
"ӏ > l;"
#endif
"ԃ > d; [ԍဌ] > g; [ടร] > s; ၂ > j"),
UTRANS_FORWARD, parse_error, status));
DCHECK(U_SUCCESS(status))
<< "Spoofchecker initalization failed due to an error: "
<< u_errorName(status);
}
| 4,847 |
78,729 | 0 | static int card_reset(const char *reset_type)
{
int cold_reset;
int r;
if (reset_type && strcmp(reset_type, "cold") &&
strcmp(reset_type, "warm")) {
fprintf(stderr, "Invalid reset type: %s\n", reset_type);
return 2;
}
cold_reset = !reset_type || strcmp(reset_type, "cold") == 0;
r = sc_lock(card);
if (r == SC_SUCCESS)
r = sc_reset(card, cold_reset);
sc_unlock(card);
if (r) {
fprintf(stderr, "sc_reset(%s) failed: %d\n",
cold_reset ? "cold" : "warm", r);
return 1;
}
return 0;
}
| 4,848 |
42,241 | 0 | static void vhost_vq_reset_user_be(struct vhost_virtqueue *vq)
{
vq->user_be = !virtio_legacy_is_little_endian();
}
| 4,849 |
126,719 | 0 | bool BrowserView::CanActivate() const {
if (!AppModalDialogQueue::GetInstance()->active_dialog())
return true;
MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&BrowserView::ActivateAppModalDialog,
activate_modal_dialog_factory_.GetWeakPtr()));
return false;
}
| 4,850 |
43,337 | 0 | void CLASS parse_external_jpeg()
{
const char *file, *ext;
char *jname, *jfile, *jext;
FILE *save=ifp;
ext = strrchr (ifname, '.');
file = strrchr (ifname, '/');
if (!file) file = strrchr (ifname, '\\');
if (!file) file = ifname-1;
file++;
if (!ext || strlen(ext) != 4 || ext-file != 8) return;
jname = (char *) malloc (strlen(ifname) + 1);
merror (jname, "parse_external_jpeg()");
strcpy (jname, ifname);
jfile = file - ifname + jname;
jext = ext - ifname + jname;
if (strcasecmp (ext, ".jpg")) {
strcpy (jext, isupper(ext[1]) ? ".JPG":".jpg");
if (isdigit(*file)) {
memcpy (jfile, file+4, 4);
memcpy (jfile+4, file, 4);
}
} else
while (isdigit(*--jext)) {
if (*jext != '9') {
(*jext)++;
break;
}
*jext = '0';
}
if (strcmp (jname, ifname)) {
if ((ifp = fopen (jname, "rb"))) {
dcraw_message (DCRAW_VERBOSE,_("Reading metadata from %s ...\n"), jname);
parse_tiff (12);
thumb_offset = 0;
is_raw = 1;
fclose (ifp);
}
}
if (!timestamp)
dcraw_message (DCRAW_WARNING,_("Failed to read metadata from %s\n"), jname);
free (jname);
ifp = save;
}
| 4,851 |
170,869 | 0 | status_t SampleIterator::findSampleTimeAndDuration(
uint32_t sampleIndex, uint32_t *time, uint32_t *duration) {
if (sampleIndex >= mTable->mNumSampleSizes) {
return ERROR_OUT_OF_RANGE;
}
while (sampleIndex >= mTTSSampleIndex + mTTSCount) {
if (mTimeToSampleIndex == mTable->mTimeToSampleCount) {
return ERROR_OUT_OF_RANGE;
}
mTTSSampleIndex += mTTSCount;
mTTSSampleTime += mTTSCount * mTTSDuration;
mTTSCount = mTable->mTimeToSample[2 * mTimeToSampleIndex];
mTTSDuration = mTable->mTimeToSample[2 * mTimeToSampleIndex + 1];
++mTimeToSampleIndex;
}
*time = mTTSSampleTime + mTTSDuration * (sampleIndex - mTTSSampleIndex);
int32_t offset = mTable->getCompositionTimeOffset(sampleIndex);
if ((offset < 0 && *time < (offset == INT32_MIN ?
INT32_MAX : uint32_t(-offset))) ||
(offset > 0 && *time > UINT32_MAX - offset)) {
ALOGE("%u + %d would overflow", *time, offset);
return ERROR_OUT_OF_RANGE;
}
if (offset > 0) {
*time += offset;
} else {
*time -= (offset == INT32_MIN ? INT32_MAX : (-offset));
}
*duration = mTTSDuration;
return OK;
}
| 4,852 |
83,678 | 0 | int git_index_find_prefix(size_t *at_pos, git_index *index, const char *prefix)
{
int error = 0;
size_t pos;
const git_index_entry *entry;
index_find(&pos, index, prefix, strlen(prefix), GIT_INDEX_STAGE_ANY);
entry = git_vector_get(&index->entries, pos);
if (!entry || git__prefixcmp(entry->path, prefix) != 0)
error = GIT_ENOTFOUND;
if (!error && at_pos)
*at_pos = pos;
return error;
}
| 4,853 |
23,489 | 0 | static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr,
struct nfs_client *clp)
{
struct compound_hdr hdr = {
.nops = 0,
};
encode_compound_hdr(xdr, req, &hdr);
encode_renew(xdr, clp, &hdr);
encode_nops(&hdr);
}
| 4,854 |
153,783 | 0 | void GLES2Implementation::OnSwapBufferPresented(
uint64_t swap_id,
const gfx::PresentationFeedback& feedback) {
auto found = pending_presentation_callbacks_.find(swap_id);
if (found == pending_presentation_callbacks_.end())
return;
std::move(found->second).Run(feedback);
pending_presentation_callbacks_.erase(found);
}
| 4,855 |
32,051 | 0 | __acquires(RCU)
{
rcu_read_lock();
return *pos ? ptype_get_idx(*pos - 1) : SEQ_START_TOKEN;
}
| 4,856 |
30,136 | 0 | int __weak ftrace_arch_code_modify_prepare(void)
{
return 0;
}
| 4,857 |
128,498 | 0 | void ShellSurface::OnPreWindowStateTypeChange(
ash::wm::WindowState* window_state,
ash::wm::WindowStateType old_type) {
ash::wm::WindowStateType new_type = window_state->GetStateType();
if (ash::wm::IsMaximizedOrFullscreenOrPinnedWindowStateType(old_type) ||
ash::wm::IsMaximizedOrFullscreenOrPinnedWindowStateType(new_type)) {
if (configure_callback_.is_null())
scoped_animations_disabled_.reset(new ScopedAnimationsDisabled(this));
}
}
| 4,858 |
40,322 | 0 | static struct sock *atalk_search_socket(struct sockaddr_at *to,
struct atalk_iface *atif)
{
struct sock *s;
read_lock_bh(&atalk_sockets_lock);
sk_for_each(s, &atalk_sockets) {
struct atalk_sock *at = at_sk(s);
if (to->sat_port != at->src_port)
continue;
if (to->sat_addr.s_net == ATADDR_ANYNET &&
to->sat_addr.s_node == ATADDR_BCAST)
goto found;
if (to->sat_addr.s_net == at->src_net &&
(to->sat_addr.s_node == at->src_node ||
to->sat_addr.s_node == ATADDR_BCAST ||
to->sat_addr.s_node == ATADDR_ANYNODE))
goto found;
/* XXXX.0 -- we got a request for this router. make sure
* that the node is appropriately set. */
if (to->sat_addr.s_node == ATADDR_ANYNODE &&
to->sat_addr.s_net != ATADDR_ANYNET &&
atif->address.s_node == at->src_node) {
to->sat_addr.s_node = atif->address.s_node;
goto found;
}
}
s = NULL;
found:
read_unlock_bh(&atalk_sockets_lock);
return s;
}
| 4,859 |
23,107 | 0 | static int nfs4_xdr_dec_lockt(struct rpc_rqst *rqstp, __be32 *p, struct nfs_lockt_res *res)
{
struct xdr_stream xdr;
struct compound_hdr hdr;
int status;
xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
status = decode_compound_hdr(&xdr, &hdr);
if (status)
goto out;
status = decode_putfh(&xdr);
if (status)
goto out;
status = decode_lockt(&xdr, res);
out:
return status;
}
| 4,860 |
154,534 | 0 | void GLES2DecoderPassthroughImpl::UpdateTextureBinding(
GLenum target,
GLuint client_id,
TexturePassthrough* texture) {
GLuint texture_service_id = texture ? texture->service_id() : 0;
size_t cur_texture_unit = active_texture_unit_;
auto& target_bound_textures =
bound_textures_[static_cast<size_t>(GLenumToTextureTarget(target))];
for (size_t bound_texture_index = 0;
bound_texture_index < target_bound_textures.size();
bound_texture_index++) {
if (target_bound_textures[bound_texture_index].client_id == client_id) {
if (bound_texture_index != cur_texture_unit) {
api()->glActiveTextureFn(
static_cast<GLenum>(GL_TEXTURE0 + bound_texture_index));
cur_texture_unit = bound_texture_index;
}
api()->glBindTextureFn(target, texture_service_id);
target_bound_textures[bound_texture_index].texture = texture;
}
}
if (cur_texture_unit != active_texture_unit_) {
api()->glActiveTextureFn(
static_cast<GLenum>(GL_TEXTURE0 + active_texture_unit_));
}
}
| 4,861 |
78,946 | 0 | ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr,
xkb_keycode_t *kc)
{
xkb_keycode_t leftRtrn, rightRtrn;
switch (expr->expr.op) {
case EXPR_VALUE:
if (expr->expr.value_type != EXPR_TYPE_INT) {
log_err(ctx,
"Found constant of type %s where an int was expected\n",
expr_value_type_to_string(expr->expr.value_type));
return false;
}
*kc = (xkb_keycode_t) expr->integer.ival;
return true;
case EXPR_ADD:
case EXPR_SUBTRACT:
case EXPR_MULTIPLY:
case EXPR_DIVIDE:
if (!ExprResolveKeyCode(ctx, expr->binary.left, &leftRtrn) ||
!ExprResolveKeyCode(ctx, expr->binary.right, &rightRtrn))
return false;
switch (expr->expr.op) {
case EXPR_ADD:
*kc = leftRtrn + rightRtrn;
break;
case EXPR_SUBTRACT:
*kc = leftRtrn - rightRtrn;
break;
case EXPR_MULTIPLY:
*kc = leftRtrn * rightRtrn;
break;
case EXPR_DIVIDE:
if (rightRtrn == 0) {
log_err(ctx, "Cannot divide by zero: %d / %d\n",
leftRtrn, rightRtrn);
return false;
}
*kc = leftRtrn / rightRtrn;
break;
default:
break;
}
return true;
case EXPR_NEGATE:
if (!ExprResolveKeyCode(ctx, expr->unary.child, &leftRtrn))
return false;
*kc = ~leftRtrn;
return true;
case EXPR_UNARY_PLUS:
return ExprResolveKeyCode(ctx, expr->unary.child, kc);
default:
log_wsgo(ctx, "Unknown operator %d in ResolveKeyCode\n",
expr->expr.op);
break;
}
return false;
}
| 4,862 |
39,940 | 0 | static bool spd_can_coalesce(const struct splice_pipe_desc *spd,
struct page *page,
unsigned int offset)
{
return spd->nr_pages &&
spd->pages[spd->nr_pages - 1] == page &&
(spd->partial[spd->nr_pages - 1].offset +
spd->partial[spd->nr_pages - 1].len == offset);
}
| 4,863 |
51,953 | 0 | SpoolssEnumPrinters_r(tvbuff_t *tvb, int offset, packet_info *pinfo,
proto_tree *tree, dcerpc_info *di, guint8 *drep _U_)
{
guint32 num_drivers;
dcerpc_call_value *dcv = (dcerpc_call_value *)di->call_data;
gint16 level = GPOINTER_TO_INT(dcv->se_data);
BUFFER buffer;
proto_item *item;
proto_tree *subtree = NULL;
col_append_fstr(pinfo->cinfo, COL_INFO, ", level %d", level);
/* Parse packet */
offset = dissect_spoolss_buffer(
tvb, offset, pinfo, tree, di, drep, &buffer);
if (buffer.tvb) {
subtree = proto_tree_add_subtree_format( buffer.tree, buffer.tvb, 0, -1, ett_PRINTER_INFO, &item, "Print info level %d", level);
switch(level) {
case 0:
dissect_PRINTER_INFO_0(
buffer.tvb, 0, pinfo, subtree, di, drep);
break;
case 1:
dissect_PRINTER_INFO_1(
buffer.tvb, 0, pinfo, subtree, di, drep);
break;
case 2:
dissect_PRINTER_INFO_2(
buffer.tvb, 0, pinfo, subtree, di, drep);
break;
case 3:
dissect_PRINTER_INFO_3(
buffer.tvb, 0, pinfo, subtree, di, drep);
break;
case 7:
dissect_PRINTER_INFO_7(
buffer.tvb, 0, pinfo, subtree, di, drep);
break;
default:
expert_add_info(pinfo, item, &ei_printer_info_level);
break;
}
}
offset = dissect_ndr_uint32(
tvb, offset, pinfo, tree, di, drep, hf_needed, NULL);
offset = dissect_ndr_uint32(
tvb, offset, pinfo, tree, di, drep, hf_returned,
&num_drivers);
offset = dissect_doserror(
tvb, offset, pinfo, tree, di, drep, hf_rc, NULL);
return offset;
}
| 4,864 |
14,753 | 0 | PHP_FUNCTION(pg_result_error)
{
zval *result;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
char *err = NULL;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "r",
&result) == FAILURE) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, &result, -1, "PostgreSQL result", le_result);
pgsql_result = pg_result->result;
if (!pgsql_result) {
RETURN_FALSE;
}
err = (char *)PQresultErrorMessage(pgsql_result);
RETURN_STRING(err,1);
}
| 4,865 |
88,826 | 0 | static unsigned int floppy_check_events(struct gendisk *disk,
unsigned int clearing)
{
int drive = (long)disk->private_data;
if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags) ||
test_bit(FD_VERIFY_BIT, &UDRS->flags))
return DISK_EVENT_MEDIA_CHANGE;
if (time_after(jiffies, UDRS->last_checked + UDP->checkfreq)) {
if (lock_fdc(drive))
return 0;
poll_drive(false, 0);
process_fd_request();
}
if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags) ||
test_bit(FD_VERIFY_BIT, &UDRS->flags) ||
test_bit(drive, &fake_change) ||
drive_no_geom(drive))
return DISK_EVENT_MEDIA_CHANGE;
return 0;
}
| 4,866 |
47,104 | 0 | int crypto_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
unsigned int key_len)
{
struct crypto_aes_ctx *ctx = crypto_tfm_ctx(tfm);
u32 *flags = &tfm->crt_flags;
int ret;
ret = crypto_aes_expand_key(ctx, in_key, key_len);
if (!ret)
return 0;
*flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
return -EINVAL;
}
| 4,867 |
71,231 | 0 | static struct page *kvm_pfn_to_page(kvm_pfn_t pfn)
{
if (is_error_noslot_pfn(pfn))
return KVM_ERR_PTR_BAD_PAGE;
if (kvm_is_reserved_pfn(pfn)) {
WARN_ON(1);
return KVM_ERR_PTR_BAD_PAGE;
}
return pfn_to_page(pfn);
}
| 4,868 |
146,421 | 0 | bool WebGLRenderingContextBase::ValidateStencilSettings(
const char* function_name) {
if (stencil_mask_ != stencil_mask_back_ ||
stencil_func_ref_ != stencil_func_ref_back_ ||
stencil_func_mask_ != stencil_func_mask_back_) {
SynthesizeGLError(GL_INVALID_OPERATION, function_name,
"front and back stencils settings do not match");
return false;
}
return true;
}
| 4,869 |
38,911 | 0 | line_vertical(PG_FUNCTION_ARGS)
{
LINE *line = PG_GETARG_LINE_P(0);
PG_RETURN_BOOL(FPzero(line->B));
}
| 4,870 |
153,096 | 0 | pp::Buffer_Dev PDFiumEngine::PrintPagesAsRasterPDF(
const PP_PrintPageNumberRange_Dev* page_ranges, uint32_t page_range_count,
const PP_PrintSettings_Dev& print_settings) {
if (!page_range_count)
return pp::Buffer_Dev();
if (doc_ && !doc_loader_.IsDocumentComplete())
return pp::Buffer_Dev();
FPDF_DOCUMENT output_doc = FPDF_CreateNewDocument();
if (!output_doc)
return pp::Buffer_Dev();
SaveSelectedFormForPrint();
std::vector<PDFiumPage> pages_to_print;
std::vector<std::pair<double, double> > source_page_sizes;
std::vector<uint32_t> page_numbers =
GetPageNumbersFromPrintPageNumberRange(page_ranges, page_range_count);
for (uint32_t page_number : page_numbers) {
FPDF_PAGE pdf_page = FPDF_LoadPage(doc_, page_number);
double source_page_width = FPDF_GetPageWidth(pdf_page);
double source_page_height = FPDF_GetPageHeight(pdf_page);
source_page_sizes.push_back(std::make_pair(source_page_width,
source_page_height));
int width_in_pixels = ConvertUnit(source_page_width,
kPointsPerInch,
print_settings.dpi);
int height_in_pixels = ConvertUnit(source_page_height,
kPointsPerInch,
print_settings.dpi);
pp::Rect rect(width_in_pixels, height_in_pixels);
pages_to_print.push_back(PDFiumPage(this, page_number, rect, true));
FPDF_ClosePage(pdf_page);
}
#if defined(OS_LINUX)
g_last_instance_id = client_->GetPluginInstance()->pp_instance();
#endif
size_t i = 0;
for (; i < pages_to_print.size(); ++i) {
double source_page_width = source_page_sizes[i].first;
double source_page_height = source_page_sizes[i].second;
FPDF_DOCUMENT temp_doc = CreateSinglePageRasterPdf(source_page_width,
source_page_height,
print_settings,
&pages_to_print[i]);
if (!temp_doc)
break;
pp::Buffer_Dev buffer = GetFlattenedPrintData(temp_doc);
FPDF_CloseDocument(temp_doc);
PDFiumMemBufferFileRead file_read(buffer.data(), buffer.size());
temp_doc = FPDF_LoadCustomDocument(&file_read, nullptr);
FPDF_BOOL imported = FPDF_ImportPages(output_doc, temp_doc, "1", i);
FPDF_CloseDocument(temp_doc);
if (!imported)
break;
}
pp::Buffer_Dev buffer;
if (i == pages_to_print.size()) {
FPDF_CopyViewerPreferences(output_doc, doc_);
FitContentsToPrintableAreaIfRequired(output_doc, print_settings);
buffer = GetFlattenedPrintData(output_doc);
}
FPDF_CloseDocument(output_doc);
return buffer;
}
| 4,871 |
112,601 | 0 | void Document::unregisterForPrivateBrowsingStateChangedCallbacks(Element* e)
{
m_privateBrowsingStateChangedElements.remove(e);
}
| 4,872 |
3,656 | 0 | int test_gf2m_mod_solve_quad(BIO *bp, BN_CTX *ctx)
{
BIGNUM *a, *b[2], *c, *d, *e;
int i, j, s = 0, t, ret = 0;
int p0[] = { 163, 7, 6, 3, 0, -1 };
int p1[] = { 193, 15, 0, -1 };
a = BN_new();
b[0] = BN_new();
b[1] = BN_new();
c = BN_new();
d = BN_new();
e = BN_new();
BN_GF2m_arr2poly(p0, b[0]);
BN_GF2m_arr2poly(p1, b[1]);
for (i = 0; i < num0; i++) {
BN_bntest_rand(a, 512, 0, 0);
for (j = 0; j < 2; j++) {
t = BN_GF2m_mod_solve_quad(c, a, b[j], ctx);
if (t) {
s++;
BN_GF2m_mod_sqr(d, c, b[j], ctx);
BN_GF2m_add(d, c, d);
BN_GF2m_mod(e, a, b[j]);
# if 0 /* make test uses ouput in bc but bc can't
* handle GF(2^m) arithmetic */
if (bp != NULL) {
if (!results) {
BN_print(bp, c);
BIO_puts(bp, " is root of z^2 + z = ");
BN_print(bp, a);
BIO_puts(bp, " % ");
BN_print(bp, b[j]);
BIO_puts(bp, "\n");
}
}
# endif
BN_GF2m_add(e, e, d);
/*
* Test that solution of quadratic c satisfies c^2 + c = a.
*/
if (!BN_is_zero(e)) {
fprintf(stderr,
"GF(2^m) modular solve quadratic test failed!\n");
goto err;
}
} else {
# if 0 /* make test uses ouput in bc but bc can't
* handle GF(2^m) arithmetic */
if (bp != NULL) {
if (!results) {
BIO_puts(bp, "There are no roots of z^2 + z = ");
BN_print(bp, a);
BIO_puts(bp, " % ");
BN_print(bp, b[j]);
BIO_puts(bp, "\n");
}
}
# endif
}
}
}
if (s == 0) {
fprintf(stderr,
"All %i tests of GF(2^m) modular solve quadratic resulted in no roots;\n",
num0);
fprintf(stderr,
"this is very unlikely and probably indicates an error.\n");
goto err;
}
ret = 1;
err:
BN_free(a);
BN_free(b[0]);
BN_free(b[1]);
BN_free(c);
BN_free(d);
BN_free(e);
return ret;
}
| 4,873 |
95,482 | 0 | void Com_ReadFromPipe( void )
{
static char buf[MAX_STRING_CHARS];
static int accu = 0;
int read;
if( !pipefile )
return;
while( ( read = FS_Read( buf + accu, sizeof( buf ) - accu - 1, pipefile ) ) > 0 )
{
char *brk = NULL;
int i;
for( i = accu; i < accu + read; ++i )
{
if( buf[ i ] == '\0' )
buf[ i ] = '\n';
if( buf[ i ] == '\n' || buf[ i ] == '\r' )
brk = &buf[ i + 1 ];
}
buf[ accu + read ] = '\0';
accu += read;
if( brk )
{
char tmp = *brk;
*brk = '\0';
Cbuf_ExecuteText( EXEC_APPEND, buf );
*brk = tmp;
accu -= brk - buf;
memmove( buf, brk, accu + 1 );
}
else if( accu >= sizeof( buf ) - 1 ) // full
{
Cbuf_ExecuteText( EXEC_APPEND, buf );
accu = 0;
}
}
}
| 4,874 |
170,380 | 0 | static int32_t readSize(off64_t offset,
const sp<DataSource> DataSource, uint8_t *numOfBytes) {
uint32_t size = 0;
uint8_t data;
bool moreData = true;
*numOfBytes = 0;
while (moreData) {
if (DataSource->readAt(offset, &data, 1) < 1) {
return -1;
}
offset ++;
moreData = (data >= 128) ? true : false;
size = (size << 7) | (data & 0x7f); // Take last 7 bits
(*numOfBytes) ++;
}
return size;
}
| 4,875 |
32,586 | 0 | static int tg3_hwtstamp_ioctl(struct net_device *dev,
struct ifreq *ifr, int cmd)
{
struct tg3 *tp = netdev_priv(dev);
struct hwtstamp_config stmpconf;
if (!tg3_flag(tp, PTP_CAPABLE))
return -EINVAL;
if (copy_from_user(&stmpconf, ifr->ifr_data, sizeof(stmpconf)))
return -EFAULT;
if (stmpconf.flags)
return -EINVAL;
switch (stmpconf.tx_type) {
case HWTSTAMP_TX_ON:
tg3_flag_set(tp, TX_TSTAMP_EN);
break;
case HWTSTAMP_TX_OFF:
tg3_flag_clear(tp, TX_TSTAMP_EN);
break;
default:
return -ERANGE;
}
switch (stmpconf.rx_filter) {
case HWTSTAMP_FILTER_NONE:
tp->rxptpctl = 0;
break;
case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V1_EN |
TG3_RX_PTP_CTL_ALL_V1_EVENTS;
break;
case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V1_EN |
TG3_RX_PTP_CTL_SYNC_EVNT;
break;
case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V1_EN |
TG3_RX_PTP_CTL_DELAY_REQ;
break;
case HWTSTAMP_FILTER_PTP_V2_EVENT:
tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_EN |
TG3_RX_PTP_CTL_ALL_V2_EVENTS;
break;
case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN |
TG3_RX_PTP_CTL_ALL_V2_EVENTS;
break;
case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN |
TG3_RX_PTP_CTL_ALL_V2_EVENTS;
break;
case HWTSTAMP_FILTER_PTP_V2_SYNC:
tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_EN |
TG3_RX_PTP_CTL_SYNC_EVNT;
break;
case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN |
TG3_RX_PTP_CTL_SYNC_EVNT;
break;
case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN |
TG3_RX_PTP_CTL_SYNC_EVNT;
break;
case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_EN |
TG3_RX_PTP_CTL_DELAY_REQ;
break;
case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ:
tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_L2_EN |
TG3_RX_PTP_CTL_DELAY_REQ;
break;
case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
tp->rxptpctl = TG3_RX_PTP_CTL_RX_PTP_V2_L4_EN |
TG3_RX_PTP_CTL_DELAY_REQ;
break;
default:
return -ERANGE;
}
if (netif_running(dev) && tp->rxptpctl)
tw32(TG3_RX_PTP_CTL,
tp->rxptpctl | TG3_RX_PTP_CTL_HWTS_INTERLOCK);
return copy_to_user(ifr->ifr_data, &stmpconf, sizeof(stmpconf)) ?
-EFAULT : 0;
}
| 4,876 |
140,942 | 0 | HTMLDialogElement* Document::ActiveModalDialog() const {
for (auto it = top_layer_elements_.rbegin(); it != top_layer_elements_.rend();
++it) {
if (auto* dialog = ToHTMLDialogElementOrNull(*it))
return dialog;
}
return nullptr;
}
| 4,877 |
70,373 | 0 | static int jp2_cmap_getdata(jp2_box_t *box, jas_stream_t *in)
{
jp2_cmap_t *cmap = &box->data.cmap;
jp2_cmapent_t *ent;
unsigned int i;
cmap->numchans = (box->datalen) / 4;
if (!(cmap->ents = jas_alloc2(cmap->numchans, sizeof(jp2_cmapent_t)))) {
return -1;
}
for (i = 0; i < cmap->numchans; ++i) {
ent = &cmap->ents[i];
if (jp2_getuint16(in, &ent->cmptno) ||
jp2_getuint8(in, &ent->map) ||
jp2_getuint8(in, &ent->pcol)) {
return -1;
}
}
return 0;
}
| 4,878 |
147,275 | 0 | static void CeReactionsNotOverloadedMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info) {
ExceptionState exception_state(info.GetIsolate(), ExceptionState::kExecutionContext, "TestObject", "ceReactionsNotOverloadedMethod");
CEReactionsScope ce_reactions_scope;
TestObject* impl = V8TestObject::ToImpl(info.Holder());
if (UNLIKELY(info.Length() < 1)) {
exception_state.ThrowTypeError(ExceptionMessages::NotEnoughArguments(1, info.Length()));
return;
}
bool arg;
arg = NativeValueTraits<IDLBoolean>::NativeValue(info.GetIsolate(), info[0], exception_state);
if (exception_state.HadException())
return;
impl->ceReactionsNotOverloadedMethod(arg);
}
| 4,879 |
177,035 | 0 | InputDispatcher::EventEntry::~EventEntry() {
releaseInjectionState();
}
| 4,880 |
175,449 | 0 | static struct audio_usecase *get_usecase_from_id(struct audio_device *adev,
audio_usecase_t uc_id)
{
struct audio_usecase *usecase;
struct listnode *node;
list_for_each(node, &adev->usecase_list) {
usecase = node_to_item(node, struct audio_usecase, adev_list_node);
if (usecase->id == uc_id)
return usecase;
}
return NULL;
}
| 4,881 |
12,215 | 0 | static void stroke_leases(private_stroke_socket_t *this,
stroke_msg_t *msg, FILE *out)
{
pop_string(msg, &msg->leases.pool);
pop_string(msg, &msg->leases.address);
this->list->leases(this->list, msg, out);
}
| 4,882 |
92,903 | 0 | main(int argc, char **argv)
{
int ch, fflag, tflag, status, n;
char **newargv;
const char *errstr;
extern char *optarg;
extern int optind;
/* Ensure that fds 0, 1 and 2 are open or directed to /dev/null */
sanitise_stdfd();
msetlocale();
/* Copy argv, because we modify it */
newargv = xcalloc(MAXIMUM(argc + 1, 1), sizeof(*newargv));
for (n = 0; n < argc; n++)
newargv[n] = xstrdup(argv[n]);
argv = newargv;
__progname = ssh_get_progname(argv[0]);
memset(&args, '\0', sizeof(args));
memset(&remote_remote_args, '\0', sizeof(remote_remote_args));
args.list = remote_remote_args.list = NULL;
addargs(&args, "%s", ssh_program);
addargs(&args, "-x");
addargs(&args, "-oForwardAgent=no");
addargs(&args, "-oPermitLocalCommand=no");
addargs(&args, "-oClearAllForwardings=yes");
addargs(&args, "-oRemoteCommand=none");
addargs(&args, "-oRequestTTY=no");
fflag = tflag = 0;
while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q12346S:o:F:")) != -1)
switch (ch) {
/* User-visible flags. */
case '1':
fatal("SSH protocol v.1 is no longer supported");
break;
case '2':
/* Ignored */
break;
case '4':
case '6':
case 'C':
addargs(&args, "-%c", ch);
addargs(&remote_remote_args, "-%c", ch);
break;
case '3':
throughlocal = 1;
break;
case 'o':
case 'c':
case 'i':
case 'F':
addargs(&remote_remote_args, "-%c", ch);
addargs(&remote_remote_args, "%s", optarg);
addargs(&args, "-%c", ch);
addargs(&args, "%s", optarg);
break;
case 'P':
sshport = a2port(optarg);
if (sshport <= 0)
fatal("bad port \"%s\"\n", optarg);
break;
case 'B':
addargs(&remote_remote_args, "-oBatchmode=yes");
addargs(&args, "-oBatchmode=yes");
break;
case 'l':
limit_kbps = strtonum(optarg, 1, 100 * 1024 * 1024,
&errstr);
if (errstr != NULL)
usage();
limit_kbps *= 1024; /* kbps */
bandwidth_limit_init(&bwlimit, limit_kbps, COPY_BUFLEN);
break;
case 'p':
pflag = 1;
break;
case 'r':
iamrecursive = 1;
break;
case 'S':
ssh_program = xstrdup(optarg);
break;
case 'v':
addargs(&args, "-v");
addargs(&remote_remote_args, "-v");
verbose_mode = 1;
break;
case 'q':
addargs(&args, "-q");
addargs(&remote_remote_args, "-q");
showprogress = 0;
break;
/* Server options. */
case 'd':
targetshouldbedirectory = 1;
break;
case 'f': /* "from" */
iamremote = 1;
fflag = 1;
break;
case 't': /* "to" */
iamremote = 1;
tflag = 1;
#ifdef HAVE_CYGWIN
setmode(0, O_BINARY);
#endif
break;
default:
usage();
}
argc -= optind;
argv += optind;
if ((pwd = getpwuid(userid = getuid())) == NULL)
fatal("unknown user %u", (u_int) userid);
if (!isatty(STDOUT_FILENO))
showprogress = 0;
if (pflag) {
/* Cannot pledge: -p allows setuid/setgid files... */
} else {
if (pledge("stdio rpath wpath cpath fattr tty proc exec",
NULL) == -1) {
perror("pledge");
exit(1);
}
}
remin = STDIN_FILENO;
remout = STDOUT_FILENO;
if (fflag) {
/* Follow "protocol", send data. */
(void) response();
source(argc, argv);
exit(errs != 0);
}
if (tflag) {
/* Receive data. */
sink(argc, argv);
exit(errs != 0);
}
if (argc < 2)
usage();
if (argc > 2)
targetshouldbedirectory = 1;
remin = remout = -1;
do_cmd_pid = -1;
/* Command to be executed on remote system using "ssh". */
(void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s",
verbose_mode ? " -v" : "",
iamrecursive ? " -r" : "", pflag ? " -p" : "",
targetshouldbedirectory ? " -d" : "");
(void) signal(SIGPIPE, lostconn);
if (colon(argv[argc - 1])) /* Dest is remote host. */
toremote(argc, argv);
else {
if (targetshouldbedirectory)
verifydir(argv[argc - 1]);
tolocal(argc, argv); /* Dest is local host. */
}
/*
* Finally check the exit status of the ssh process, if one was forked
* and no error has occurred yet
*/
if (do_cmd_pid != -1 && errs == 0) {
if (remin != -1)
(void) close(remin);
if (remout != -1)
(void) close(remout);
if (waitpid(do_cmd_pid, &status, 0) == -1)
errs = 1;
else {
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
errs = 1;
}
}
exit(errs != 0);
}
| 4,883 |
7,987 | 0 | void start_client_init(VncState *vs)
{
vnc_read_when(vs, protocol_client_init, 1);
}
| 4,884 |
1,652 | 0 | compute_inst_matrix(gs_pattern1_instance_t * pinst, gs_gstate * saved,
gs_rect * pbbox, int width, int height)
{
float xx, xy, yx, yy, dx, dy, temp;
int code;
code = gs_bbox_transform(&pinst->templat.BBox, &ctm_only(saved), pbbox);
if (code < 0)
return code;
/*
* Adjust saved.ctm to map the bbox origin to pixels.
*/
dx = pbbox->p.x - floor(pbbox->p.x + 0.5);
dy = pbbox->p.y - floor(pbbox->p.y + 0.5);
pbbox->p.x -= dx;
pbbox->p.y -= dy;
pbbox->q.x -= dx;
pbbox->q.y -= dy;
if (saved->ctm.txy_fixed_valid) {
code = gx_translate_to_fixed(saved, float2fixed_rounded(saved->ctm.tx - dx),
float2fixed_rounded(saved->ctm.ty - dy));
} else { /* the ctm didn't fit in a fixed. Just adjust the float values */
saved->ctm.tx -= dx;
saved->ctm.ty -= dy;
/* not sure if this is needed for patterns, but lifted from gx_translate_to_fixed */
code = gx_path_translate(saved->path, float2fixed(-dx), float2fixed(-dy));
}
if (code < 0)
return code;
/* The stepping matrix : */
xx = pinst->templat.XStep * saved->ctm.xx;
xy = pinst->templat.XStep * saved->ctm.xy;
yx = pinst->templat.YStep * saved->ctm.yx;
yy = pinst->templat.YStep * saved->ctm.yy;
/* Adjust the stepping matrix so all coefficients are >= 0. */
if (xx == 0 || yy == 0) { /* We know that both xy and yx are non-zero. */
temp = xx, xx = yx, yx = temp;
temp = xy, xy = yy, yy = temp;
}
if (xx < 0)
xx = -xx, xy = -xy;
if (yy < 0)
yx = -yx, yy = -yy;
/* Now xx > 0, yy > 0. */
pinst->step_matrix.xx = xx;
pinst->step_matrix.xy = xy;
pinst->step_matrix.yx = yx;
pinst->step_matrix.yy = yy;
pinst->step_matrix.tx = saved->ctm.tx;
pinst->step_matrix.ty = saved->ctm.ty;
/*
* Some applications produce patterns that are larger than the page.
* If the bounding box for the pattern is larger than the page. clamp
* the pattern to the page size.
*/
if ((pbbox->q.x - pbbox->p.x > width || pbbox->q.y - pbbox->p.y > height))
code = clamp_pattern_bbox(pinst, pbbox, width,
height, &ctm_only(saved));
return code;
}
| 4,885 |
20,711 | 0 | void kvm_arch_async_page_present(struct kvm_vcpu *vcpu,
struct kvm_async_pf *work)
{
struct x86_exception fault;
trace_kvm_async_pf_ready(work->arch.token, work->gva);
if (is_error_page(work->page))
work->arch.token = ~0; /* broadcast wakeup */
else
kvm_del_async_pf_gfn(vcpu, work->arch.gfn);
if ((vcpu->arch.apf.msr_val & KVM_ASYNC_PF_ENABLED) &&
!apf_put_user(vcpu, KVM_PV_REASON_PAGE_READY)) {
fault.vector = PF_VECTOR;
fault.error_code_valid = true;
fault.error_code = 0;
fault.nested_page_fault = false;
fault.address = work->arch.token;
kvm_inject_page_fault(vcpu, &fault);
}
vcpu->arch.apf.halted = false;
}
| 4,886 |
135,734 | 0 | void InputMethodController::DeleteSurroundingTextInCodePoints(int before,
int after) {
DCHECK_GE(before, 0);
DCHECK_GE(after, 0);
if (!GetEditor().CanEdit())
return;
const PlainTextRange selection_offsets(GetSelectionOffsets());
if (selection_offsets.IsNull())
return;
Element* const root_editable_element =
GetFrame().Selection().RootEditableElementOrDocumentElement();
if (!root_editable_element)
return;
const TextIteratorBehavior& behavior =
TextIteratorBehavior::Builder()
.SetEmitsObjectReplacementCharacter(true)
.Build();
const String& text = PlainText(
EphemeralRange::RangeOfContents(*root_editable_element), behavior);
if (text.Is8Bit())
return DeleteSurroundingText(before, after);
const int selection_start = static_cast<int>(selection_offsets.Start());
const int selection_end = static_cast<int>(selection_offsets.End());
const int before_length =
CalculateBeforeDeletionLengthsInCodePoints(text, before, selection_start);
if (IsInvalidDeletionLength(before_length))
return;
const int after_length =
CalculateAfterDeletionLengthsInCodePoints(text, after, selection_end);
if (IsInvalidDeletionLength(after_length))
return;
return DeleteSurroundingText(before_length, after_length);
}
| 4,887 |
72,469 | 0 | gdImagePtr gdImageCreate (int sx, int sy)
{
int i;
gdImagePtr im;
if (overflow2(sx, sy)) {
return NULL;
}
if (overflow2(sizeof(unsigned char *), sy)) {
return NULL;
}
if (overflow2(sizeof(unsigned char *), sx)) {
return NULL;
}
im = (gdImage *) gdCalloc(1, sizeof(gdImage));
/* Row-major ever since gd 1.3 */
im->pixels = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy);
im->AA_opacity = (unsigned char **) gdMalloc(sizeof(unsigned char *) * sy);
im->polyInts = 0;
im->polyAllocated = 0;
im->brush = 0;
im->tile = 0;
im->style = 0;
for (i = 0; i < sy; i++) {
/* Row-major ever since gd 1.3 */
im->pixels[i] = (unsigned char *) gdCalloc(sx, sizeof(unsigned char));
im->AA_opacity[i] = (unsigned char *) gdCalloc(sx, sizeof(unsigned char));
}
im->sx = sx;
im->sy = sy;
im->colorsTotal = 0;
im->transparent = (-1);
im->interlace = 0;
im->thick = 1;
im->AA = 0;
im->AA_polygon = 0;
for (i = 0; i < gdMaxColors; i++) {
im->open[i] = 1;
im->red[i] = 0;
im->green[i] = 0;
im->blue[i] = 0;
}
im->trueColor = 0;
im->tpixels = 0;
im->cx1 = 0;
im->cy1 = 0;
im->cx2 = im->sx - 1;
im->cy2 = im->sy - 1;
im->interpolation = NULL;
im->interpolation_id = GD_BILINEAR_FIXED;
return im;
}
| 4,888 |
136,000 | 0 | bool ChildProcessSecurityPolicyImpl::CanCreateReadWriteFileSystemFile(
int child_id,
const storage::FileSystemURL& url) {
return HasPermissionsForFileSystemFile(child_id, url,
CREATE_READ_WRITE_FILE_GRANT);
}
| 4,889 |
168,267 | 0 | const char* BrowserView::GetClassName() const {
return kViewClassName;
}
| 4,890 |
165,606 | 0 | bool FrameLoader::ShouldTreatURLAsSrcdocDocument(const KURL& url) const {
if (!url.IsAboutSrcdocURL())
return false;
HTMLFrameOwnerElement* owner_element = frame_->DeprecatedLocalOwner();
if (!IsHTMLIFrameElement(owner_element))
return false;
return owner_element->FastHasAttribute(kSrcdocAttr);
}
| 4,891 |
62,050 | 0 | static int ip_error(struct sk_buff *skb)
{
struct in_device *in_dev = __in_dev_get_rcu(skb->dev);
struct rtable *rt = skb_rtable(skb);
struct inet_peer *peer;
unsigned long now;
struct net *net;
bool send;
int code;
/* IP on this device is disabled. */
if (!in_dev)
goto out;
net = dev_net(rt->dst.dev);
if (!IN_DEV_FORWARD(in_dev)) {
switch (rt->dst.error) {
case EHOSTUNREACH:
__IP_INC_STATS(net, IPSTATS_MIB_INADDRERRORS);
break;
case ENETUNREACH:
__IP_INC_STATS(net, IPSTATS_MIB_INNOROUTES);
break;
}
goto out;
}
switch (rt->dst.error) {
case EINVAL:
default:
goto out;
case EHOSTUNREACH:
code = ICMP_HOST_UNREACH;
break;
case ENETUNREACH:
code = ICMP_NET_UNREACH;
__IP_INC_STATS(net, IPSTATS_MIB_INNOROUTES);
break;
case EACCES:
code = ICMP_PKT_FILTERED;
break;
}
peer = inet_getpeer_v4(net->ipv4.peers, ip_hdr(skb)->saddr,
l3mdev_master_ifindex(skb->dev), 1);
send = true;
if (peer) {
now = jiffies;
peer->rate_tokens += now - peer->rate_last;
if (peer->rate_tokens > ip_rt_error_burst)
peer->rate_tokens = ip_rt_error_burst;
peer->rate_last = now;
if (peer->rate_tokens >= ip_rt_error_cost)
peer->rate_tokens -= ip_rt_error_cost;
else
send = false;
inet_putpeer(peer);
}
if (send)
icmp_send(skb, ICMP_DEST_UNREACH, code, 0);
out: kfree_skb(skb);
return 0;
}
| 4,892 |
5,043 | 0 | static X509 *find_issuer(X509_STORE_CTX *ctx, STACK_OF(X509) *sk, X509 *x)
{
int i;
X509 *issuer;
for (i = 0; i < sk_X509_num(sk); i++) {
issuer = sk_X509_value(sk, i);
if (ctx->check_issued(ctx, x, issuer))
return issuer;
}
return NULL;
}
| 4,893 |
128,083 | 0 | void SynchronousCompositorImpl::OnComputeScroll(
base::TimeTicks animation_time) {
if (need_animate_input_) {
need_animate_input_ = false;
synchronous_input_handler_proxy_->SynchronouslyAnimate(animation_time);
}
}
| 4,894 |
178,911 | 1 | static void ieee80211_if_setup(struct net_device *dev)
{
ether_setup(dev);
dev->netdev_ops = &ieee80211_dataif_ops;
dev->destructor = free_netdev;
}
| 4,895 |
146,246 | 0 | void WebGLRenderingContextBase::ActivateContext(
WebGLRenderingContextBase* context) {
unsigned max_gl_contexts = CurrentMaxGLContexts();
unsigned removed_contexts = 0;
while (ActiveContexts().size() >= max_gl_contexts &&
removed_contexts < max_gl_contexts) {
ForciblyLoseOldestContext(
"WARNING: Too many active WebGL contexts. Oldest context will be "
"lost.");
removed_contexts++;
}
DCHECK(!context->isContextLost());
ActiveContexts().insert(context);
}
| 4,896 |
25,400 | 0 | asmlinkage void do_reserved(struct pt_regs *regs)
{
/*
* Game over - no way to handle this if it ever occurs. Most probably
* caused by a new unknown cpu type or after another deadly
* hard/software error.
*/
show_regs(regs);
panic("Caught reserved exception %ld - should not happen.",
(regs->cp0_cause & 0x7f) >> 2);
}
| 4,897 |
38,399 | 0 | static struct cm_id_private * cm_insert_remote_sidr(struct cm_id_private
*cm_id_priv)
{
struct rb_node **link = &cm.remote_sidr_table.rb_node;
struct rb_node *parent = NULL;
struct cm_id_private *cur_cm_id_priv;
union ib_gid *port_gid = &cm_id_priv->av.dgid;
__be32 remote_id = cm_id_priv->id.remote_id;
while (*link) {
parent = *link;
cur_cm_id_priv = rb_entry(parent, struct cm_id_private,
sidr_id_node);
if (be32_lt(remote_id, cur_cm_id_priv->id.remote_id))
link = &(*link)->rb_left;
else if (be32_gt(remote_id, cur_cm_id_priv->id.remote_id))
link = &(*link)->rb_right;
else {
int cmp;
cmp = memcmp(port_gid, &cur_cm_id_priv->av.dgid,
sizeof *port_gid);
if (cmp < 0)
link = &(*link)->rb_left;
else if (cmp > 0)
link = &(*link)->rb_right;
else
return cur_cm_id_priv;
}
}
rb_link_node(&cm_id_priv->sidr_id_node, parent, link);
rb_insert_color(&cm_id_priv->sidr_id_node, &cm.remote_sidr_table);
return NULL;
}
| 4,898 |
51,526 | 0 | static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
struct sk_buff_head *list)
{
struct sk_buff *next = NULL;
if (!skb_queue_is_last(list, skb))
next = skb_queue_next(list, skb);
__skb_unlink(skb, list);
__kfree_skb(skb);
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRCVCOLLAPSED);
return next;
}
| 4,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.