unique_id
int64 13
189k
| target
int64 0
1
| code
stringlengths 20
241k
| __index_level_0__
int64 0
18.9k
|
---|---|---|---|
79,712 | 0 | static void dump_r_bin_dwarf_debug_abbrev(FILE *f, RBinDwarfDebugAbbrev *da) {
size_t i, j;
ut64 attr_name, attr_form;
if (!f || !da) {
return;
}
for (i = 0; i < da->length; i++) {
int declstag = da->decls[i].tag;
fprintf (f, "Abbreviation Code %"PFMT64d" ", da->decls[i].code);
if (declstag>=0 && declstag < DW_TAG_LAST) {
fprintf (f, "Tag %s ", dwarf_tag_name_encodings[declstag]);
}
fprintf (f, "[%s]\n", da->decls[i].has_children ?
"has children" : "no children");
fprintf (f, "Offset 0x%"PFMT64x"\n", da->decls[i].offset);
if (da->decls[i].specs) {
for (j = 0; j < da->decls[i].length; j++) {
attr_name = da->decls[i].specs[j].attr_name;
attr_form = da->decls[i].specs[j].attr_form;
if (attr_name && attr_form &&
attr_name <= DW_AT_vtable_elem_location &&
attr_form <= DW_FORM_indirect) {
fprintf (f, " %s %s\n",
dwarf_attr_encodings[attr_name],
dwarf_attr_form_encodings[attr_form]);
}
}
}
}
}
| 6,200 |
108,612 | 0 | bool ContainsString(const std::string& haystack, const char* needle) {
std::string::const_iterator it =
std::search(haystack.begin(),
haystack.end(),
needle,
needle + strlen(needle),
base::CaseInsensitiveCompare<char>());
return it != haystack.end();
}
| 6,201 |
170,329 | 0 | status_t SampleTable::findSampleAtTime(
uint64_t req_time, uint64_t scale_num, uint64_t scale_den,
uint32_t *sample_index, uint32_t flags) {
buildSampleEntriesTable();
uint32_t left = 0;
uint32_t right_plus_one = mNumSampleSizes;
while (left < right_plus_one) {
uint32_t center = left + (right_plus_one - left) / 2;
uint64_t centerTime =
getSampleTime(center, scale_num, scale_den);
if (req_time < centerTime) {
right_plus_one = center;
} else if (req_time > centerTime) {
left = center + 1;
} else {
*sample_index = mSampleTimeEntries[center].mSampleIndex;
return OK;
}
}
uint32_t closestIndex = left;
if (closestIndex == mNumSampleSizes) {
if (flags == kFlagAfter) {
return ERROR_OUT_OF_RANGE;
}
flags = kFlagBefore;
} else if (closestIndex == 0) {
if (flags == kFlagBefore) {
}
flags = kFlagAfter;
}
switch (flags) {
case kFlagBefore:
{
--closestIndex;
break;
}
case kFlagAfter:
{
break;
}
default:
{
CHECK(flags == kFlagClosest);
if (abs_difference(
getSampleTime(closestIndex, scale_num, scale_den), req_time) >
abs_difference(
req_time, getSampleTime(closestIndex - 1, scale_num, scale_den))) {
--closestIndex;
}
break;
}
}
*sample_index = mSampleTimeEntries[closestIndex].mSampleIndex;
return OK;
}
| 6,202 |
67,735 | 0 | static ssize_t sock_read_iter(struct kiocb *iocb, struct iov_iter *to)
{
struct file *file = iocb->ki_filp;
struct socket *sock = file->private_data;
struct msghdr msg = {.msg_iter = *to,
.msg_iocb = iocb};
ssize_t res;
if (file->f_flags & O_NONBLOCK)
msg.msg_flags = MSG_DONTWAIT;
if (iocb->ki_pos != 0)
return -ESPIPE;
if (!iov_iter_count(to)) /* Match SYS5 behaviour */
return 0;
res = sock_recvmsg(sock, &msg, msg.msg_flags);
*to = msg.msg_iter;
return res;
}
| 6,203 |
161,905 | 0 | PrintMsg_Print_Params GetCssPrintParams(
blink::WebLocalFrame* frame,
int page_index,
const PrintMsg_Print_Params& page_params) {
PrintMsg_Print_Params page_css_params = page_params;
int dpi = GetDPI(&page_params);
blink::WebDoubleSize page_size_in_pixels(
ConvertUnitDouble(page_params.page_size.width(), dpi, kPixelsPerInch),
ConvertUnitDouble(page_params.page_size.height(), dpi, kPixelsPerInch));
int margin_top_in_pixels =
ConvertUnit(page_params.margin_top, dpi, kPixelsPerInch);
int margin_right_in_pixels = ConvertUnit(
page_params.page_size.width() - page_params.content_size.width() -
page_params.margin_left,
dpi, kPixelsPerInch);
int margin_bottom_in_pixels = ConvertUnit(
page_params.page_size.height() - page_params.content_size.height() -
page_params.margin_top,
dpi, kPixelsPerInch);
int margin_left_in_pixels =
ConvertUnit(page_params.margin_left, dpi, kPixelsPerInch);
if (frame) {
frame->PageSizeAndMarginsInPixels(
page_index, page_size_in_pixels, margin_top_in_pixels,
margin_right_in_pixels, margin_bottom_in_pixels, margin_left_in_pixels);
}
double new_content_width = page_size_in_pixels.Width() -
margin_left_in_pixels - margin_right_in_pixels;
double new_content_height = page_size_in_pixels.Height() -
margin_top_in_pixels - margin_bottom_in_pixels;
if (new_content_width < 1 || new_content_height < 1) {
CHECK(frame != nullptr);
page_css_params = GetCssPrintParams(nullptr, page_index, page_params);
return page_css_params;
}
page_css_params.page_size =
gfx::Size(ConvertUnit(page_size_in_pixels.Width(), kPixelsPerInch, dpi),
ConvertUnit(page_size_in_pixels.Height(), kPixelsPerInch, dpi));
page_css_params.content_size =
gfx::Size(ConvertUnit(new_content_width, kPixelsPerInch, dpi),
ConvertUnit(new_content_height, kPixelsPerInch, dpi));
page_css_params.margin_top =
ConvertUnit(margin_top_in_pixels, kPixelsPerInch, dpi);
page_css_params.margin_left =
ConvertUnit(margin_left_in_pixels, kPixelsPerInch, dpi);
return page_css_params;
}
| 6,204 |
79,834 | 0 | struct inode *ilookup5(struct super_block *sb, unsigned long hashval,
int (*test)(struct inode *, void *), void *data)
{
struct inode *inode;
again:
inode = ilookup5_nowait(sb, hashval, test, data);
if (inode) {
wait_on_inode(inode);
if (unlikely(inode_unhashed(inode))) {
iput(inode);
goto again;
}
}
return inode;
}
| 6,205 |
161,772 | 0 | void CheckConfigsCountForClient(const scoped_refptr<PlatformSensor>& sensor,
PlatformSensor::Client* client,
size_t expected_count) {
auto client_entry = sensor->GetConfigMapForTesting().find(client);
if (sensor->GetConfigMapForTesting().end() == client_entry) {
EXPECT_EQ(0u, expected_count);
return;
}
EXPECT_EQ(expected_count, client_entry->second.size());
}
| 6,206 |
91,313 | 0 | static ssize_t provides_device_sdrs_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct bmc_device *bmc = to_bmc_device(dev);
struct ipmi_device_id id;
int rv;
rv = bmc_get_device_id(NULL, bmc, &id, NULL, NULL);
if (rv)
return rv;
return snprintf(buf, 10, "%u\n", (id.device_revision & 0x80) >> 7);
}
| 6,207 |
174,892 | 0 | status_t Camera2Client::commandStartSmoothZoomL() {
ALOGE("%s: Unimplemented!", __FUNCTION__);
return OK;
}
| 6,208 |
105,555 | 0 | bool SendMouseDragJSONRequest(
AutomationMessageSender* sender,
int browser_index,
int tab_index,
int start_x,
int start_y,
int end_x,
int end_y,
std::string* error_msg) {
DictionaryValue dict;
dict.SetString("command", "WebkitMouseDrag");
dict.SetInteger("windex", browser_index);
dict.SetInteger("tab_index", tab_index);
dict.SetInteger("start_x", start_x);
dict.SetInteger("start_y", start_y);
dict.SetInteger("end_x", end_x);
dict.SetInteger("end_y", end_y);
DictionaryValue reply_dict;
return SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg);
}
| 6,209 |
40,998 | 0 | cmsUInt32Number CMSEXPORT cmsMLUgetWide(const cmsMLU* mlu,
const char LanguageCode[3], const char CountryCode[3],
wchar_t* Buffer, cmsUInt32Number BufferSize)
{
const wchar_t *Wide;
cmsUInt32Number StrLen = 0;
cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode);
cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode);
if (mlu == NULL) return 0;
Wide = _cmsMLUgetWide(mlu, &StrLen, Lang, Cntry, NULL, NULL);
if (Wide == NULL) return 0;
if (Buffer == NULL) return StrLen + sizeof(wchar_t);
if (BufferSize <= 0) return 0;
if (BufferSize < StrLen + sizeof(wchar_t))
StrLen = BufferSize - + sizeof(wchar_t);
memmove(Buffer, Wide, StrLen);
Buffer[StrLen / sizeof(wchar_t)] = 0;
return StrLen + sizeof(wchar_t);
}
| 6,210 |
151,550 | 0 | ResourceLoadPriority ResourceFetcher::ComputeLoadPriority(
Resource::Type type,
const ResourceRequest& resource_request,
ResourcePriority::VisibilityStatus visibility,
FetchParameters::DeferOption defer_option,
FetchParameters::SpeculativePreloadType speculative_preload_type,
bool is_link_preload) {
ResourceLoadPriority priority = TypeToPriority(type);
if (visibility == ResourcePriority::kVisible)
priority = kResourceLoadPriorityHigh;
if (type == Resource::kImage && !is_link_preload)
image_fetched_ = true;
if (type == Resource::kFont && is_link_preload)
priority = kResourceLoadPriorityHigh;
if (FetchParameters::kIdleLoad == defer_option) {
priority = kResourceLoadPriorityVeryLow;
} else if (type == Resource::kScript) {
if (FetchParameters::kLazyLoad == defer_option) {
priority = kResourceLoadPriorityLow;
} else if (speculative_preload_type ==
FetchParameters::SpeculativePreloadType::kInDocument &&
image_fetched_) {
priority = kResourceLoadPriorityMedium;
}
} else if (FetchParameters::kLazyLoad == defer_option) {
priority = kResourceLoadPriorityVeryLow;
} else if (resource_request.GetRequestContext() ==
WebURLRequest::kRequestContextBeacon ||
resource_request.GetRequestContext() ==
WebURLRequest::kRequestContextPing ||
resource_request.GetRequestContext() ==
WebURLRequest::kRequestContextCSPReport) {
priority = kResourceLoadPriorityVeryLow;
}
return std::max(priority, resource_request.Priority());
}
| 6,211 |
181,077 | 1 | aodv_extension(netdissect_options *ndo,
const struct aodv_ext *ep, u_int length)
{
const struct aodv_hello *ah;
switch (ep->type) {
case AODV_EXT_HELLO:
ah = (const struct aodv_hello *)(const void *)ep;
ND_TCHECK(*ah);
if (length < sizeof(struct aodv_hello))
goto trunc;
ND_PRINT((ndo, "\n\text HELLO %ld ms",
(unsigned long)EXTRACT_32BITS(&ah->interval)));
break;
default:
ND_PRINT((ndo, "\n\text %u %u", ep->type, ep->length));
break;
}
return;
trunc:
ND_PRINT((ndo, " [|hello]"));
}
| 6,212 |
166,146 | 0 | void RenderFrameHostImpl::OnJavaScriptExecuteResponse(
int id, const base::ListValue& result) {
const base::Value* result_value;
if (!result.Get(0, &result_value)) {
NOTREACHED() << "Got bad arguments for OnJavaScriptExecuteResponse";
return;
}
auto it = javascript_callbacks_.find(id);
if (it != javascript_callbacks_.end()) {
it->second.Run(result_value);
javascript_callbacks_.erase(it);
} else {
NOTREACHED() << "Received script response for unknown request";
}
}
| 6,213 |
138,117 | 0 | String AXNodeObject::valueDescription() const {
if (!supportsRangeValue())
return String();
return getAOMPropertyOrARIAAttribute(AOMStringProperty::kValueText)
.getString();
}
| 6,214 |
64,669 | 0 | onig_get_options(regex_t* reg)
{
return reg->options;
}
| 6,215 |
143,585 | 0 | OomInterventionMetrics OomInterventionImpl::GetCurrentMemoryMetrics() {
return CrashMemoryMetricsReporterImpl::Instance().GetCurrentMemoryMetrics();
}
| 6,216 |
154,695 | 0 | error::Error GLES2DecoderPassthroughImpl::DoGetProgramInterfaceiv(
GLuint program,
GLenum program_interface,
GLenum pname,
GLsizei bufsize,
GLsizei* length,
GLint* params) {
if (bufsize < 1) {
return error::kOutOfBounds;
}
*length = 1;
api()->glGetProgramInterfaceivFn(GetProgramServiceID(program, resources_),
program_interface, pname, params);
return error::kNoError;
}
| 6,217 |
24,569 | 0 | static void op64_tx_suspend(struct b43_dmaring *ring)
{
b43_dma_write(ring, B43_DMA64_TXCTL, b43_dma_read(ring, B43_DMA64_TXCTL)
| B43_DMA64_TXSUSPEND);
}
| 6,218 |
33,055 | 0 | static int sctp_setsockopt_mappedv4(struct sock *sk, char __user *optval, unsigned int optlen)
{
int val;
struct sctp_sock *sp = sctp_sk(sk);
if (optlen < sizeof(int))
return -EINVAL;
if (get_user(val, (int __user *)optval))
return -EFAULT;
if (val)
sp->v4mapped = 1;
else
sp->v4mapped = 0;
return 0;
}
| 6,219 |
23,886 | 0 | static int is_valid_veth_mtu(int new_mtu)
{
return new_mtu >= MIN_MTU && new_mtu <= MAX_MTU;
}
| 6,220 |
155,703 | 0 | void TestPresentationLocksFocusImpl(WebXrVrBrowserTestBase* t,
std::string filename) {
t->LoadUrlAndAwaitInitialization(t->GetFileUrlForHtmlTestFile(filename));
t->EnterSessionWithUserGestureOrFail();
t->ExecuteStepAndWait("stepSetupFocusLoss()");
t->EndTest();
}
| 6,221 |
160,316 | 0 | void Run() {
if (!loader_)
return;
ExecutionContext& context = loader_->GetElement()->GetDocument();
probe::AsyncTask async_task(&context, this);
if (script_state_->ContextIsValid()) {
ScriptState::Scope scope(script_state_.get());
loader_->DoUpdateFromElement(should_bypass_main_world_csp_,
update_behavior_, request_url_,
referrer_policy_);
} else {
loader_->DoUpdateFromElement(should_bypass_main_world_csp_,
update_behavior_, request_url_,
referrer_policy_);
}
}
| 6,222 |
127,374 | 0 | void StyleResolver::collectViewportRules()
{
viewportStyleResolver()->collectViewportRules(CSSDefaultStyleSheets::defaultStyle, ViewportStyleResolver::UserAgentOrigin);
if (document().isMobileDocument())
viewportStyleResolver()->collectViewportRules(CSSDefaultStyleSheets::xhtmlMobileProfileStyle(), ViewportStyleResolver::UserAgentOrigin);
if (ScopedStyleResolver* scopedResolver = m_styleTree.scopedStyleResolverForDocument())
scopedResolver->collectViewportRulesTo(this);
viewportStyleResolver()->resolve();
}
| 6,223 |
168,423 | 0 | bool TestBrowserWindow::IsVisible() const {
return true;
}
| 6,224 |
47,599 | 0 | static inline int ap_instructions_available(void)
{
register unsigned long reg0 asm ("0") = AP_MKQID(0,0);
register unsigned long reg1 asm ("1") = -ENODEV;
register unsigned long reg2 asm ("2") = 0UL;
asm volatile(
" .long 0xb2af0000\n" /* PQAP(TAPQ) */
"0: la %1,0\n"
"1:\n"
EX_TABLE(0b, 1b)
: "+d" (reg0), "+d" (reg1), "+d" (reg2) : : "cc" );
return reg1;
}
| 6,225 |
112,467 | 0 | HTMLCanvasElement* Document::getCSSCanvasElement(const String& name)
{
RefPtr<HTMLCanvasElement>& element = m_cssCanvasElements.add(name, 0).iterator->value;
if (!element)
element = HTMLCanvasElement::create(this);
return element.get();
}
| 6,226 |
134,006 | 0 | void ExtensionAppItem::ExecuteLaunchCommand(int event_flags) {
Launch(event_flags);
}
| 6,227 |
113,063 | 0 | const GURL& DownloadItemImpl::GetURL() const {
return url_chain_.empty() ?
GURL::EmptyGURL() : url_chain_.back();
}
| 6,228 |
80,304 | 0 | GF_Err padb_Write(GF_Box *s, GF_BitStream *bs)
{
u32 i;
GF_Err e;
GF_PaddingBitsBox *ptr = (GF_PaddingBitsBox *) s;
e = gf_isom_full_box_write(s, bs);
if (e) return e;
gf_bs_write_int(bs, ptr->SampleCount, 32);
for (i=0 ; i<ptr->SampleCount; i += 2) {
gf_bs_write_int(bs, 0, 1);
if (i+1 < ptr->SampleCount) {
gf_bs_write_int(bs, ptr->padbits[i+1], 3);
} else {
gf_bs_write_int(bs, 0, 3);
}
gf_bs_write_int(bs, 0, 1);
gf_bs_write_int(bs, ptr->padbits[i], 3);
}
return GF_OK;
}
| 6,229 |
150,316 | 0 | void PasswordAutofillAgent::LogPrefilledUsernameFillOutcome(
PrefilledUsernameFillOutcome outcome) {
if (prefilled_username_metrics_logged_)
return;
prefilled_username_metrics_logged_ = true;
UMA_HISTOGRAM_ENUMERATION("PasswordManager.PrefilledUsernameFillOutcome",
outcome);
}
| 6,230 |
88,241 | 0 | XML_UseParserAsHandlerArg(XML_Parser parser) {
if (parser != NULL)
parser->m_handlerArg = parser;
}
| 6,231 |
103,059 | 0 | explicit TabStripDummyDelegate(TabContentsWrapper* dummy)
: dummy_contents_(dummy), can_close_(true), run_unload_(false) {}
| 6,232 |
169,814 | 0 | exsltFuncResultComp (xsltStylesheetPtr style, xmlNodePtr inst,
xsltTransformFunction function) {
xmlNodePtr test;
xmlChar *sel;
exsltFuncResultPreComp *ret;
if ((style == NULL) || (inst == NULL) || (inst->type != XML_ELEMENT_NODE))
return (NULL);
/*
* "Validity" checking
*/
/* it is an error to have any following sibling elements aside
* from the xsl:fallback element.
*/
for (test = inst->next; test != NULL; test = test->next) {
if (test->type != XML_ELEMENT_NODE)
continue;
if (IS_XSLT_ELEM(test) && IS_XSLT_NAME(test, "fallback"))
continue;
xsltGenericError(xsltGenericErrorContext,
"exsltFuncResultElem: only xsl:fallback is "
"allowed to follow func:result\n");
style->errors++;
return (NULL);
}
/* it is an error for a func:result element to not be a descendant
* of func:function.
* it is an error if a func:result occurs within a func:result
* element.
* it is an error if instanciating the content of a variable
* binding element (i.e. xsl:variable, xsl:param) results in the
* instanciation of a func:result element.
*/
for (test = inst->parent; test != NULL; test = test->parent) {
if (IS_XSLT_ELEM(test) &&
IS_XSLT_NAME(test, "stylesheet")) {
xsltGenericError(xsltGenericErrorContext,
"func:result element not a descendant "
"of a func:function\n");
style->errors++;
return (NULL);
}
if ((test->ns != NULL) &&
(xmlStrEqual(test->ns->href, EXSLT_FUNCTIONS_NAMESPACE))) {
if (xmlStrEqual(test->name, (const xmlChar *) "function")) {
break;
}
if (xmlStrEqual(test->name, (const xmlChar *) "result")) {
xsltGenericError(xsltGenericErrorContext,
"func:result element not allowed within"
" another func:result element\n");
style->errors++;
return (NULL);
}
}
if (IS_XSLT_ELEM(test) &&
(IS_XSLT_NAME(test, "variable") ||
IS_XSLT_NAME(test, "param"))) {
xsltGenericError(xsltGenericErrorContext,
"func:result element not allowed within"
" a variable binding element\n");
style->errors++;
return (NULL);
}
}
/*
* Precomputation
*/
ret = (exsltFuncResultPreComp *)
xmlMalloc (sizeof(exsltFuncResultPreComp));
if (ret == NULL) {
xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"exsltFuncResultComp : malloc failed\n");
style->errors++;
return (NULL);
}
memset(ret, 0, sizeof(exsltFuncResultPreComp));
xsltInitElemPreComp ((xsltElemPreCompPtr) ret, style, inst, function,
(xsltElemPreCompDeallocator) exsltFreeFuncResultPreComp);
ret->select = NULL;
/*
* Precompute the select attribute
*/
sel = xmlGetNsProp(inst, (const xmlChar *) "select", NULL);
if (sel != NULL) {
ret->select = xmlXPathCompile (sel);
xmlFree(sel);
}
/*
* Precompute the namespace list
*/
ret->nsList = xmlGetNsList(inst->doc, inst);
if (ret->nsList != NULL) {
int i = 0;
while (ret->nsList[i] != NULL)
i++;
ret->nsNr = i;
}
return ((xsltElemPreCompPtr) ret);
}
| 6,233 |
70,999 | 0 | cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
{
cmsUInt32Number nTabSize;
cmsPipeline* NewLUT = (cmsPipeline*) Ptr;
cmsStage* mpe;
_cmsStageToneCurvesData* PreMPE = NULL, *PostMPE = NULL;
_cmsStageMatrixData* MatMPE = NULL;
_cmsStageCLutData* clut = NULL;
int i, InputChannels, OutputChannels, clutPoints;
mpe = NewLUT -> Elements;
if (mpe != NULL && mpe ->Type == cmsSigMatrixElemType) {
MatMPE = (_cmsStageMatrixData*) mpe ->Data;
mpe = mpe -> Next;
}
if (mpe != NULL && mpe ->Type == cmsSigCurveSetElemType) {
PreMPE = (_cmsStageToneCurvesData*) mpe ->Data;
mpe = mpe -> Next;
}
if (mpe != NULL && mpe ->Type == cmsSigCLutElemType) {
clut = (_cmsStageCLutData*) mpe -> Data;
mpe = mpe ->Next;
}
if (mpe != NULL && mpe ->Type == cmsSigCurveSetElemType) {
PostMPE = (_cmsStageToneCurvesData*) mpe ->Data;
mpe = mpe -> Next;
}
if (mpe != NULL) {
cmsSignalError(mpe->ContextID, cmsERROR_UNKNOWN_EXTENSION, "LUT is not suitable to be saved as LUT16");
return FALSE;
}
InputChannels = cmsPipelineInputChannels(NewLUT);
OutputChannels = cmsPipelineOutputChannels(NewLUT);
if (clut == NULL)
clutPoints = 0;
else
clutPoints = clut->Params->nSamples[0];
if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) InputChannels)) return FALSE;
if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) OutputChannels)) return FALSE;
if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE;
if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding
if (MatMPE != NULL) {
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[0])) return FALSE;
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[1])) return FALSE;
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[2])) return FALSE;
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[3])) return FALSE;
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[4])) return FALSE;
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[5])) return FALSE;
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[6])) return FALSE;
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[7])) return FALSE;
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[8])) return FALSE;
}
else {
if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
}
if (PreMPE != NULL) {
if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) PreMPE ->TheCurves[0]->nEntries)) return FALSE;
} else {
if (!_cmsWriteUInt16Number(io, 2)) return FALSE;
}
if (PostMPE != NULL) {
if (!_cmsWriteUInt16Number(io, (cmsUInt16Number) PostMPE ->TheCurves[0]->nEntries)) return FALSE;
} else {
if (!_cmsWriteUInt16Number(io, 2)) return FALSE;
}
if (PreMPE != NULL) {
if (!Write16bitTables(self ->ContextID, io, PreMPE)) return FALSE;
}
else {
for (i=0; i < InputChannels; i++) {
if (!_cmsWriteUInt16Number(io, 0)) return FALSE;
if (!_cmsWriteUInt16Number(io, 0xffff)) return FALSE;
}
}
nTabSize = uipow(OutputChannels, clutPoints, InputChannels);
if (nTabSize == (cmsUInt32Number) -1) return FALSE;
if (nTabSize > 0) {
if (clut != NULL) {
if (!_cmsWriteUInt16Array(io, nTabSize, clut->Tab.T)) return FALSE;
}
}
if (PostMPE != NULL) {
if (!Write16bitTables(self ->ContextID, io, PostMPE)) return FALSE;
}
else {
for (i=0; i < OutputChannels; i++) {
if (!_cmsWriteUInt16Number(io, 0)) return FALSE;
if (!_cmsWriteUInt16Number(io, 0xffff)) return FALSE;
}
}
return TRUE;
cmsUNUSED_PARAMETER(nItems);
}
| 6,234 |
122,441 | 0 | void HTMLTextAreaElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == rowsAttr) {
int rows = value.toInt();
if (rows <= 0)
rows = defaultRows;
if (m_rows != rows) {
m_rows = rows;
if (renderer())
renderer()->setNeedsLayoutAndPrefWidthsRecalc();
}
} else if (name == colsAttr) {
int cols = value.toInt();
if (cols <= 0)
cols = defaultCols;
if (m_cols != cols) {
m_cols = cols;
if (renderer())
renderer()->setNeedsLayoutAndPrefWidthsRecalc();
}
} else if (name == wrapAttr) {
WrapMethod wrap;
if (equalIgnoringCase(value, "physical") || equalIgnoringCase(value, "hard") || equalIgnoringCase(value, "on"))
wrap = HardWrap;
else if (equalIgnoringCase(value, "off"))
wrap = NoWrap;
else
wrap = SoftWrap;
if (wrap != m_wrap) {
m_wrap = wrap;
if (renderer())
renderer()->setNeedsLayoutAndPrefWidthsRecalc();
}
} else if (name == accesskeyAttr) {
} else if (name == maxlengthAttr)
setNeedsValidityCheck();
else
HTMLTextFormControlElement::parseAttribute(name, value);
}
| 6,235 |
102,537 | 0 | virtual void RunCallback() {
callback_->Run(error_code(), base::PassPlatformFile(&file_handle_),
file_path_);
delete callback_;
}
| 6,236 |
137,464 | 0 | bool MessageLoop::SweepDelayedWorkQueueAndReturnTrueIfStillHasWork() {
while (!delayed_work_queue_.empty()) {
const PendingTask& pending_task = delayed_work_queue_.top();
if (!pending_task.task.IsCancelled())
return true;
#if defined(OS_WIN)
DecrementHighResTaskCountIfNeeded(pending_task);
#endif
delayed_work_queue_.pop();
}
return false;
}
| 6,237 |
163,242 | 0 | const std::vector<GURL>& redirected_navigation_urls() const {
return redirected_navigation_urls_;
}
| 6,238 |
156,368 | 0 | bool DebuggerAttachFunction::RunAsync() {
std::unique_ptr<Attach::Params> params(Attach::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
CopyDebuggee(&debuggee_, params->target);
if (!InitAgentHost())
return false;
if (!DevToolsAgentHost::IsSupportedProtocolVersion(
params->required_version)) {
error_ = ErrorUtils::FormatErrorMessage(
debugger_api_constants::kProtocolVersionNotSupportedError,
params->required_version);
return false;
}
if (FindClientHost()) {
FormatErrorMessage(debugger_api_constants::kAlreadyAttachedError);
return false;
}
auto host = std::make_unique<ExtensionDevToolsClientHost>(
GetProfile(), agent_host_.get(), extension(), debuggee_);
if (!host->Attach()) {
FormatErrorMessage(debugger_api_constants::kRestrictedError);
return false;
}
host.release(); // An attached client host manages its own lifetime.
SendResponse(true);
return true;
}
| 6,239 |
20,090 | 0 | receive_packet (struct net_device *dev)
{
struct netdev_private *np = netdev_priv(dev);
int entry = np->cur_rx % RX_RING_SIZE;
int cnt = 30;
/* If RFDDone, FrameStart and FrameEnd set, there is a new packet in. */
while (1) {
struct netdev_desc *desc = &np->rx_ring[entry];
int pkt_len;
u64 frame_status;
if (!(desc->status & cpu_to_le64(RFDDone)) ||
!(desc->status & cpu_to_le64(FrameStart)) ||
!(desc->status & cpu_to_le64(FrameEnd)))
break;
/* Chip omits the CRC. */
frame_status = le64_to_cpu(desc->status);
pkt_len = frame_status & 0xffff;
if (--cnt < 0)
break;
/* Update rx error statistics, drop packet. */
if (frame_status & RFS_Errors) {
np->stats.rx_errors++;
if (frame_status & (RxRuntFrame | RxLengthError))
np->stats.rx_length_errors++;
if (frame_status & RxFCSError)
np->stats.rx_crc_errors++;
if (frame_status & RxAlignmentError && np->speed != 1000)
np->stats.rx_frame_errors++;
if (frame_status & RxFIFOOverrun)
np->stats.rx_fifo_errors++;
} else {
struct sk_buff *skb;
/* Small skbuffs for short packets */
if (pkt_len > copy_thresh) {
pci_unmap_single (np->pdev,
desc_to_dma(desc),
np->rx_buf_sz,
PCI_DMA_FROMDEVICE);
skb_put (skb = np->rx_skbuff[entry], pkt_len);
np->rx_skbuff[entry] = NULL;
} else if ((skb = netdev_alloc_skb_ip_align(dev, pkt_len))) {
pci_dma_sync_single_for_cpu(np->pdev,
desc_to_dma(desc),
np->rx_buf_sz,
PCI_DMA_FROMDEVICE);
skb_copy_to_linear_data (skb,
np->rx_skbuff[entry]->data,
pkt_len);
skb_put (skb, pkt_len);
pci_dma_sync_single_for_device(np->pdev,
desc_to_dma(desc),
np->rx_buf_sz,
PCI_DMA_FROMDEVICE);
}
skb->protocol = eth_type_trans (skb, dev);
#if 0
/* Checksum done by hw, but csum value unavailable. */
if (np->pdev->pci_rev_id >= 0x0c &&
!(frame_status & (TCPError | UDPError | IPError))) {
skb->ip_summed = CHECKSUM_UNNECESSARY;
}
#endif
netif_rx (skb);
}
entry = (entry + 1) % RX_RING_SIZE;
}
spin_lock(&np->rx_lock);
np->cur_rx = entry;
/* Re-allocate skbuffs to fill the descriptor ring */
entry = np->old_rx;
while (entry != np->cur_rx) {
struct sk_buff *skb;
/* Dropped packets don't need to re-allocate */
if (np->rx_skbuff[entry] == NULL) {
skb = netdev_alloc_skb_ip_align(dev, np->rx_buf_sz);
if (skb == NULL) {
np->rx_ring[entry].fraginfo = 0;
printk (KERN_INFO
"%s: receive_packet: "
"Unable to re-allocate Rx skbuff.#%d\n",
dev->name, entry);
break;
}
np->rx_skbuff[entry] = skb;
np->rx_ring[entry].fraginfo =
cpu_to_le64 (pci_map_single
(np->pdev, skb->data, np->rx_buf_sz,
PCI_DMA_FROMDEVICE));
}
np->rx_ring[entry].fraginfo |=
cpu_to_le64((u64)np->rx_buf_sz << 48);
np->rx_ring[entry].status = 0;
entry = (entry + 1) % RX_RING_SIZE;
}
np->old_rx = entry;
spin_unlock(&np->rx_lock);
return 0;
}
| 6,240 |
166,162 | 0 | void RenderFrameHostImpl::UpdateSubresourceLoaderFactories() {
DCHECK(base::FeatureList::IsEnabled(network::features::kNetworkService));
if (!has_committed_any_navigation_)
return;
DCHECK(!IsOutOfProcessNetworkService() ||
network_service_connection_error_handler_holder_.is_bound());
network::mojom::URLLoaderFactoryPtrInfo default_factory_info;
bool bypass_redirect_checks = false;
if (recreate_default_url_loader_factory_after_network_service_crash_) {
bypass_redirect_checks = CreateNetworkServiceDefaultFactoryAndObserve(
last_committed_origin_, mojo::MakeRequest(&default_factory_info));
}
std::unique_ptr<URLLoaderFactoryBundleInfo> subresource_loader_factories =
std::make_unique<URLLoaderFactoryBundleInfo>(
std::move(default_factory_info),
URLLoaderFactoryBundleInfo::SchemeMap(),
CreateInitiatorSpecificURLLoaderFactories(
initiators_requiring_separate_url_loader_factory_),
bypass_redirect_checks);
GetNavigationControl()->UpdateSubresourceLoaderFactories(
std::move(subresource_loader_factories));
}
| 6,241 |
151,646 | 0 | PaymentRequestSettingsLinkTest()
: PaymentRequestBrowserTestBase(
"/payment_request_no_shipping_test.html") {}
| 6,242 |
165,727 | 0 | bool ConfigureWebsocketOverHttp2(
const base::CommandLine& command_line,
const VariationParameters& http2_trial_params) {
if (command_line.HasSwitch(switches::kEnableWebsocketOverHttp2))
return true;
const std::string websocket_value =
GetVariationParam(http2_trial_params, "websocket_over_http2");
return websocket_value == "true";
}
| 6,243 |
133,659 | 0 | static inline void notifyTargetAboutAnimValChange(SVGElement* targetElement, const QualifiedName& attributeName)
{
ASSERT_WITH_SECURITY_IMPLICATION(!targetElement->m_deletionHasBegun);
targetElement->svgAttributeChanged(attributeName);
}
| 6,244 |
43,383 | 0 | void CLASS stretch()
{
ushort newdim, (*img)[4], *pix0, *pix1;
int row, col, c;
double rc, frac;
if (pixel_aspect == 1) return;
dcraw_message (DCRAW_VERBOSE,_("Stretching the image...\n"));
if (pixel_aspect < 1) {
newdim = height / pixel_aspect + 0.5;
img = (ushort (*)[4]) calloc (width*newdim, sizeof *img);
merror (img, "stretch()");
for (rc=row=0; row < newdim; row++, rc+=pixel_aspect) {
frac = rc - (c = rc);
pix0 = pix1 = image[c*width];
if (c+1 < height) pix1 += width*4;
for (col=0; col < width; col++, pix0+=4, pix1+=4)
FORCC img[row*width+col][c] = pix0[c]*(1-frac) + pix1[c]*frac + 0.5;
}
height = newdim;
} else {
newdim = width * pixel_aspect + 0.5;
img = (ushort (*)[4]) calloc (height*newdim, sizeof *img);
merror (img, "stretch()");
for (rc=col=0; col < newdim; col++, rc+=1/pixel_aspect) {
frac = rc - (c = rc);
pix0 = pix1 = image[c];
if (c+1 < width) pix1 += 4;
for (row=0; row < height; row++, pix0+=width*4, pix1+=width*4)
FORCC img[row*newdim+col][c] = pix0[c]*(1-frac) + pix1[c]*frac + 0.5;
}
width = newdim;
}
free (image);
image = img;
}
| 6,245 |
55,509 | 0 | static void cpu_cgroup_fork(struct task_struct *task)
{
sched_move_task(task);
}
| 6,246 |
11,240 | 0 | zval *php_snmp_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
{
zval tmp_member;
zval *retval;
php_snmp_object *obj;
php_snmp_prop_handler *hnd;
int ret;
obj = Z_SNMP_P(object);
if (Z_TYPE_P(member) != IS_STRING) {
ZVAL_COPY(&tmp_member, member);
convert_to_string(&tmp_member);
member = &tmp_member;
}
hnd = zend_hash_find_ptr(&php_snmp_properties, Z_STR_P(member));
if (hnd && hnd->read_func) {
ret = hnd->read_func(obj, rv);
if (ret == SUCCESS) {
retval = rv;
} else {
retval = &EG(uninitialized_zval);
}
} else {
zend_object_handlers * std_hnd = zend_get_std_object_handlers();
retval = std_hnd->read_property(object, member, type, cache_slot, rv);
}
if (member == &tmp_member) {
zval_ptr_dtor(member);
}
return retval;
}
| 6,247 |
12,923 | 0 | int nlmsg_ok(const struct nlmsghdr *nlh, int remaining)
{
return (remaining >= (int)sizeof(struct nlmsghdr) &&
nlh->nlmsg_len >= sizeof(struct nlmsghdr) &&
nlh->nlmsg_len <= remaining);
}
| 6,248 |
159,779 | 0 | PermissionsBubbleDialogDelegateView::PermissionsBubbleDialogDelegateView(
PermissionPromptImpl* owner,
const std::vector<PermissionRequest*>& requests)
: owner_(owner), persist_checkbox_(nullptr) {
DCHECK(!requests.empty());
set_close_on_deactivate(false);
set_arrow(kPermissionAnchorArrow);
#if defined(OS_MACOSX)
if (base::FeatureList::IsEnabled(features::kMacRTL))
set_mirror_arrow_in_rtl(true);
#endif
ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
SetLayoutManager(new views::BoxLayout(
views::BoxLayout::kVertical, gfx::Insets(),
provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)));
display_origin_ = url_formatter::FormatUrlForSecurityDisplay(
requests[0]->GetOrigin(),
url_formatter::SchemeDisplay::OMIT_CRYPTOGRAPHIC);
bool show_persistence_toggle = true;
for (size_t index = 0; index < requests.size(); index++) {
views::View* label_container = new views::View();
int indent =
provider->GetDistanceMetric(DISTANCE_SUBSECTION_HORIZONTAL_INDENT);
label_container->SetLayoutManager(new views::BoxLayout(
views::BoxLayout::kHorizontal, gfx::Insets(0, indent),
provider->GetDistanceMetric(views::DISTANCE_RELATED_LABEL_HORIZONTAL)));
views::ImageView* icon = new views::ImageView();
const gfx::VectorIcon& vector_id = requests[index]->GetIconId();
icon->SetImage(
gfx::CreateVectorIcon(vector_id, kIconSize, gfx::kChromeIconGrey));
icon->SetTooltipText(base::string16()); // Redundant with the text fragment
label_container->AddChildView(icon);
views::Label* label =
new views::Label(requests.at(index)->GetMessageTextFragment());
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
label_container->AddChildView(label);
AddChildView(label_container);
show_persistence_toggle = show_persistence_toggle &&
requests[index]->ShouldShowPersistenceToggle();
}
if (show_persistence_toggle) {
persist_checkbox_ = new views::Checkbox(
l10n_util::GetStringUTF16(IDS_PERMISSIONS_BUBBLE_PERSIST_TEXT));
persist_checkbox_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
persist_checkbox_->SetChecked(true);
AddChildView(persist_checkbox_);
}
chrome::RecordDialogCreation(chrome::DialogIdentifier::PERMISSIONS);
}
| 6,249 |
22,966 | 0 | struct nfs_seqid *nfs_alloc_seqid(struct nfs_seqid_counter *counter)
{
struct nfs_seqid *new;
new = kmalloc(sizeof(*new), GFP_KERNEL);
if (new != NULL) {
new->sequence = counter;
INIT_LIST_HEAD(&new->list);
}
return new;
}
| 6,250 |
91,309 | 0 | static int panic_event(struct notifier_block *this,
unsigned long event,
void *ptr)
{
struct ipmi_smi *intf;
struct ipmi_user *user;
if (has_panicked)
return NOTIFY_DONE;
has_panicked = 1;
/* For every registered interface, set it to run to completion. */
list_for_each_entry_rcu(intf, &ipmi_interfaces, link) {
if (!intf->handlers || intf->intf_num == -1)
/* Interface is not ready. */
continue;
if (!intf->handlers->poll)
continue;
/*
* If we were interrupted while locking xmit_msgs_lock or
* waiting_rcv_msgs_lock, the corresponding list may be
* corrupted. In this case, drop items on the list for
* the safety.
*/
if (!spin_trylock(&intf->xmit_msgs_lock)) {
INIT_LIST_HEAD(&intf->xmit_msgs);
INIT_LIST_HEAD(&intf->hp_xmit_msgs);
} else
spin_unlock(&intf->xmit_msgs_lock);
if (!spin_trylock(&intf->waiting_rcv_msgs_lock))
INIT_LIST_HEAD(&intf->waiting_rcv_msgs);
else
spin_unlock(&intf->waiting_rcv_msgs_lock);
intf->run_to_completion = 1;
if (intf->handlers->set_run_to_completion)
intf->handlers->set_run_to_completion(intf->send_info,
1);
list_for_each_entry_rcu(user, &intf->users, link) {
if (user->handler->ipmi_panic_handler)
user->handler->ipmi_panic_handler(
user->handler_data);
}
send_panic_events(intf, ptr);
}
return NOTIFY_DONE;
}
| 6,251 |
141,874 | 0 | void AutofillPopupBaseView::OnGestureEvent(ui::GestureEvent* event) {
switch (event->type()) {
case ui::ET_GESTURE_TAP_DOWN:
case ui::ET_GESTURE_SCROLL_BEGIN:
case ui::ET_GESTURE_SCROLL_UPDATE:
if (HitTestPoint(event->location()))
SetSelection(event->location());
else
ClearSelection();
break;
case ui::ET_GESTURE_TAP:
case ui::ET_GESTURE_SCROLL_END:
if (HitTestPoint(event->location()))
AcceptSelection(event->location());
else
ClearSelection();
break;
case ui::ET_GESTURE_TAP_CANCEL:
case ui::ET_SCROLL_FLING_START:
ClearSelection();
break;
default:
return;
}
event->SetHandled();
}
| 6,252 |
81,824 | 0 | static INLINE void IncrementX963KdfCounter(byte* inOutCtr)
{
int i;
/* in network byte order so start at end and work back */
for (i = 3; i >= 0; i--) {
if (++inOutCtr[i]) /* we're done unless we overflow */
return;
}
}
| 6,253 |
179,239 | 1 | static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg)
{
struct crypto_report_cipher rcipher;
snprintf(rcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "cipher");
rcipher.blocksize = alg->cra_blocksize;
rcipher.min_keysize = alg->cra_cipher.cia_min_keysize;
rcipher.max_keysize = alg->cra_cipher.cia_max_keysize;
if (nla_put(skb, CRYPTOCFGA_REPORT_CIPHER,
sizeof(struct crypto_report_cipher), &rcipher))
goto nla_put_failure;
return 0;
nla_put_failure:
return -EMSGSIZE;
}
| 6,254 |
104,609 | 0 | ExtensionResource Extension::GetIconResource(
int size, ExtensionIconSet::MatchType match_type) const {
std::string path = icons().Get(size, match_type);
if (path.empty())
return ExtensionResource();
return GetResource(path);
}
| 6,255 |
165,881 | 0 | RenderWidgetFullscreenPepper* RenderFrameImpl::CreatePepperFullscreenContainer(
PepperPluginInstanceImpl* plugin) {
blink::WebURL main_frame_url;
WebFrame* main_frame = render_view()->webview()->MainFrame();
if (main_frame->IsWebLocalFrame())
main_frame_url = main_frame->ToWebLocalFrame()->GetDocument().Url();
mojom::WidgetPtr widget_channel;
mojom::WidgetRequest widget_channel_request =
mojo::MakeRequest(&widget_channel);
int32_t fullscreen_widget_routing_id = MSG_ROUTING_NONE;
if (!RenderThreadImpl::current_render_message_filter()
->CreateFullscreenWidget(render_view()->GetRoutingID(),
std::move(widget_channel),
&fullscreen_widget_routing_id)) {
return nullptr;
}
RenderWidget::ShowCallback show_callback =
base::BindOnce(&RenderViewImpl::ShowCreatedFullscreenWidget,
render_view()->GetWeakPtr());
RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create(
fullscreen_widget_routing_id, std::move(show_callback),
GetRenderWidget()->compositor_deps(), plugin, std::move(main_frame_url),
GetRenderWidget()->GetWebScreenInfo(), std::move(widget_channel_request));
widget->Show(blink::kWebNavigationPolicyCurrentTab);
return widget;
}
| 6,256 |
47,424 | 0 | static inline struct aes_ctx *aes_ctx(struct crypto_tfm *tfm)
{
return aes_ctx_common(crypto_tfm_ctx(tfm));
}
| 6,257 |
68,008 | 0 | static MagickBooleanType DecodeImage(const unsigned char *compressed_pixels,
const size_t length,unsigned char *pixels,size_t extent)
{
register const unsigned char
*p;
register unsigned char
*q;
ssize_t
count;
unsigned char
byte;
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(compressed_pixels != (unsigned char *) NULL);
assert(pixels != (unsigned char *) NULL);
p=compressed_pixels;
q=pixels;
while (((size_t) (p-compressed_pixels) < length) &&
((size_t) (q-pixels) < extent))
{
byte=(*p++);
if (byte != 128U)
*q++=byte;
else
{
/*
Runlength-encoded packet: <count><byte>.
*/
if (((size_t) (p-compressed_pixels) >= length))
break;
count=(*p++);
if (count > 0)
{
if (((size_t) (p-compressed_pixels) >= length))
break;
byte=(*p++);
}
while ((count >= 0) && ((size_t) (q-pixels) < extent))
{
*q++=byte;
count--;
}
}
}
return(((size_t) (q-pixels) == extent) ? MagickTrue : MagickFalse);
}
| 6,258 |
160,258 | 0 | ServiceWorkerLazyBackgroundTest()
: ServiceWorkerTest(
version_info::Channel::UNKNOWN) {}
| 6,259 |
188,398 | 1 | unsigned long long Chapters::Atom::GetUID() const
{
return m_uid;
}
| 6,260 |
185,933 | 1 | void V8Window::namedPropertyGetterCustom(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info)
{
if (!name->IsString())
return;
auto nameString = name.As<v8::String>();
LocalDOMWindow* window = toLocalDOMWindow(V8Window::toImpl(info.Holder()));
if (!window)
return;
LocalFrame* frame = window->frame();
if (!frame)
return;
AtomicString propName = toCoreAtomicString(nameString);
Frame* child = frame->tree().scopedChild(propName);
if (child) {
v8SetReturnValueFast(info, child->domWindow(), window);
return;
}
if (!info.Holder()->GetRealNamedProperty(nameString).IsEmpty())
return;
Document* doc = frame->document();
if (doc && doc->isHTMLDocument()) {
if (toHTMLDocument(doc)->hasNamedItem(propName) || doc->hasElementWithId(propName)) {
RefPtrWillBeRawPtr<HTMLCollection> items = doc->windowNamedItems(propName);
if (!items->isEmpty()) {
if (items->hasExactlyOneItem()) {
v8SetReturnValueFast(info, items->item(0), window);
return;
}
v8SetReturnValueFast(info, items.release(), window);
return;
}
}
}
}
| 6,261 |
47,847 | 0 | static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream,
unsigned int in_interrupt)
{
struct snd_pcm_runtime *runtime = substream->runtime;
snd_pcm_uframes_t pos;
snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_base;
snd_pcm_sframes_t hdelta, delta;
unsigned long jdelta;
unsigned long curr_jiffies;
struct timespec curr_tstamp;
struct timespec audio_tstamp;
int crossed_boundary = 0;
old_hw_ptr = runtime->status->hw_ptr;
/*
* group pointer, time and jiffies reads to allow for more
* accurate correlations/corrections.
* The values are stored at the end of this routine after
* corrections for hw_ptr position
*/
pos = substream->ops->pointer(substream);
curr_jiffies = jiffies;
if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) {
if ((substream->ops->get_time_info) &&
(runtime->audio_tstamp_config.type_requested != SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)) {
substream->ops->get_time_info(substream, &curr_tstamp,
&audio_tstamp,
&runtime->audio_tstamp_config,
&runtime->audio_tstamp_report);
/* re-test in case tstamp type is not supported in hardware and was demoted to DEFAULT */
if (runtime->audio_tstamp_report.actual_type == SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)
snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp);
} else
snd_pcm_gettime(runtime, (struct timespec *)&curr_tstamp);
}
if (pos == SNDRV_PCM_POS_XRUN) {
xrun(substream);
return -EPIPE;
}
if (pos >= runtime->buffer_size) {
if (printk_ratelimit()) {
char name[16];
snd_pcm_debug_name(substream, name, sizeof(name));
pcm_err(substream->pcm,
"invalid position: %s, pos = %ld, buffer size = %ld, period size = %ld\n",
name, pos, runtime->buffer_size,
runtime->period_size);
}
pos = 0;
}
pos -= pos % runtime->min_align;
trace_hwptr(substream, pos, in_interrupt);
hw_base = runtime->hw_ptr_base;
new_hw_ptr = hw_base + pos;
if (in_interrupt) {
/* we know that one period was processed */
/* delta = "expected next hw_ptr" for in_interrupt != 0 */
delta = runtime->hw_ptr_interrupt + runtime->period_size;
if (delta > new_hw_ptr) {
/* check for double acknowledged interrupts */
hdelta = curr_jiffies - runtime->hw_ptr_jiffies;
if (hdelta > runtime->hw_ptr_buffer_jiffies/2 + 1) {
hw_base += runtime->buffer_size;
if (hw_base >= runtime->boundary) {
hw_base = 0;
crossed_boundary++;
}
new_hw_ptr = hw_base + pos;
goto __delta;
}
}
}
/* new_hw_ptr might be lower than old_hw_ptr in case when */
/* pointer crosses the end of the ring buffer */
if (new_hw_ptr < old_hw_ptr) {
hw_base += runtime->buffer_size;
if (hw_base >= runtime->boundary) {
hw_base = 0;
crossed_boundary++;
}
new_hw_ptr = hw_base + pos;
}
__delta:
delta = new_hw_ptr - old_hw_ptr;
if (delta < 0)
delta += runtime->boundary;
if (runtime->no_period_wakeup) {
snd_pcm_sframes_t xrun_threshold;
/*
* Without regular period interrupts, we have to check
* the elapsed time to detect xruns.
*/
jdelta = curr_jiffies - runtime->hw_ptr_jiffies;
if (jdelta < runtime->hw_ptr_buffer_jiffies / 2)
goto no_delta_check;
hdelta = jdelta - delta * HZ / runtime->rate;
xrun_threshold = runtime->hw_ptr_buffer_jiffies / 2 + 1;
while (hdelta > xrun_threshold) {
delta += runtime->buffer_size;
hw_base += runtime->buffer_size;
if (hw_base >= runtime->boundary) {
hw_base = 0;
crossed_boundary++;
}
new_hw_ptr = hw_base + pos;
hdelta -= runtime->hw_ptr_buffer_jiffies;
}
goto no_delta_check;
}
/* something must be really wrong */
if (delta >= runtime->buffer_size + runtime->period_size) {
hw_ptr_error(substream, in_interrupt, "Unexpected hw_ptr",
"(stream=%i, pos=%ld, new_hw_ptr=%ld, old_hw_ptr=%ld)\n",
substream->stream, (long)pos,
(long)new_hw_ptr, (long)old_hw_ptr);
return 0;
}
/* Do jiffies check only in xrun_debug mode */
if (!xrun_debug(substream, XRUN_DEBUG_JIFFIESCHECK))
goto no_jiffies_check;
/* Skip the jiffies check for hardwares with BATCH flag.
* Such hardware usually just increases the position at each IRQ,
* thus it can't give any strange position.
*/
if (runtime->hw.info & SNDRV_PCM_INFO_BATCH)
goto no_jiffies_check;
hdelta = delta;
if (hdelta < runtime->delay)
goto no_jiffies_check;
hdelta -= runtime->delay;
jdelta = curr_jiffies - runtime->hw_ptr_jiffies;
if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) {
delta = jdelta /
(((runtime->period_size * HZ) / runtime->rate)
+ HZ/100);
/* move new_hw_ptr according jiffies not pos variable */
new_hw_ptr = old_hw_ptr;
hw_base = delta;
/* use loop to avoid checks for delta overflows */
/* the delta value is small or zero in most cases */
while (delta > 0) {
new_hw_ptr += runtime->period_size;
if (new_hw_ptr >= runtime->boundary) {
new_hw_ptr -= runtime->boundary;
crossed_boundary--;
}
delta--;
}
/* align hw_base to buffer_size */
hw_ptr_error(substream, in_interrupt, "hw_ptr skipping",
"(pos=%ld, delta=%ld, period=%ld, jdelta=%lu/%lu/%lu, hw_ptr=%ld/%ld)\n",
(long)pos, (long)hdelta,
(long)runtime->period_size, jdelta,
((hdelta * HZ) / runtime->rate), hw_base,
(unsigned long)old_hw_ptr,
(unsigned long)new_hw_ptr);
/* reset values to proper state */
delta = 0;
hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size);
}
no_jiffies_check:
if (delta > runtime->period_size + runtime->period_size / 2) {
hw_ptr_error(substream, in_interrupt,
"Lost interrupts?",
"(stream=%i, delta=%ld, new_hw_ptr=%ld, old_hw_ptr=%ld)\n",
substream->stream, (long)delta,
(long)new_hw_ptr,
(long)old_hw_ptr);
}
no_delta_check:
if (runtime->status->hw_ptr == new_hw_ptr) {
update_audio_tstamp(substream, &curr_tstamp, &audio_tstamp);
return 0;
}
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
runtime->silence_size > 0)
snd_pcm_playback_silence(substream, new_hw_ptr);
if (in_interrupt) {
delta = new_hw_ptr - runtime->hw_ptr_interrupt;
if (delta < 0)
delta += runtime->boundary;
delta -= (snd_pcm_uframes_t)delta % runtime->period_size;
runtime->hw_ptr_interrupt += delta;
if (runtime->hw_ptr_interrupt >= runtime->boundary)
runtime->hw_ptr_interrupt -= runtime->boundary;
}
runtime->hw_ptr_base = hw_base;
runtime->status->hw_ptr = new_hw_ptr;
runtime->hw_ptr_jiffies = curr_jiffies;
if (crossed_boundary) {
snd_BUG_ON(crossed_boundary != 1);
runtime->hw_ptr_wrap += runtime->boundary;
}
update_audio_tstamp(substream, &curr_tstamp, &audio_tstamp);
return snd_pcm_update_state(substream, runtime);
}
| 6,262 |
50,066 | 0 | static SECStatus CanFalseStartCallback(PRFileDesc *sock, void *client_data,
PRBool *canFalseStart)
{
struct connectdata *conn = client_data;
struct Curl_easy *data = conn->data;
SSLChannelInfo channelInfo;
SSLCipherSuiteInfo cipherInfo;
SECStatus rv;
PRBool negotiatedExtension;
*canFalseStart = PR_FALSE;
if(SSL_GetChannelInfo(sock, &channelInfo, sizeof(channelInfo)) != SECSuccess)
return SECFailure;
if(SSL_GetCipherSuiteInfo(channelInfo.cipherSuite, &cipherInfo,
sizeof(cipherInfo)) != SECSuccess)
return SECFailure;
/* Prevent version downgrade attacks from TLS 1.2, and avoid False Start for
* TLS 1.3 and later. See https://bugzilla.mozilla.org/show_bug.cgi?id=861310
*/
if(channelInfo.protocolVersion != SSL_LIBRARY_VERSION_TLS_1_2)
goto end;
/* Only allow ECDHE key exchange algorithm.
* See https://bugzilla.mozilla.org/show_bug.cgi?id=952863 */
if(cipherInfo.keaType != ssl_kea_ecdh)
goto end;
/* Prevent downgrade attacks on the symmetric cipher. We do not allow CBC
* mode due to BEAST, POODLE, and other attacks on the MAC-then-Encrypt
* design. See https://bugzilla.mozilla.org/show_bug.cgi?id=1109766 */
if(cipherInfo.symCipher != ssl_calg_aes_gcm)
goto end;
/* Enforce ALPN or NPN to do False Start, as an indicator of server
* compatibility. */
rv = SSL_HandshakeNegotiatedExtension(sock, ssl_app_layer_protocol_xtn,
&negotiatedExtension);
if(rv != SECSuccess || !negotiatedExtension) {
rv = SSL_HandshakeNegotiatedExtension(sock, ssl_next_proto_nego_xtn,
&negotiatedExtension);
}
if(rv != SECSuccess || !negotiatedExtension)
goto end;
*canFalseStart = PR_TRUE;
infof(data, "Trying TLS False Start\n");
end:
return SECSuccess;
}
| 6,263 |
176,586 | 0 | xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar * val)
{
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
(ctxt->instate == XML_PARSER_EOF))
return;
if (ctxt != NULL)
ctxt->errNo = error;
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL,
XML_FROM_PARSER, error, XML_ERR_FATAL,
NULL, 0, (const char *) val, NULL, NULL, 0, 0, msg,
val);
if (ctxt != NULL) {
ctxt->wellFormed = 0;
if (ctxt->recovery == 0)
ctxt->disableSAX = 1;
}
}
| 6,264 |
116,969 | 0 | void IndexedDBDispatcher::RequestIDBObjectStoreDelete(
const IndexedDBKey& key,
WebIDBCallbacks* callbacks_ptr,
int32 idb_object_store_id,
const WebIDBTransaction& transaction,
WebExceptionCode* ec) {
ResetCursorPrefetchCaches();
scoped_ptr<WebIDBCallbacks> callbacks(callbacks_ptr);
int32 response_id = pending_callbacks_.Add(callbacks.release());
Send(new IndexedDBHostMsg_ObjectStoreDelete(
idb_object_store_id, CurrentWorkerId(), response_id, key,
TransactionId(transaction), ec));
if (*ec)
pending_callbacks_.Remove(response_id);
}
| 6,265 |
116,668 | 0 | WebExternalPopupMenu* RenderViewImpl::createExternalPopupMenu(
const WebPopupMenuInfo& popup_menu_info,
WebExternalPopupMenuClient* popup_menu_client) {
DCHECK(!external_popup_menu_.get());
external_popup_menu_.reset(
new ExternalPopupMenu(this, popup_menu_info, popup_menu_client));
return external_popup_menu_.get();
}
| 6,266 |
80,275 | 0 | GF_Err mvex_Write(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
GF_MovieExtendsBox *ptr = (GF_MovieExtendsBox *) s;
if (!s) return GF_BAD_PARAM;
e = gf_isom_box_write_header(s, bs);
if (e) return e;
if (ptr->mehd) {
e = gf_isom_box_write((GF_Box *)ptr->mehd, bs);
if (e) return e;
}
e = gf_isom_box_array_write(s, ptr->TrackExList, bs);
if (e) return e;
return gf_isom_box_array_write(s, ptr->TrackExPropList, bs);
}
| 6,267 |
61,013 | 0 | can_delete_without_confirm (GFile *file)
{
if (g_file_has_uri_scheme (file, "burn") ||
g_file_has_uri_scheme (file, "recent") ||
g_file_has_uri_scheme (file, "x-nautilus-desktop"))
{
return TRUE;
}
return FALSE;
}
| 6,268 |
181,645 | 1 | jp2_box_t *jp2_box_get(jas_stream_t *in)
{
jp2_box_t *box;
jp2_boxinfo_t *boxinfo;
jas_stream_t *tmpstream;
uint_fast32_t len;
uint_fast64_t extlen;
bool dataflag;
box = 0;
tmpstream = 0;
if (!(box = jas_malloc(sizeof(jp2_box_t)))) {
goto error;
}
box->ops = &jp2_boxinfo_unk.ops;
if (jp2_getuint32(in, &len) || jp2_getuint32(in, &box->type)) {
goto error;
}
boxinfo = jp2_boxinfolookup(box->type);
box->info = boxinfo;
box->ops = &boxinfo->ops;
box->len = len;
JAS_DBGLOG(10, (
"preliminary processing of JP2 box: type=%c%s%c (0x%08x); length=%d\n",
'"', boxinfo->name, '"', box->type, box->len
));
if (box->len == 1) {
if (jp2_getuint64(in, &extlen)) {
goto error;
}
if (extlen > 0xffffffffUL) {
jas_eprintf("warning: cannot handle large 64-bit box length\n");
extlen = 0xffffffffUL;
}
box->len = extlen;
box->datalen = extlen - JP2_BOX_HDRLEN(true);
} else {
box->datalen = box->len - JP2_BOX_HDRLEN(false);
}
if (box->len != 0 && box->len < 8) {
goto error;
}
dataflag = !(box->info->flags & (JP2_BOX_SUPER | JP2_BOX_NODATA));
if (dataflag) {
if (!(tmpstream = jas_stream_memopen(0, 0))) {
goto error;
}
if (jas_stream_copy(tmpstream, in, box->datalen)) {
// Mark the box data as never having been constructed
// so that we will not errantly attempt to destroy it later.
box->ops = &jp2_boxinfo_unk.ops;
jas_eprintf("cannot copy box data\n");
goto error;
}
jas_stream_rewind(tmpstream);
if (box->ops->getdata) {
if ((*box->ops->getdata)(box, tmpstream)) {
jas_eprintf("cannot parse box data\n");
goto error;
}
}
jas_stream_close(tmpstream);
}
if (jas_getdbglevel() >= 1) {
jp2_box_dump(box, stderr);
}
return box;
error:
if (box) {
jp2_box_destroy(box);
}
if (tmpstream) {
jas_stream_close(tmpstream);
}
return 0;
}
| 6,269 |
123,025 | 0 | bool RenderWidgetHostImpl::PaintBackingStoreRect(
TransportDIB::Id bitmap,
const gfx::Rect& bitmap_rect,
const std::vector<gfx::Rect>& copy_rects,
const gfx::Size& view_size,
float scale_factor,
const base::Closure& completion_callback) {
if (!view_)
return false;
if (is_hidden_) {
needs_repainting_on_restore_ = true;
return false;
}
bool needs_full_paint = false;
bool scheduled_completion_callback = false;
BackingStoreManager::PrepareBackingStore(this, view_size, bitmap, bitmap_rect,
copy_rects, scale_factor,
completion_callback,
&needs_full_paint,
&scheduled_completion_callback);
if (needs_full_paint) {
repaint_start_time_ = TimeTicks::Now();
repaint_ack_pending_ = true;
Send(new ViewMsg_Repaint(routing_id_, view_size));
}
return scheduled_completion_callback;
}
| 6,270 |
183,160 | 1 | ext4_xattr_block_get(struct inode *inode, int name_index, const char *name,
void *buffer, size_t buffer_size)
{
struct buffer_head *bh = NULL;
struct ext4_xattr_entry *entry;
size_t size;
int error;
struct mb_cache *ext4_mb_cache = EXT4_GET_MB_CACHE(inode);
ea_idebug(inode, "name=%d.%s, buffer=%p, buffer_size=%ld",
name_index, name, buffer, (long)buffer_size);
error = -ENODATA;
if (!EXT4_I(inode)->i_file_acl)
goto cleanup;
ea_idebug(inode, "reading block %llu",
(unsigned long long)EXT4_I(inode)->i_file_acl);
bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
if (!bh)
goto cleanup;
ea_bdebug(bh, "b_count=%d, refcount=%d",
atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
if (ext4_xattr_check_block(inode, bh)) {
bad_block:
EXT4_ERROR_INODE(inode, "bad block %llu",
EXT4_I(inode)->i_file_acl);
error = -EFSCORRUPTED;
goto cleanup;
}
ext4_xattr_cache_insert(ext4_mb_cache, bh);
entry = BFIRST(bh);
error = ext4_xattr_find_entry(&entry, name_index, name, bh->b_size, 1);
if (error == -EFSCORRUPTED)
goto bad_block;
if (error)
goto cleanup;
size = le32_to_cpu(entry->e_value_size);
if (buffer) {
error = -ERANGE;
if (size > buffer_size)
goto cleanup;
memcpy(buffer, bh->b_data + le16_to_cpu(entry->e_value_offs),
size);
}
error = size;
cleanup:
brelse(bh);
return error;
}
| 6,271 |
134,562 | 0 | RenderWidgetHostViewAura* ToRenderWidgetHostViewAura(
RenderWidgetHostView* view) {
if (!view || RenderViewHostFactory::has_factory())
return NULL; // Can't cast to RenderWidgetHostViewAura in unit tests.
RenderProcessHostImpl* process = static_cast<RenderProcessHostImpl*>(
view->GetRenderWidgetHost()->GetProcess());
if (process->IsGuest())
return NULL;
return static_cast<RenderWidgetHostViewAura*>(view);
}
| 6,272 |
145,293 | 0 | bool ObjectBackedNativeHandler::GetPrivate(v8::Local<v8::Object> obj,
const char* key,
v8::Local<v8::Value>* result) {
return GetPrivate(context_->v8_context(), obj, key, result);
}
| 6,273 |
41,052 | 0 | static int authenticate_and_decrypt_nss_2_0 (
struct crypto_instance *instance,
unsigned char *buf,
int *buf_len)
{
if (hash_to_nss[instance->crypto_hash_type]) {
unsigned char tmp_hash[hash_len[instance->crypto_hash_type]];
unsigned char *hash = buf;
unsigned char *data = hash + hash_len[instance->crypto_hash_type];
int datalen = *buf_len - hash_len[instance->crypto_hash_type];
if (calculate_nss_hash(instance, data, datalen, tmp_hash) < 0) {
return -1;
}
if (memcmp(tmp_hash, hash, hash_len[instance->crypto_hash_type]) != 0) {
log_printf(instance->log_level_error, "Digest does not match");
return -1;
}
memmove(buf, data, datalen);
*buf_len = datalen;
}
if (decrypt_nss(instance, buf, buf_len) < 0) {
return -1;
}
return 0;
}
| 6,274 |
164,731 | 0 | void TestClearSectionWithNodeContainingSelectOne(const char* html,
bool unowned) {
LoadHTML(html);
WebLocalFrame* web_frame = GetMainFrame();
ASSERT_NE(nullptr, web_frame);
FormCache form_cache(web_frame);
std::vector<FormData> forms = form_cache.ExtractNewForms();
ASSERT_EQ(1U, forms.size());
WebInputElement firstname = GetInputElementById("firstname");
firstname.SetAutofillState(WebAutofillState::kAutofilled);
WebInputElement lastname = GetInputElementById("lastname");
lastname.SetAutofillState(WebAutofillState::kAutofilled);
WebSelectElement state =
web_frame->GetDocument().GetElementById("state").To<WebSelectElement>();
state.SetValue(WebString::FromUTF8("AK"));
state.SetAutofillState(WebAutofillState::kAutofilled);
EXPECT_TRUE(form_cache.ClearSectionWithElement(firstname));
EXPECT_FALSE(firstname.IsAutofilled());
FormData form;
FormFieldData field;
EXPECT_TRUE(
FindFormAndFieldForFormControlElement(firstname, &form, &field));
EXPECT_EQ(GetCanonicalOriginForDocument(web_frame->GetDocument()),
form.origin);
EXPECT_FALSE(form.origin.is_empty());
if (!unowned) {
EXPECT_EQ(ASCIIToUTF16("TestForm"), form.name);
EXPECT_EQ(GURL("http://abc.com"), form.action);
}
const std::vector<FormFieldData>& fields = form.fields;
ASSERT_EQ(3U, fields.size());
FormFieldData expected;
expected.id_attribute = ASCIIToUTF16("firstname");
expected.name = expected.id_attribute;
expected.value.clear();
expected.form_control_type = "text";
expected.max_length = WebInputElement::DefaultMaxLength();
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[0]);
expected.id_attribute = ASCIIToUTF16("lastname");
expected.name = expected.id_attribute;
expected.value.clear();
expected.form_control_type = "text";
expected.max_length = WebInputElement::DefaultMaxLength();
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[1]);
expected.id_attribute = ASCIIToUTF16("state");
expected.name_attribute = ASCIIToUTF16("state");
expected.name = expected.name_attribute;
expected.value = ASCIIToUTF16("?");
expected.form_control_type = "select-one";
expected.max_length = 0;
EXPECT_FORM_FIELD_DATA_EQUALS(expected, fields[2]);
EXPECT_EQ(0, firstname.SelectionStart());
EXPECT_EQ(0, firstname.SelectionEnd());
}
| 6,275 |
164,892 | 0 | std::string DownloadResourceHandler::DebugString() const {
const ResourceRequestInfoImpl* info = GetRequestInfo();
return base::StringPrintf("{"
" url_ = " "\"%s\""
" info = {"
" child_id = " "%d"
" request_id = " "%d"
" route_id = " "%d"
" }"
" }",
request() ?
request()->url().spec().c_str() :
"<NULL request>",
info->GetChildID(),
info->GetRequestID(),
info->GetRouteID());
}
| 6,276 |
14,510 | 0 | static inline int padr_bcast(PCNetState *s, const uint8_t *buf, int size)
{
static const uint8_t BCAST[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
struct qemu_ether_header *hdr = (void *)buf;
int result = !CSR_DRCVBC(s) && !memcmp(hdr->ether_dhost, BCAST, 6);
#ifdef PCNET_DEBUG_MATCH
printf("padr_bcast result=%d\n", result);
#endif
return result;
}
| 6,277 |
109,127 | 0 | void RenderViewImpl::focusedNodeChanged(const WebNode& node) {
Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node)));
FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node));
}
| 6,278 |
78,625 | 0 | piv_check_protected_objects(sc_card_t *card)
{
int r = 0;
int i;
piv_private_data_t * priv = PIV_DATA(card);
u8 buf[8]; /* tag of 53 with 82 xx xx will fit in 4 */
u8 * rbuf;
size_t buf_len;
static int protected_objects[] = {PIV_OBJ_PI, PIV_OBJ_CHF, PIV_OBJ_IRIS_IMAGE};
LOG_FUNC_CALLED(card->ctx);
/*
* routine only called from piv_pin_cmd after verify lc=0 did not return 90 00
* We will test for a protected object using GET DATA.
*
* Based on observations, of cards using the GET DATA APDU,
* SC_ERROR_SECURITY_STATUS_NOT_SATISFIED means the PIN not verified,
* SC_SUCCESS means PIN has been verified even if it has length 0
* SC_ERROR_FILE_NOT_FOUND (which is the bug) does not tell us anything
* about the state of the PIN and we will try the next object.
*
* If we can't determine the security state from this process,
* set card_issues CI_CANT_USE_GETDATA_FOR_STATE
* and return SC_ERROR_PIN_CODE_INCORRECT
* The circumvention is to add a dummy Printed Info object in the card.
* so we will have an object to test.
*
* We save the object's number to use in the future.
*
*/
if (priv->object_test_verify == 0) {
for (i = 0; i < (int)(sizeof(protected_objects)/sizeof(int)); i++) {
buf_len = sizeof(buf);
priv->pin_cmd_noparse = 1; /* tell piv_general_io dont need to parse at all. */
rbuf = buf;
r = piv_get_data(card, protected_objects[i], &rbuf, &buf_len);
priv->pin_cmd_noparse = 0;
/* TODO may need to check sw1 and sw2 to see what really happened */
if (r >= 0 || r == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED) {
/* we can use this object next time if needed */
priv->object_test_verify = protected_objects[i];
break;
}
}
if (priv->object_test_verify == 0) {
/*
* none of the objects returned acceptable sw1, sw2
*/
sc_log(card->ctx, "No protected objects found, setting CI_CANT_USE_GETDATA_FOR_STATE");
priv->card_issues |= CI_CANT_USE_GETDATA_FOR_STATE;
r = SC_ERROR_PIN_CODE_INCORRECT;
}
} else {
/* use the one object we found earlier. Test is security status has changed */
buf_len = sizeof(buf);
priv->pin_cmd_noparse = 1; /* tell piv_general_io dont need to parse at all. */
rbuf = buf;
r = piv_get_data(card, priv->object_test_verify, &rbuf, &buf_len);
priv->pin_cmd_noparse = 0;
}
if (r == SC_ERROR_FILE_NOT_FOUND)
r = SC_ERROR_PIN_CODE_INCORRECT;
else if (r == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED)
r = SC_ERROR_PIN_CODE_INCORRECT;
else if (r > 0)
r = SC_SUCCESS;
sc_log(card->ctx, "object_test_verify=%d, card_issues = 0x%08x", priv->object_test_verify, priv->card_issues);
LOG_FUNC_RETURN(card->ctx, r);
}
| 6,279 |
23,335 | 0 | static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
{
return decode_opaque_fixed(xdr, stateid->data, NFS4_STATEID_SIZE);
}
| 6,280 |
136,855 | 0 | String HTMLInputElement::AltText() const {
String alt = FastGetAttribute(altAttr);
if (alt.IsNull())
alt = FastGetAttribute(titleAttr);
if (alt.IsNull())
alt = FastGetAttribute(valueAttr);
if (alt.IsNull())
alt = GetLocale().QueryString(WebLocalizedString::kInputElementAltText);
return alt;
}
| 6,281 |
53,222 | 0 | static int proc_disconnectsignal_compat(struct usb_dev_state *ps, void __user *arg)
{
struct usbdevfs_disconnectsignal32 ds;
if (copy_from_user(&ds, arg, sizeof(ds)))
return -EFAULT;
ps->discsignr = ds.signr;
ps->disccontext = compat_ptr(ds.context);
return 0;
}
| 6,282 |
100,780 | 0 | void HttpResponseHeaders::AddHopContentRangeHeaders(HeaderSet* result) {
result->insert("content-range");
}
| 6,283 |
122,763 | 0 | void BrowserPluginGuest::Resize(
RenderViewHost* embedder_rvh,
const BrowserPluginHostMsg_ResizeGuest_Params& params) {
RenderWidgetHostImpl* render_widget_host =
RenderWidgetHostImpl::From(web_contents()->GetRenderViewHost());
render_widget_host->ResetSizeAndRepaintPendingFlags();
if (!TransportDIB::is_valid_id(params.damage_buffer_id)) {
if (!params.view_size.IsEmpty())
web_contents()->GetView()->SizeContents(params.view_size);
return;
}
TransportDIB* damage_buffer =
GetDamageBufferFromEmbedder(embedder_rvh, params);
SetDamageBuffer(damage_buffer,
#if defined(OS_WIN)
params.damage_buffer_size,
params.damage_buffer_id.handle,
#endif
params.view_size,
params.scale_factor);
web_contents()->GetView()->SizeContents(params.view_size);
}
| 6,284 |
89,602 | 0 | _gcry_cipher_gcm_authenticate (gcry_cipher_hd_t c,
const byte * aadbuf, size_t aadbuflen)
{
static const unsigned char zerobuf[MAX_BLOCKSIZE];
if (c->spec->blocksize != GCRY_GCM_BLOCK_LEN)
return GPG_ERR_CIPHER_ALGO;
if (c->u_mode.gcm.datalen_over_limits)
return GPG_ERR_INV_LENGTH;
if (c->marks.tag
|| c->u_mode.gcm.ghash_aad_finalized
|| c->u_mode.gcm.ghash_data_finalized
|| !c->u_mode.gcm.ghash_fn)
return GPG_ERR_INV_STATE;
if (!c->marks.iv)
_gcry_cipher_gcm_setiv (c, zerobuf, GCRY_GCM_BLOCK_LEN);
gcm_bytecounter_add(c->u_mode.gcm.aadlen, aadbuflen);
if (!gcm_check_aadlen_or_ivlen(c->u_mode.gcm.aadlen))
{
c->u_mode.gcm.datalen_over_limits = 1;
return GPG_ERR_INV_LENGTH;
}
do_ghash_buf(c, c->u_mode.gcm.u_tag.tag, aadbuf, aadbuflen, 0);
return 0;
}
| 6,285 |
50,311 | 0 | static int v9fs_set_acl(struct p9_fid *fid, int type, struct posix_acl *acl)
{
int retval;
char *name;
size_t size;
void *buffer;
if (!acl)
return 0;
/* Set a setxattr request to server */
size = posix_acl_xattr_size(acl->a_count);
buffer = kmalloc(size, GFP_KERNEL);
if (!buffer)
return -ENOMEM;
retval = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
if (retval < 0)
goto err_free_out;
switch (type) {
case ACL_TYPE_ACCESS:
name = XATTR_NAME_POSIX_ACL_ACCESS;
break;
case ACL_TYPE_DEFAULT:
name = XATTR_NAME_POSIX_ACL_DEFAULT;
break;
default:
BUG();
}
retval = v9fs_fid_xattr_set(fid, name, buffer, size, 0);
err_free_out:
kfree(buffer);
return retval;
}
| 6,286 |
3,562 | 0 | static int ldb_match_scope(struct ldb_context *ldb,
struct ldb_dn *base,
struct ldb_dn *dn,
enum ldb_scope scope)
{
int ret = 0;
if (base == NULL || dn == NULL) {
return 1;
}
switch (scope) {
case LDB_SCOPE_BASE:
if (ldb_dn_compare(base, dn) == 0) {
ret = 1;
}
break;
case LDB_SCOPE_ONELEVEL:
if (ldb_dn_get_comp_num(dn) == (ldb_dn_get_comp_num(base) + 1)) {
if (ldb_dn_compare_base(base, dn) == 0) {
ret = 1;
}
}
break;
case LDB_SCOPE_SUBTREE:
default:
if (ldb_dn_compare_base(base, dn) == 0) {
ret = 1;
}
break;
}
return ret;
}
| 6,287 |
77,657 | 0 | ofputil_protocol_from_ofp_version(enum ofp_version version)
{
return rightmost_1bit(ofputil_protocols_from_ofp_version(version));
}
| 6,288 |
55,925 | 0 | int tty_init_termios(struct tty_struct *tty)
{
struct ktermios *tp;
int idx = tty->index;
if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS)
tty->termios = tty->driver->init_termios;
else {
/* Check for lazy saved data */
tp = tty->driver->termios[idx];
if (tp != NULL)
tty->termios = *tp;
else
tty->termios = tty->driver->init_termios;
}
/* Compatibility until drivers always set this */
tty->termios.c_ispeed = tty_termios_input_baud_rate(&tty->termios);
tty->termios.c_ospeed = tty_termios_baud_rate(&tty->termios);
return 0;
}
| 6,289 |
186,881 | 1 | BaseRenderingContext2D::BaseRenderingContext2D()
: clip_antialiasing_(kNotAntiAliased) {
state_stack_.push_back(CanvasRenderingContext2DState::Create());
}
| 6,290 |
182,328 | 1 | static enum AVPixelFormat h263_get_format(AVCodecContext *avctx)
{
/* MPEG-4 Studio Profile only, not supported by hardware */
if (avctx->bits_per_raw_sample > 8) {
av_assert1(avctx->profile == FF_PROFILE_MPEG4_SIMPLE_STUDIO);
return avctx->pix_fmt;
}
if (avctx->codec->id == AV_CODEC_ID_MSS2)
return AV_PIX_FMT_YUV420P;
if (CONFIG_GRAY && (avctx->flags & AV_CODEC_FLAG_GRAY)) {
if (avctx->color_range == AVCOL_RANGE_UNSPECIFIED)
avctx->color_range = AVCOL_RANGE_MPEG;
return AV_PIX_FMT_GRAY8;
}
return avctx->pix_fmt = ff_get_format(avctx, avctx->codec->pix_fmts);
}
| 6,291 |
41,260 | 0 | static void scsi_disk_reset(DeviceState *dev)
{
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev.qdev, dev);
uint64_t nb_sectors;
scsi_device_purge_requests(&s->qdev, SENSE_CODE(RESET));
bdrv_get_geometry(s->bs, &nb_sectors);
nb_sectors /= s->cluster_size;
if (nb_sectors) {
nb_sectors--;
}
s->max_lba = nb_sectors;
}
| 6,292 |
111,212 | 0 | IntPoint WebPagePrivate::mapFromTransformedContentsToTransformedViewport(const IntPoint& point) const
{
return m_backingStoreClient->mapFromTransformedContentsToTransformedViewport(point);
}
| 6,293 |
109,170 | 0 | WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() {
EnsureMediaStreamImpl();
return media_stream_impl_;
}
| 6,294 |
60,752 | 0 | ModuleExport size_t RegisterYUVImage(void)
{
MagickInfo
*entry;
entry=AcquireMagickInfo("YUV","YUV","CCIR 601 4:1:1 or 4:2:2");
entry->decoder=(DecodeImageHandler *) ReadYUVImage;
entry->encoder=(EncodeImageHandler *) WriteYUVImage;
entry->flags^=CoderAdjoinFlag;
entry->flags|=CoderRawSupportFlag;
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
| 6,295 |
155,150 | 0 | void OmniboxViewViews::OnPaint(gfx::Canvas* canvas) {
if (latency_histogram_state_ == CHAR_TYPED) {
DCHECK(!insert_char_time_.is_null());
UMA_HISTOGRAM_TIMES("Omnibox.CharTypedToRepaintLatency.ToPaint",
base::TimeTicks::Now() - insert_char_time_);
latency_histogram_state_ = ON_PAINT_CALLED;
}
{
SCOPED_UMA_HISTOGRAM_TIMER("Omnibox.PaintTime");
Textfield::OnPaint(canvas);
}
}
| 6,296 |
18,585 | 0 | void ext4_ext_truncate(struct inode *inode)
{
struct address_space *mapping = inode->i_mapping;
struct super_block *sb = inode->i_sb;
ext4_lblk_t last_block;
handle_t *handle;
loff_t page_len;
int err = 0;
/*
* finish any pending end_io work so we won't run the risk of
* converting any truncated blocks to initialized later
*/
ext4_flush_unwritten_io(inode);
/*
* probably first extent we're gonna free will be last in block
*/
err = ext4_writepage_trans_blocks(inode);
handle = ext4_journal_start(inode, err);
if (IS_ERR(handle))
return;
if (inode->i_size % PAGE_CACHE_SIZE != 0) {
page_len = PAGE_CACHE_SIZE -
(inode->i_size & (PAGE_CACHE_SIZE - 1));
err = ext4_discard_partial_page_buffers(handle,
mapping, inode->i_size, page_len, 0);
if (err)
goto out_stop;
}
if (ext4_orphan_add(handle, inode))
goto out_stop;
down_write(&EXT4_I(inode)->i_data_sem);
ext4_ext_invalidate_cache(inode);
ext4_discard_preallocations(inode);
/*
* TODO: optimization is possible here.
* Probably we need not scan at all,
* because page truncation is enough.
*/
/* we have to know where to truncate from in crash case */
EXT4_I(inode)->i_disksize = inode->i_size;
ext4_mark_inode_dirty(handle, inode);
last_block = (inode->i_size + sb->s_blocksize - 1)
>> EXT4_BLOCK_SIZE_BITS(sb);
err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1);
/* In a multi-transaction truncate, we only make the final
* transaction synchronous.
*/
if (IS_SYNC(inode))
ext4_handle_sync(handle);
up_write(&EXT4_I(inode)->i_data_sem);
out_stop:
/*
* If this was a simple ftruncate() and the file will remain alive,
* then we need to clear up the orphan record which we created above.
* However, if this was a real unlink then we were called by
* ext4_delete_inode(), and we allow that function to clean up the
* orphan info for us.
*/
if (inode->i_nlink)
ext4_orphan_del(handle, inode);
inode->i_mtime = inode->i_ctime = ext4_current_time(inode);
ext4_mark_inode_dirty(handle, inode);
ext4_journal_stop(handle);
}
| 6,297 |
55,677 | 0 | static inline void ttwu_activate(struct rq *rq, struct task_struct *p, int en_flags)
{
activate_task(rq, p, en_flags);
p->on_rq = TASK_ON_RQ_QUEUED;
/* if a worker is waking up, notify workqueue */
if (p->flags & PF_WQ_WORKER)
wq_worker_waking_up(p, cpu_of(rq));
}
| 6,298 |
176,601 | 0 | xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
xmlChar limit = 0;
xmlChar *buf = NULL;
xmlChar *rep = NULL;
size_t len = 0;
size_t buf_size = 0;
int c, l, in_space = 0;
xmlChar *current = NULL;
xmlEntityPtr ent;
if (NXT(0) == '"') {
ctxt->instate = XML_PARSER_ATTRIBUTE_VALUE;
limit = '"';
NEXT;
} else if (NXT(0) == '\'') {
limit = '\'';
ctxt->instate = XML_PARSER_ATTRIBUTE_VALUE;
NEXT;
} else {
xmlFatalErr(ctxt, XML_ERR_ATTRIBUTE_NOT_STARTED, NULL);
return(NULL);
}
/*
* allocate a translation buffer.
*/
buf_size = XML_PARSER_BUFFER_SIZE;
buf = (xmlChar *) xmlMallocAtomic(buf_size);
if (buf == NULL) goto mem_error;
/*
* OK loop until we reach one of the ending char or a size limit.
*/
c = CUR_CHAR(l);
while (((NXT(0) != limit) && /* checked */
(IS_CHAR(c)) && (c != '<')) &&
(ctxt->instate != XML_PARSER_EOF)) {
/*
* Impose a reasonable limit on attribute size, unless XML_PARSE_HUGE
* special option is given
*/
if ((len > XML_MAX_TEXT_LENGTH) &&
((ctxt->options & XML_PARSE_HUGE) == 0)) {
xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
"AttValue length too long\n");
goto mem_error;
}
if (c == 0) break;
if (c == '&') {
in_space = 0;
if (NXT(1) == '#') {
int val = xmlParseCharRef(ctxt);
if (val == '&') {
if (ctxt->replaceEntities) {
if (len + 10 > buf_size) {
growBuffer(buf, 10);
}
buf[len++] = '&';
} else {
/*
* The reparsing will be done in xmlStringGetNodeList()
* called by the attribute() function in SAX.c
*/
if (len + 10 > buf_size) {
growBuffer(buf, 10);
}
buf[len++] = '&';
buf[len++] = '#';
buf[len++] = '3';
buf[len++] = '8';
buf[len++] = ';';
}
} else if (val != 0) {
if (len + 10 > buf_size) {
growBuffer(buf, 10);
}
len += xmlCopyChar(0, &buf[len], val);
}
} else {
ent = xmlParseEntityRef(ctxt);
ctxt->nbentities++;
if (ent != NULL)
ctxt->nbentities += ent->owner;
if ((ent != NULL) &&
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
if (len + 10 > buf_size) {
growBuffer(buf, 10);
}
if ((ctxt->replaceEntities == 0) &&
(ent->content[0] == '&')) {
buf[len++] = '&';
buf[len++] = '#';
buf[len++] = '3';
buf[len++] = '8';
buf[len++] = ';';
} else {
buf[len++] = ent->content[0];
}
} else if ((ent != NULL) &&
(ctxt->replaceEntities != 0)) {
if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) {
++ctxt->depth;
rep = xmlStringDecodeEntities(ctxt, ent->content,
XML_SUBSTITUTE_REF,
0, 0, 0);
--ctxt->depth;
if (rep != NULL) {
current = rep;
while (*current != 0) { /* non input consuming */
if ((*current == 0xD) || (*current == 0xA) ||
(*current == 0x9)) {
buf[len++] = 0x20;
current++;
} else
buf[len++] = *current++;
if (len + 10 > buf_size) {
growBuffer(buf, 10);
}
}
xmlFree(rep);
rep = NULL;
}
} else {
if (len + 10 > buf_size) {
growBuffer(buf, 10);
}
if (ent->content != NULL)
buf[len++] = ent->content[0];
}
} else if (ent != NULL) {
int i = xmlStrlen(ent->name);
const xmlChar *cur = ent->name;
/*
* This may look absurd but is needed to detect
* entities problems
*/
if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
(ent->content != NULL) && (ent->checked == 0)) {
unsigned long oldnbent = ctxt->nbentities;
++ctxt->depth;
rep = xmlStringDecodeEntities(ctxt, ent->content,
XML_SUBSTITUTE_REF, 0, 0, 0);
--ctxt->depth;
ent->checked = (ctxt->nbentities - oldnbent + 1) * 2;
if (rep != NULL) {
if (xmlStrchr(rep, '<'))
ent->checked |= 1;
xmlFree(rep);
rep = NULL;
}
}
/*
* Just output the reference
*/
buf[len++] = '&';
while (len + i + 10 > buf_size) {
growBuffer(buf, i + 10);
}
for (;i > 0;i--)
buf[len++] = *cur++;
buf[len++] = ';';
}
}
} else {
if ((c == 0x20) || (c == 0xD) || (c == 0xA) || (c == 0x9)) {
if ((len != 0) || (!normalize)) {
if ((!normalize) || (!in_space)) {
COPY_BUF(l,buf,len,0x20);
while (len + 10 > buf_size) {
growBuffer(buf, 10);
}
}
in_space = 1;
}
} else {
in_space = 0;
COPY_BUF(l,buf,len,c);
if (len + 10 > buf_size) {
growBuffer(buf, 10);
}
}
NEXTL(l);
}
GROW;
c = CUR_CHAR(l);
}
if (ctxt->instate == XML_PARSER_EOF)
goto error;
if ((in_space) && (normalize)) {
while ((len > 0) && (buf[len - 1] == 0x20)) len--;
}
buf[len] = 0;
if (RAW == '<') {
xmlFatalErr(ctxt, XML_ERR_LT_IN_ATTRIBUTE, NULL);
} else if (RAW != limit) {
if ((c != 0) && (!IS_CHAR(c))) {
xmlFatalErrMsg(ctxt, XML_ERR_INVALID_CHAR,
"invalid character in attribute value\n");
} else {
xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
"AttValue: ' expected\n");
}
} else
NEXT;
/*
* There we potentially risk an overflow, don't allow attribute value of
* length more than INT_MAX it is a very reasonnable assumption !
*/
if (len >= INT_MAX) {
xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
"AttValue length too long\n");
goto mem_error;
}
if (attlen != NULL) *attlen = (int) len;
return(buf);
mem_error:
xmlErrMemory(ctxt, NULL);
error:
if (buf != NULL)
xmlFree(buf);
if (rep != NULL)
xmlFree(rep);
return(NULL);
}
| 6,299 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.