unique_id
int64 13
189k
| target
int64 0
1
| code
stringlengths 20
241k
| __index_level_0__
int64 0
18.9k
|
---|---|---|---|
46,352 | 0 | static int ramfs_nommu_setattr(struct dentry *dentry, struct iattr *ia)
{
struct inode *inode = dentry->d_inode;
unsigned int old_ia_valid = ia->ia_valid;
int ret = 0;
/* POSIX UID/GID verification for setting inode attributes */
ret = inode_change_ok(inode, ia);
if (ret)
return ret;
/* pick out size-changing events */
if (ia->ia_valid & ATTR_SIZE) {
loff_t size = inode->i_size;
if (ia->ia_size != size) {
ret = ramfs_nommu_resize(inode, ia->ia_size, size);
if (ret < 0 || ia->ia_valid == ATTR_SIZE)
goto out;
} else {
/* we skipped the truncate but must still update
* timestamps
*/
ia->ia_valid |= ATTR_MTIME|ATTR_CTIME;
}
}
setattr_copy(inode, ia);
out:
ia->ia_valid = old_ia_valid;
return ret;
}
| 6,000 |
94,859 | 0 | static ssize_t SmushXGap(const Image *smush_image,const Image *images,
const ssize_t offset,ExceptionInfo *exception)
{
CacheView
*left_view,
*right_view;
const Image
*left_image,
*right_image;
RectangleInfo
left_geometry,
right_geometry;
register const Quantum
*p;
register ssize_t
i,
y;
size_t
gap;
ssize_t
x;
if (images->previous == (Image *) NULL)
return(0);
right_image=images;
SetGeometry(smush_image,&right_geometry);
GravityAdjustGeometry(right_image->columns,right_image->rows,
right_image->gravity,&right_geometry);
left_image=images->previous;
SetGeometry(smush_image,&left_geometry);
GravityAdjustGeometry(left_image->columns,left_image->rows,
left_image->gravity,&left_geometry);
gap=right_image->columns;
left_view=AcquireVirtualCacheView(left_image,exception);
right_view=AcquireVirtualCacheView(right_image,exception);
for (y=0; y < (ssize_t) smush_image->rows; y++)
{
for (x=(ssize_t) left_image->columns-1; x > 0; x--)
{
p=GetCacheViewVirtualPixels(left_view,x,left_geometry.y+y,1,1,exception);
if ((p == (const Quantum *) NULL) ||
(GetPixelAlpha(left_image,p) != TransparentAlpha) ||
((left_image->columns-x-1) >= gap))
break;
}
i=(ssize_t) left_image->columns-x-1;
for (x=0; x < (ssize_t) right_image->columns; x++)
{
p=GetCacheViewVirtualPixels(right_view,x,right_geometry.y+y,1,1,
exception);
if ((p == (const Quantum *) NULL) ||
(GetPixelAlpha(right_image,p) != TransparentAlpha) ||
((x+i) >= (ssize_t) gap))
break;
}
if ((x+i) < (ssize_t) gap)
gap=(size_t) (x+i);
}
right_view=DestroyCacheView(right_view);
left_view=DestroyCacheView(left_view);
if (y < (ssize_t) smush_image->rows)
return(offset);
return((ssize_t) gap-offset);
}
| 6,001 |
118,768 | 0 | static inline bool isChildTypeAllowed(ContainerNode* newParent, Node* child)
{
if (!child->isDocumentFragment())
return newParent->childTypeAllowed(child->nodeType());
for (Node* node = child->firstChild(); node; node = node->nextSibling()) {
if (!newParent->childTypeAllowed(node->nodeType()))
return false;
}
return true;
}
| 6,002 |
123,018 | 0 | void RenderWidgetHostImpl::OnMsgUpdateIsDelayed() {
if (in_get_backing_store_)
abort_get_backing_store_ = true;
}
| 6,003 |
160,460 | 0 | void RenderFrameHostImpl::OnCreateChildFrame(
int new_routing_id,
service_manager::mojom::InterfaceProviderRequest
new_interface_provider_provider_request,
blink::WebTreeScopeType scope,
const std::string& frame_name,
const std::string& frame_unique_name,
bool is_created_by_script,
const base::UnguessableToken& devtools_frame_token,
const blink::FramePolicy& frame_policy,
const FrameOwnerProperties& frame_owner_properties) {
DCHECK(!frame_unique_name.empty());
DCHECK(new_interface_provider_provider_request.is_pending());
if (!is_active() || !IsCurrent() || !render_frame_created_)
return;
frame_tree_->AddFrame(frame_tree_node_, GetProcess()->GetID(), new_routing_id,
std::move(new_interface_provider_provider_request),
scope, frame_name, frame_unique_name,
is_created_by_script, devtools_frame_token,
frame_policy, frame_owner_properties);
}
| 6,004 |
61,033 | 0 | custom_full_name_skip (va_list *va)
{
(void) va_arg (*va, GFile *);
}
| 6,005 |
26,990 | 0 | static int do_send_NPIdentifier(rpc_message_t *message, void *p_value)
{
NPIdentifier ident = *(NPIdentifier *)p_value;
int id = 0;
if (ident) {
#ifdef BUILD_WRAPPER
id = id_lookup_value(ident);
if (id < 0)
id = id_create(ident);
#endif
#ifdef BUILD_VIEWER
id = (uintptr_t)ident;
#endif
assert(id != 0);
}
return rpc_message_send_uint32(message, id);
}
| 6,006 |
122,901 | 0 | void RegisterProcess(const std::string& site, RenderProcessHost* process) {
map_[site] = process;
}
| 6,007 |
29,969 | 0 | int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, size_t len,
int noblock, int flags, int *addr_len)
{
struct ipv6_pinfo *np = inet6_sk(sk);
struct inet_sock *inet = inet_sk(sk);
struct sk_buff *skb;
unsigned int ulen, copied;
int peeked, off = 0;
int err;
int is_udplite = IS_UDPLITE(sk);
int is_udp4;
bool slow;
if (addr_len)
*addr_len = sizeof(struct sockaddr_in6);
if (flags & MSG_ERRQUEUE)
return ipv6_recv_error(sk, msg, len);
if (np->rxpmtu && np->rxopt.bits.rxpmtu)
return ipv6_recv_rxpmtu(sk, msg, len);
try_again:
skb = __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0),
&peeked, &off, &err);
if (!skb)
goto out;
ulen = skb->len - sizeof(struct udphdr);
copied = len;
if (copied > ulen)
copied = ulen;
else if (copied < ulen)
msg->msg_flags |= MSG_TRUNC;
is_udp4 = (skb->protocol == htons(ETH_P_IP));
/*
* If checksum is needed at all, try to do it while copying the
* data. If the data is truncated, or if we only want a partial
* coverage checksum (UDP-Lite), do it before the copy.
*/
if (copied < ulen || UDP_SKB_CB(skb)->partial_cov) {
if (udp_lib_checksum_complete(skb))
goto csum_copy_err;
}
if (skb_csum_unnecessary(skb))
err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),
msg->msg_iov, copied);
else {
err = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov);
if (err == -EINVAL)
goto csum_copy_err;
}
if (unlikely(err)) {
trace_kfree_skb(skb, udpv6_recvmsg);
if (!peeked) {
atomic_inc(&sk->sk_drops);
if (is_udp4)
UDP_INC_STATS_USER(sock_net(sk),
UDP_MIB_INERRORS,
is_udplite);
else
UDP6_INC_STATS_USER(sock_net(sk),
UDP_MIB_INERRORS,
is_udplite);
}
goto out_free;
}
if (!peeked) {
if (is_udp4)
UDP_INC_STATS_USER(sock_net(sk),
UDP_MIB_INDATAGRAMS, is_udplite);
else
UDP6_INC_STATS_USER(sock_net(sk),
UDP_MIB_INDATAGRAMS, is_udplite);
}
sock_recv_ts_and_drops(msg, sk, skb);
/* Copy the address. */
if (msg->msg_name) {
struct sockaddr_in6 *sin6;
sin6 = (struct sockaddr_in6 *) msg->msg_name;
sin6->sin6_family = AF_INET6;
sin6->sin6_port = udp_hdr(skb)->source;
sin6->sin6_flowinfo = 0;
if (is_udp4) {
ipv6_addr_set_v4mapped(ip_hdr(skb)->saddr,
&sin6->sin6_addr);
sin6->sin6_scope_id = 0;
} else {
sin6->sin6_addr = ipv6_hdr(skb)->saddr;
sin6->sin6_scope_id =
ipv6_iface_scope_id(&sin6->sin6_addr,
IP6CB(skb)->iif);
}
}
if (is_udp4) {
if (inet->cmsg_flags)
ip_cmsg_recv(msg, skb);
} else {
if (np->rxopt.all)
ip6_datagram_recv_ctl(sk, msg, skb);
}
err = copied;
if (flags & MSG_TRUNC)
err = ulen;
out_free:
skb_free_datagram_locked(sk, skb);
out:
return err;
csum_copy_err:
slow = lock_sock_fast(sk);
if (!skb_kill_datagram(sk, skb, flags)) {
if (is_udp4) {
UDP_INC_STATS_USER(sock_net(sk),
UDP_MIB_CSUMERRORS, is_udplite);
UDP_INC_STATS_USER(sock_net(sk),
UDP_MIB_INERRORS, is_udplite);
} else {
UDP6_INC_STATS_USER(sock_net(sk),
UDP_MIB_CSUMERRORS, is_udplite);
UDP6_INC_STATS_USER(sock_net(sk),
UDP_MIB_INERRORS, is_udplite);
}
}
unlock_sock_fast(sk, slow);
if (noblock)
return -EAGAIN;
/* starting over for a new packet */
msg->msg_flags &= ~MSG_TRUNC;
goto try_again;
}
| 6,008 |
98,232 | 0 | Environment::~Environment() {}
| 6,009 |
115,701 | 0 | bool HostNPScriptObject::SetProperty(const std::string& property_name,
const NPVariant* value) {
VLOG(2) << "SetProperty " << property_name;
CHECK_EQ(base::PlatformThread::CurrentId(), np_thread_id_);
if (property_name == kAttrNameOnNatTraversalPolicyChanged) {
if (NPVARIANT_IS_OBJECT(*value)) {
on_nat_traversal_policy_changed_func_ = NPVARIANT_TO_OBJECT(*value);
bool policy_received, nat_traversal_enabled;
{
base::AutoLock lock(nat_policy_lock_);
policy_received = policy_received_;
nat_traversal_enabled = nat_traversal_enabled_;
}
if (policy_received) {
UpdateWebappNatPolicy(nat_traversal_enabled);
}
return true;
} else {
SetException("SetProperty: unexpected type for property " +
property_name);
}
return false;
}
if (property_name == kAttrNameOnStateChanged) {
if (NPVARIANT_IS_OBJECT(*value)) {
on_state_changed_func_ = NPVARIANT_TO_OBJECT(*value);
return true;
} else {
SetException("SetProperty: unexpected type for property " +
property_name);
}
return false;
}
if (property_name == kAttrNameLogDebugInfo) {
if (NPVARIANT_IS_OBJECT(*value)) {
log_debug_info_func_ = NPVARIANT_TO_OBJECT(*value);
HostLogHandler::RegisterLoggingScriptObject(this);
return true;
} else {
SetException("SetProperty: unexpected type for property " +
property_name);
}
return false;
}
return false;
}
| 6,010 |
91,208 | 0 | static ssize_t add_dev_support_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, "0x%02x\n", id.additional_device_support);
}
| 6,011 |
138,703 | 0 | RenderWidgetHostViewBase* RenderFrameHostImpl::GetViewForAccessibility() {
return static_cast<RenderWidgetHostViewBase*>(
frame_tree_node_->IsMainFrame()
? render_view_host_->GetWidget()->GetView()
: frame_tree_node_->frame_tree()
->GetMainFrame()
->render_view_host_->GetWidget()
->GetView());
}
| 6,012 |
39,187 | 0 | nfs_reqs_to_commit(struct nfs_commit_info *cinfo)
{
return cinfo->mds->ncommit;
}
| 6,013 |
140,955 | 0 | bool Document::AllowedToUseDynamicMarkUpInsertion(
const char* api_name,
ExceptionState& exception_state) {
if (!RuntimeEnabledFeatures::ExperimentalProductivityFeaturesEnabled()) {
return true;
}
if (!frame_ || IsFeatureEnabled(mojom::FeaturePolicyFeature::kDocumentWrite,
ReportOptions::kReportOnFailure)) {
return true;
}
exception_state.ThrowDOMException(
DOMExceptionCode::kNotAllowedError,
String::Format(
"The use of method '%s' has been blocked by feature policy. The "
"feature "
"'document-write' is disabled in this document.",
api_name));
return false;
}
| 6,014 |
42,514 | 0 | static ssize_t recovery_start_show(struct md_rdev *rdev, char *page)
{
unsigned long long recovery_start = rdev->recovery_offset;
if (test_bit(In_sync, &rdev->flags) ||
recovery_start == MaxSector)
return sprintf(page, "none\n");
return sprintf(page, "%llu\n", recovery_start);
}
| 6,015 |
45,732 | 0 | static struct crypto_instance *crypto_gcm_alloc(struct rtattr **tb)
{
const char *cipher_name;
char ctr_name[CRYPTO_MAX_ALG_NAME];
char full_name[CRYPTO_MAX_ALG_NAME];
cipher_name = crypto_attr_alg_name(tb[1]);
if (IS_ERR(cipher_name))
return ERR_CAST(cipher_name);
if (snprintf(ctr_name, CRYPTO_MAX_ALG_NAME, "ctr(%s)", cipher_name) >=
CRYPTO_MAX_ALG_NAME)
return ERR_PTR(-ENAMETOOLONG);
if (snprintf(full_name, CRYPTO_MAX_ALG_NAME, "gcm(%s)", cipher_name) >=
CRYPTO_MAX_ALG_NAME)
return ERR_PTR(-ENAMETOOLONG);
return crypto_gcm_alloc_common(tb, full_name, ctr_name, "ghash");
}
| 6,016 |
169,798 | 0 | exsltDateSecondInMinute (const xmlChar *dateTime)
{
exsltDateValPtr dt;
double ret;
if (dateTime == NULL) {
#ifdef WITH_TIME
dt = exsltDateCurrent();
if (dt == NULL)
#endif
return xmlXPathNAN;
} else {
dt = exsltDateParse(dateTime);
if (dt == NULL)
return xmlXPathNAN;
if ((dt->type != XS_DATETIME) && (dt->type != XS_TIME)) {
exsltDateFreeDate(dt);
return xmlXPathNAN;
}
}
ret = dt->value.date.sec;
exsltDateFreeDate(dt);
return ret;
}
| 6,017 |
127,146 | 0 | void SetProfiles(std::vector<AutofillProfile>* profiles) {
WindowedPersonalDataManagerObserver observer(browser());
personal_data_manager()->SetProfiles(profiles);
observer.Wait();
}
| 6,018 |
159,226 | 0 | DownloadManagerImpl::UniqueUrlDownloadHandlerPtr BeginDownload(
std::unique_ptr<DownloadUrlParameters> params,
content::ResourceContext* resource_context,
uint32_t download_id,
base::WeakPtr<DownloadManagerImpl> download_manager) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
std::unique_ptr<net::URLRequest> url_request =
DownloadRequestCore::CreateRequestOnIOThread(download_id, params.get());
std::unique_ptr<storage::BlobDataHandle> blob_data_handle =
params->GetBlobDataHandle();
if (blob_data_handle) {
storage::BlobProtocolHandler::SetRequestedBlobDataHandle(
url_request.get(), std::move(blob_data_handle));
}
if (params->render_process_host_id() >= 0) {
DownloadInterruptReason reason = DownloadManagerImpl::BeginDownloadRequest(
std::move(url_request), params->referrer(), resource_context,
params->content_initiated(), params->render_process_host_id(),
params->render_view_host_routing_id(),
params->render_frame_host_routing_id(),
params->do_not_prompt_for_login());
if (reason == DOWNLOAD_INTERRUPT_REASON_NONE)
return nullptr;
CreateInterruptedDownload(params.get(), reason, download_manager);
return nullptr;
}
return DownloadManagerImpl::UniqueUrlDownloadHandlerPtr(
UrlDownloader::BeginDownload(download_manager, std::move(url_request),
params->referrer(), false)
.release());
}
| 6,019 |
136,924 | 0 | static bool IsValidMIMEType(const String& type) {
size_t slash_position = type.find('/');
if (slash_position == kNotFound || !slash_position ||
slash_position == type.length() - 1)
return false;
for (size_t i = 0; i < type.length(); ++i) {
if (!IsRFC2616TokenCharacter(type[i]) && i != slash_position)
return false;
}
return true;
}
| 6,020 |
74,318 | 0 | bool set_pool(PgSocket *client, const char *dbname, const char *username)
{
PgDatabase *db;
PgUser *user;
/* find database */
db = find_database(dbname);
if (!db) {
db = register_auto_database(dbname);
if (!db) {
disconnect_client(client, true, "No such database: %s", dbname);
return false;
}
else {
slog_info(client, "registered new auto-database: db = %s", dbname );
}
}
/* find user */
if (cf_auth_type == AUTH_ANY) {
/* ignore requested user */
user = NULL;
if (db->forced_user == NULL) {
slog_error(client, "auth_type=any requires forced user");
disconnect_client(client, true, "bouncer config error");
return false;
}
client->auth_user = db->forced_user;
} else {
/* the user clients wants to log in as */
user = find_user(username);
if (!user) {
disconnect_client(client, true, "No such user: %s", username);
return false;
}
client->auth_user = user;
}
/* pool user may be forced */
if (db->forced_user)
user = db->forced_user;
client->pool = get_pool(db, user);
if (!client->pool) {
disconnect_client(client, true, "no memory for pool");
return false;
}
return check_fast_fail(client);
}
| 6,021 |
176,388 | 0 | uint8_t btif_av_get_peer_sep(void) { return btif_av_cb.peer_sep; }
| 6,022 |
112,468 | 0 | Locale& Document::getCachedLocale(const AtomicString& locale)
{
AtomicString localeKey = locale;
if (locale.isEmpty() || !RuntimeEnabledFeatures::langAttributeAwareFormControlUIEnabled())
localeKey = defaultLanguage();
LocaleIdentifierToLocaleMap::AddResult result = m_localeCache.add(localeKey, nullptr);
if (result.isNewEntry)
result.iterator->value = Locale::create(localeKey);
return *(result.iterator->value);
}
| 6,023 |
168,605 | 0 | Status IndexedDBDatabase::CountOperation(
int64_t object_store_id,
int64_t index_id,
std::unique_ptr<IndexedDBKeyRange> key_range,
scoped_refptr<IndexedDBCallbacks> callbacks,
IndexedDBTransaction* transaction) {
IDB_TRACE1("IndexedDBDatabase::CountOperation", "txn.id", transaction->id());
uint32_t count = 0;
std::unique_ptr<IndexedDBBackingStore::Cursor> backing_store_cursor;
Status s = Status::OK();
if (index_id == IndexedDBIndexMetadata::kInvalidId) {
backing_store_cursor = backing_store_->OpenObjectStoreKeyCursor(
transaction->BackingStoreTransaction(), id(), object_store_id,
*key_range, blink::kWebIDBCursorDirectionNext, &s);
} else {
backing_store_cursor = backing_store_->OpenIndexKeyCursor(
transaction->BackingStoreTransaction(), id(), object_store_id, index_id,
*key_range, blink::kWebIDBCursorDirectionNext, &s);
}
if (!s.ok()) {
DLOG(ERROR) << "Unable perform count operation: " << s.ToString();
return s;
}
if (!backing_store_cursor) {
callbacks->OnSuccess(count);
return s;
}
do {
if (!s.ok())
return s;
++count;
} while (backing_store_cursor->Continue(&s));
callbacks->OnSuccess(count);
return s;
}
| 6,024 |
169,452 | 0 | static void ResetMonitor() {
NetworkActivityMonitor* monitor = NetworkActivityMonitor::GetInstance();
base::AutoLock lock(monitor->lock_);
monitor->bytes_sent_ = 0;
monitor->bytes_received_ = 0;
monitor->last_received_ticks_ = base::TimeTicks();
monitor->last_sent_ticks_ = base::TimeTicks();
}
| 6,025 |
42,122 | 0 | monitor_init(void)
{
struct ssh *ssh = active_state; /* XXX */
struct monitor *mon;
mon = xcalloc(1, sizeof(*mon));
monitor_openfds(mon, 1);
/* Used to share zlib space across processes */
if (options.compression) {
mon->m_zback = mm_create(NULL, MM_MEMSIZE);
mon->m_zlib = mm_create(mon->m_zback, 20 * MM_MEMSIZE);
/* Compression needs to share state across borders */
ssh_packet_set_compress_hooks(ssh, mon->m_zlib,
(ssh_packet_comp_alloc_func *)mm_zalloc,
(ssh_packet_comp_free_func *)mm_zfree);
}
return mon;
}
| 6,026 |
106,796 | 0 | void AddDeleteUninstallShortcutsForMSIWorkItems(
const InstallerState& installer_state,
const Product& product,
const FilePath& temp_path,
WorkItemList* work_item_list) {
DCHECK(installer_state.is_msi())
<< "This must only be called for MSI installations!";
HKEY reg_root = installer_state.root_key();
std::wstring uninstall_reg(product.distribution()->GetUninstallRegPath());
WorkItem* delete_reg_key = work_item_list->AddDeleteRegKeyWorkItem(
reg_root, uninstall_reg);
delete_reg_key->set_ignore_failure(true);
FilePath uninstall_link;
if (installer_state.system_install()) {
PathService::Get(base::DIR_COMMON_START_MENU, &uninstall_link);
} else {
PathService::Get(base::DIR_START_MENU, &uninstall_link);
}
if (uninstall_link.empty()) {
LOG(ERROR) << "Failed to get location for shortcut.";
} else {
uninstall_link = uninstall_link.Append(
product.distribution()->GetAppShortCutName());
uninstall_link = uninstall_link.Append(
product.distribution()->GetUninstallLinkName() + L".lnk");
VLOG(1) << "Deleting old uninstall shortcut (if present): "
<< uninstall_link.value();
WorkItem* delete_link = work_item_list->AddDeleteTreeWorkItem(
uninstall_link, temp_path);
delete_link->set_ignore_failure(true);
delete_link->set_log_message(
"Failed to delete old uninstall shortcut.");
}
}
| 6,027 |
68,078 | 0 | static void __r_bin_class_free(RBinClass *p) {
r_list_free (p->methods);
r_list_free (p->fields);
r_bin_class_free (p);
}
| 6,028 |
21,835 | 0 | static void save_state_to_tss32(struct x86_emulate_ctxt *ctxt,
struct tss_segment_32 *tss)
{
tss->cr3 = ctxt->ops->get_cr(ctxt, 3);
tss->eip = ctxt->_eip;
tss->eflags = ctxt->eflags;
tss->eax = ctxt->regs[VCPU_REGS_RAX];
tss->ecx = ctxt->regs[VCPU_REGS_RCX];
tss->edx = ctxt->regs[VCPU_REGS_RDX];
tss->ebx = ctxt->regs[VCPU_REGS_RBX];
tss->esp = ctxt->regs[VCPU_REGS_RSP];
tss->ebp = ctxt->regs[VCPU_REGS_RBP];
tss->esi = ctxt->regs[VCPU_REGS_RSI];
tss->edi = ctxt->regs[VCPU_REGS_RDI];
tss->es = get_segment_selector(ctxt, VCPU_SREG_ES);
tss->cs = get_segment_selector(ctxt, VCPU_SREG_CS);
tss->ss = get_segment_selector(ctxt, VCPU_SREG_SS);
tss->ds = get_segment_selector(ctxt, VCPU_SREG_DS);
tss->fs = get_segment_selector(ctxt, VCPU_SREG_FS);
tss->gs = get_segment_selector(ctxt, VCPU_SREG_GS);
tss->ldt_selector = get_segment_selector(ctxt, VCPU_SREG_LDTR);
}
| 6,029 |
92,372 | 0 | storeEntityValue(XML_Parser parser,
const ENCODING *enc,
const char *entityTextPtr,
const char *entityTextEnd)
{
DTD * const dtd = parser->m_dtd; /* save one level of indirection */
STRING_POOL *pool = &(dtd->entityValuePool);
enum XML_Error result = XML_ERROR_NONE;
#ifdef XML_DTD
int oldInEntityValue = parser->m_prologState.inEntityValue;
parser->m_prologState.inEntityValue = 1;
#endif /* XML_DTD */
/* never return Null for the value argument in EntityDeclHandler,
since this would indicate an external entity; therefore we
have to make sure that entityValuePool.start is not null */
if (!pool->blocks) {
if (!poolGrow(pool))
return XML_ERROR_NO_MEMORY;
}
for (;;) {
const char *next;
int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next);
switch (tok) {
case XML_TOK_PARAM_ENTITY_REF:
#ifdef XML_DTD
if (parser->m_isParamEntity || enc != parser->m_encoding) {
const XML_Char *name;
ENTITY *entity;
name = poolStoreString(&parser->m_tempPool, enc,
entityTextPtr + enc->minBytesPerChar,
next - enc->minBytesPerChar);
if (!name) {
result = XML_ERROR_NO_MEMORY;
goto endEntityValue;
}
entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0);
poolDiscard(&parser->m_tempPool);
if (!entity) {
/* not a well-formedness error - see XML 1.0: WFC Entity Declared */
/* cannot report skipped entity here - see comments on
parser->m_skippedEntityHandler
if (parser->m_skippedEntityHandler)
parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0);
*/
dtd->keepProcessing = dtd->standalone;
goto endEntityValue;
}
if (entity->open) {
if (enc == parser->m_encoding)
parser->m_eventPtr = entityTextPtr;
result = XML_ERROR_RECURSIVE_ENTITY_REF;
goto endEntityValue;
}
if (entity->systemId) {
if (parser->m_externalEntityRefHandler) {
dtd->paramEntityRead = XML_FALSE;
entity->open = XML_TRUE;
if (!parser->m_externalEntityRefHandler(parser->m_externalEntityRefHandlerArg,
0,
entity->base,
entity->systemId,
entity->publicId)) {
entity->open = XML_FALSE;
result = XML_ERROR_EXTERNAL_ENTITY_HANDLING;
goto endEntityValue;
}
entity->open = XML_FALSE;
if (!dtd->paramEntityRead)
dtd->keepProcessing = dtd->standalone;
}
else
dtd->keepProcessing = dtd->standalone;
}
else {
entity->open = XML_TRUE;
result = storeEntityValue(parser,
parser->m_internalEncoding,
(char *)entity->textPtr,
(char *)(entity->textPtr
+ entity->textLen));
entity->open = XML_FALSE;
if (result)
goto endEntityValue;
}
break;
}
#endif /* XML_DTD */
/* In the internal subset, PE references are not legal
within markup declarations, e.g entity values in this case. */
parser->m_eventPtr = entityTextPtr;
result = XML_ERROR_PARAM_ENTITY_REF;
goto endEntityValue;
case XML_TOK_NONE:
result = XML_ERROR_NONE;
goto endEntityValue;
case XML_TOK_ENTITY_REF:
case XML_TOK_DATA_CHARS:
if (!poolAppend(pool, enc, entityTextPtr, next)) {
result = XML_ERROR_NO_MEMORY;
goto endEntityValue;
}
break;
case XML_TOK_TRAILING_CR:
next = entityTextPtr + enc->minBytesPerChar;
/* fall through */
case XML_TOK_DATA_NEWLINE:
if (pool->end == pool->ptr && !poolGrow(pool)) {
result = XML_ERROR_NO_MEMORY;
goto endEntityValue;
}
*(pool->ptr)++ = 0xA;
break;
case XML_TOK_CHAR_REF:
{
XML_Char buf[XML_ENCODE_MAX];
int i;
int n = XmlCharRefNumber(enc, entityTextPtr);
if (n < 0) {
if (enc == parser->m_encoding)
parser->m_eventPtr = entityTextPtr;
result = XML_ERROR_BAD_CHAR_REF;
goto endEntityValue;
}
n = XmlEncode(n, (ICHAR *)buf);
/* The XmlEncode() functions can never return 0 here. That
* error return happens if the code point passed in is either
* negative or greater than or equal to 0x110000. The
* XmlCharRefNumber() functions will all return a number
* strictly less than 0x110000 or a negative value if an error
* occurred. The negative value is intercepted above, so
* XmlEncode() is never passed a value it might return an
* error for.
*/
for (i = 0; i < n; i++) {
if (pool->end == pool->ptr && !poolGrow(pool)) {
result = XML_ERROR_NO_MEMORY;
goto endEntityValue;
}
*(pool->ptr)++ = buf[i];
}
}
break;
case XML_TOK_PARTIAL:
if (enc == parser->m_encoding)
parser->m_eventPtr = entityTextPtr;
result = XML_ERROR_INVALID_TOKEN;
goto endEntityValue;
case XML_TOK_INVALID:
if (enc == parser->m_encoding)
parser->m_eventPtr = next;
result = XML_ERROR_INVALID_TOKEN;
goto endEntityValue;
default:
/* This default case should be unnecessary -- all the tokens
* that XmlEntityValueTok() can return have their own explicit
* cases -- but should be retained for safety. We do however
* exclude it from the coverage statistics.
*
* LCOV_EXCL_START
*/
if (enc == parser->m_encoding)
parser->m_eventPtr = entityTextPtr;
result = XML_ERROR_UNEXPECTED_STATE;
goto endEntityValue;
/* LCOV_EXCL_STOP */
}
entityTextPtr = next;
}
endEntityValue:
#ifdef XML_DTD
parser->m_prologState.inEntityValue = oldInEntityValue;
#endif /* XML_DTD */
return result;
}
| 6,030 |
126,193 | 0 | void Browser::HandleKeyboardEvent(content::WebContents* source,
const NativeWebKeyboardEvent& event) {
window()->HandleKeyboardEvent(event);
}
| 6,031 |
139,515 | 0 | static bool ExecuteToggleBold(LocalFrame& frame,
Event*,
EditorCommandSource source,
const String&) {
return ExecuteToggleStyle(frame, source, InputEvent::InputType::kFormatBold,
CSSPropertyFontWeight, "normal", "bold");
}
| 6,032 |
25,627 | 0 | void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t pte)
{
}
| 6,033 |
156,421 | 0 | Response PageHandler::StartScreencast(Maybe<std::string> format,
Maybe<int> quality,
Maybe<int> max_width,
Maybe<int> max_height,
Maybe<int> every_nth_frame) {
WebContentsImpl* web_contents = GetWebContents();
if (!web_contents)
return Response::InternalError();
RenderWidgetHostImpl* widget_host =
host_ ? host_->GetRenderWidgetHost() : nullptr;
if (!widget_host)
return Response::InternalError();
screencast_enabled_ = true;
screencast_format_ = format.fromMaybe(kPng);
screencast_quality_ = quality.fromMaybe(kDefaultScreenshotQuality);
if (screencast_quality_ < 0 || screencast_quality_ > 100)
screencast_quality_ = kDefaultScreenshotQuality;
screencast_max_width_ = max_width.fromMaybe(-1);
screencast_max_height_ = max_height.fromMaybe(-1);
++session_id_;
frame_counter_ = 0;
frames_in_flight_ = 0;
capture_every_nth_frame_ = every_nth_frame.fromMaybe(1);
bool visible = !widget_host->is_hidden();
NotifyScreencastVisibility(visible);
if (video_consumer_) {
gfx::Size surface_size = gfx::Size();
RenderWidgetHostViewBase* const view =
static_cast<RenderWidgetHostViewBase*>(host_->GetView());
if (view) {
surface_size = view->GetCompositorViewportPixelSize();
last_surface_size_ = surface_size;
}
gfx::Size snapshot_size = DetermineSnapshotSize(
surface_size, screencast_max_width_, screencast_max_height_);
if (!snapshot_size.IsEmpty())
video_consumer_->SetMinAndMaxFrameSize(snapshot_size, snapshot_size);
video_consumer_->StartCapture();
return Response::FallThrough();
}
if (!visible)
return Response::FallThrough();
if (has_compositor_frame_metadata_) {
InnerSwapCompositorFrame();
} else {
widget_host->Send(
new WidgetMsg_ForceRedraw(widget_host->GetRoutingID(), 0));
}
return Response::FallThrough();
}
| 6,034 |
120,756 | 0 | void FakeBluetoothAgentManagerClient::RegisterAgentServiceProvider(
FakeBluetoothAgentServiceProvider* service_provider) {
service_provider_ = service_provider;
}
| 6,035 |
38,626 | 0 | void flush_thread(void)
{
discard_lazy_cpu_state();
#ifdef CONFIG_HAVE_HW_BREAKPOINT
flush_ptrace_hw_breakpoint(current);
#else /* CONFIG_HAVE_HW_BREAKPOINT */
set_debug_reg_defaults(¤t->thread);
#endif /* CONFIG_HAVE_HW_BREAKPOINT */
}
| 6,036 |
122,457 | 0 | String HTMLTextAreaElement::suggestedValue() const
{
return m_suggestedValue;
}
| 6,037 |
168,122 | 0 | void ExpectFilledField(const char* expected_label,
const char* expected_name,
const char* expected_value,
const char* expected_form_control_type,
const FormFieldData& field) {
SCOPED_TRACE(expected_label);
EXPECT_EQ(UTF8ToUTF16(expected_label), field.label);
EXPECT_EQ(UTF8ToUTF16(expected_name), field.name);
EXPECT_EQ(UTF8ToUTF16(expected_value), field.value);
EXPECT_EQ(expected_form_control_type, field.form_control_type);
}
| 6,038 |
187,488 | 1 | static inline void set_socket_blocking(int s, int blocking)
{
int opts;
opts = fcntl(s, F_GETFL);
if (opts<0) APPL_TRACE_ERROR("set blocking (%s)", strerror(errno));
if(blocking)
opts &= ~O_NONBLOCK;
else opts |= O_NONBLOCK;
if (fcntl(s, F_SETFL, opts) < 0)
APPL_TRACE_ERROR("set blocking (%s)", strerror(errno));
}
| 6,039 |
89,139 | 0 | compile_tree(Node* node, regex_t* reg, ScanEnv* env)
{
int n, len, pos, r = 0;
switch (NODE_TYPE(node)) {
case NODE_LIST:
do {
r = compile_tree(NODE_CAR(node), reg, env);
} while (r == 0 && IS_NOT_NULL(node = NODE_CDR(node)));
break;
case NODE_ALT:
{
Node* x = node;
len = 0;
do {
len += compile_length_tree(NODE_CAR(x), reg);
if (IS_NOT_NULL(NODE_CDR(x))) {
len += SIZE_OP_PUSH + SIZE_OP_JUMP;
}
} while (IS_NOT_NULL(x = NODE_CDR(x)));
pos = COP_CURR_OFFSET(reg) + 1 + len; /* goal position */
do {
len = compile_length_tree(NODE_CAR(node), reg);
if (IS_NOT_NULL(NODE_CDR(node))) {
enum OpCode push = NODE_IS_SUPER(node) ? OP_PUSH_SUPER : OP_PUSH;
r = add_op(reg, push);
if (r != 0) break;
COP(reg)->push.addr = SIZE_INC_OP + len + SIZE_OP_JUMP;
}
r = compile_tree(NODE_CAR(node), reg, env);
if (r != 0) break;
if (IS_NOT_NULL(NODE_CDR(node))) {
len = pos - (COP_CURR_OFFSET(reg) + 1);
r = add_op(reg, OP_JUMP);
if (r != 0) break;
COP(reg)->jump.addr = len;
}
} while (IS_NOT_NULL(node = NODE_CDR(node)));
}
break;
case NODE_STRING:
if (NODE_STRING_IS_RAW(node))
r = compile_string_raw_node(STR_(node), reg);
else
r = compile_string_node(node, reg);
break;
case NODE_CCLASS:
r = compile_cclass_node(CCLASS_(node), reg);
break;
case NODE_CTYPE:
{
int op;
switch (CTYPE_(node)->ctype) {
case CTYPE_ANYCHAR:
r = add_op(reg, IS_MULTILINE(CTYPE_OPTION(node, reg)) ?
OP_ANYCHAR_ML : OP_ANYCHAR);
break;
case ONIGENC_CTYPE_WORD:
if (CTYPE_(node)->ascii_mode == 0) {
op = CTYPE_(node)->not != 0 ? OP_NO_WORD : OP_WORD;
}
else {
op = CTYPE_(node)->not != 0 ? OP_NO_WORD_ASCII : OP_WORD_ASCII;
}
r = add_op(reg, op);
break;
default:
return ONIGERR_TYPE_BUG;
break;
}
}
break;
case NODE_BACKREF:
{
BackRefNode* br = BACKREF_(node);
if (NODE_IS_CHECKER(node)) {
#ifdef USE_BACKREF_WITH_LEVEL
if (NODE_IS_NEST_LEVEL(node)) {
r = add_op(reg, OP_BACKREF_CHECK_WITH_LEVEL);
if (r != 0) return r;
COP(reg)->backref_general.nest_level = br->nest_level;
}
else
#endif
{
r = add_op(reg, OP_BACKREF_CHECK);
if (r != 0) return r;
}
goto add_bacref_mems;
}
else {
#ifdef USE_BACKREF_WITH_LEVEL
if (NODE_IS_NEST_LEVEL(node)) {
if ((reg->options & ONIG_OPTION_IGNORECASE) != 0)
r = add_op(reg, OP_BACKREF_WITH_LEVEL_IC);
else
r = add_op(reg, OP_BACKREF_WITH_LEVEL);
if (r != 0) return r;
COP(reg)->backref_general.nest_level = br->nest_level;
goto add_bacref_mems;
}
else
#endif
if (br->back_num == 1) {
n = br->back_static[0];
if (IS_IGNORECASE(reg->options)) {
r = add_op(reg, OP_BACKREF_N_IC);
if (r != 0) return r;
COP(reg)->backref_n.n1 = n;
}
else {
switch (n) {
case 1: r = add_op(reg, OP_BACKREF1); break;
case 2: r = add_op(reg, OP_BACKREF2); break;
default:
r = add_op(reg, OP_BACKREF_N);
if (r != 0) return r;
COP(reg)->backref_n.n1 = n;
break;
}
}
}
else {
int num;
int* p;
r = add_op(reg, IS_IGNORECASE(reg->options) ?
OP_BACKREF_MULTI_IC : OP_BACKREF_MULTI);
if (r != 0) return r;
add_bacref_mems:
num = br->back_num;
COP(reg)->backref_general.num = num;
if (num == 1) {
COP(reg)->backref_general.n1 = br->back_static[0];
}
else {
int i, j;
MemNumType* ns;
ns = xmalloc(sizeof(MemNumType) * num);
CHECK_NULL_RETURN_MEMERR(ns);
COP(reg)->backref_general.ns = ns;
p = BACKREFS_P(br);
for (i = num - 1, j = 0; i >= 0; i--, j++) {
ns[j] = p[i];
}
}
}
}
}
break;
#ifdef USE_CALL
case NODE_CALL:
r = compile_call(CALL_(node), reg, env);
break;
#endif
case NODE_QUANT:
r = compile_quantifier_node(QUANT_(node), reg, env);
break;
case NODE_BAG:
r = compile_bag_node(BAG_(node), reg, env);
break;
case NODE_ANCHOR:
r = compile_anchor_node(ANCHOR_(node), reg, env);
break;
case NODE_GIMMICK:
r = compile_gimmick_node(GIMMICK_(node), reg);
break;
default:
#ifdef ONIG_DEBUG
fprintf(stderr, "compile_tree: undefined node type %d\n", NODE_TYPE(node));
#endif
break;
}
return r;
}
| 6,040 |
179,774 | 1 | static void save_text_if_changed(const char *name, const char *new_value)
{
/* a text value can't be change if the file is not loaded */
/* returns NULL if the name is not found; otherwise nonzero */
if (!g_hash_table_lookup(g_loaded_texts, name))
return;
const char *old_value = g_cd ? problem_data_get_content_or_NULL(g_cd, name) : "";
if (!old_value)
old_value = "";
if (strcmp(new_value, old_value) != 0)
{
struct dump_dir *dd = wizard_open_directory_for_writing(g_dump_dir_name);
if (dd)
dd_save_text(dd, name, new_value);
//FIXME: else: what to do with still-unsaved data in the widget??
dd_close(dd);
problem_data_reload_from_dump_dir();
update_gui_state_from_problem_data(/* don't update selected event */ 0);
}
}
| 6,041 |
165,455 | 0 | void Document::PropagateStyleToViewport() {
DCHECK(InStyleRecalc());
if (!documentElement())
return;
HTMLElement* body = this->body();
const ComputedStyle* body_style =
body ? body->EnsureComputedStyle() : nullptr;
const ComputedStyle* document_element_style =
documentElement()->EnsureComputedStyle();
TouchAction effective_touch_action =
document_element_style->GetEffectiveTouchAction();
WritingMode root_writing_mode = document_element_style->GetWritingMode();
TextDirection root_direction = document_element_style->Direction();
if (body_style) {
root_writing_mode = body_style->GetWritingMode();
root_direction = body_style->Direction();
}
const ComputedStyle* background_style = document_element_style;
if (IsHTMLHtmlElement(documentElement()) &&
document_element_style->Display() != EDisplay::kNone &&
IsHTMLBodyElement(body) && !background_style->HasBackground()) {
background_style = body_style;
}
Color background_color = Color::kTransparent;
FillLayer background_layers(EFillLayerType::kBackground, true);
EImageRendering image_rendering = EImageRendering::kAuto;
if (background_style->Display() != EDisplay::kNone) {
background_color = background_style->VisitedDependentColor(
GetCSSPropertyBackgroundColor());
background_layers = background_style->BackgroundLayers();
for (auto* current_layer = &background_layers; current_layer;
current_layer = current_layer->Next()) {
current_layer->SetClip(EFillBox::kBorder);
if (current_layer->Attachment() == EFillAttachment::kScroll)
current_layer->SetAttachment(EFillAttachment::kLocal);
}
image_rendering = background_style->ImageRendering();
}
const ComputedStyle* overflow_style = nullptr;
Element* viewport_element = ViewportDefiningElement();
DCHECK(viewport_element);
if (viewport_element == body) {
overflow_style = body_style;
} else {
DCHECK_EQ(viewport_element, documentElement());
overflow_style = document_element_style;
if (body_style && !body_style->IsOverflowVisible())
UseCounter::Count(*this, WebFeature::kBodyScrollsInAdditionToViewport);
}
DCHECK(overflow_style);
EOverflowAnchor overflow_anchor = overflow_style->OverflowAnchor();
EOverflow overflow_x = overflow_style->OverflowX();
EOverflow overflow_y = overflow_style->OverflowY();
if (overflow_x == EOverflow::kVisible)
overflow_x = EOverflow::kAuto;
if (overflow_y == EOverflow::kVisible)
overflow_y = EOverflow::kAuto;
if (overflow_anchor == EOverflowAnchor::kVisible)
overflow_anchor = EOverflowAnchor::kAuto;
GapLength column_gap = overflow_style->ColumnGap();
ScrollSnapType snap_type = overflow_style->GetScrollSnapType();
ScrollBehavior scroll_behavior = document_element_style->GetScrollBehavior();
EOverscrollBehavior overscroll_behavior_x =
overflow_style->OverscrollBehaviorX();
EOverscrollBehavior overscroll_behavior_y =
overflow_style->OverscrollBehaviorY();
using OverscrollBehaviorType = cc::OverscrollBehavior::OverscrollBehaviorType;
if (IsInMainFrame()) {
GetPage()->GetOverscrollController().SetOverscrollBehavior(
cc::OverscrollBehavior(
static_cast<OverscrollBehaviorType>(overscroll_behavior_x),
static_cast<OverscrollBehaviorType>(overscroll_behavior_y)));
}
Length scroll_padding_top = overflow_style->ScrollPaddingTop();
Length scroll_padding_right = overflow_style->ScrollPaddingRight();
Length scroll_padding_bottom = overflow_style->ScrollPaddingBottom();
Length scroll_padding_left = overflow_style->ScrollPaddingLeft();
const ComputedStyle& viewport_style = GetLayoutView()->StyleRef();
if (viewport_style.GetWritingMode() != root_writing_mode ||
viewport_style.Direction() != root_direction ||
viewport_style.VisitedDependentColor(GetCSSPropertyBackgroundColor()) !=
background_color ||
viewport_style.BackgroundLayers() != background_layers ||
viewport_style.ImageRendering() != image_rendering ||
viewport_style.OverflowAnchor() != overflow_anchor ||
viewport_style.OverflowX() != overflow_x ||
viewport_style.OverflowY() != overflow_y ||
viewport_style.ColumnGap() != column_gap ||
viewport_style.GetScrollSnapType() != snap_type ||
viewport_style.GetScrollBehavior() != scroll_behavior ||
viewport_style.OverscrollBehaviorX() != overscroll_behavior_x ||
viewport_style.OverscrollBehaviorY() != overscroll_behavior_y ||
viewport_style.ScrollPaddingTop() != scroll_padding_top ||
viewport_style.ScrollPaddingRight() != scroll_padding_right ||
viewport_style.ScrollPaddingBottom() != scroll_padding_bottom ||
viewport_style.ScrollPaddingLeft() != scroll_padding_left ||
viewport_style.GetEffectiveTouchAction() != effective_touch_action) {
scoped_refptr<ComputedStyle> new_style =
ComputedStyle::Clone(viewport_style);
new_style->SetWritingMode(root_writing_mode);
new_style->UpdateFontOrientation();
new_style->SetDirection(root_direction);
new_style->SetBackgroundColor(background_color);
new_style->AccessBackgroundLayers() = background_layers;
new_style->SetImageRendering(image_rendering);
new_style->SetOverflowAnchor(overflow_anchor);
new_style->SetOverflowX(overflow_x);
new_style->SetOverflowY(overflow_y);
new_style->SetColumnGap(column_gap);
new_style->SetScrollSnapType(snap_type);
new_style->SetScrollBehavior(scroll_behavior);
new_style->SetOverscrollBehaviorX(overscroll_behavior_x);
new_style->SetOverscrollBehaviorY(overscroll_behavior_y);
new_style->SetScrollPaddingTop(scroll_padding_top);
new_style->SetScrollPaddingRight(scroll_padding_right);
new_style->SetScrollPaddingBottom(scroll_padding_bottom);
new_style->SetScrollPaddingLeft(scroll_padding_left);
new_style->SetEffectiveTouchAction(effective_touch_action);
GetLayoutView()->SetStyle(new_style);
SetupFontBuilder(*new_style);
if (PaintLayerScrollableArea* scrollable_area =
GetLayoutView()->GetScrollableArea()) {
if (scrollable_area->HorizontalScrollbar() &&
scrollable_area->HorizontalScrollbar()->IsCustomScrollbar())
scrollable_area->HorizontalScrollbar()->StyleChanged();
if (scrollable_area->VerticalScrollbar() &&
scrollable_area->VerticalScrollbar()->IsCustomScrollbar())
scrollable_area->VerticalScrollbar()->StyleChanged();
}
}
}
| 6,042 |
126,728 | 0 | BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
BrowserView* view = new BrowserView(browser);
(new BrowserFrame(view))->InitBrowserFrame();
view->GetWidget()->non_client_view()->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
return view;
}
| 6,043 |
108,218 | 0 | void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded(
const DictionaryValue& manifest) {
if (thread_identifier_ != BrowserThread::ID_COUNT)
DCHECK(BrowserThread::CurrentlyOn(thread_identifier_));
got_response_ = true;
scoped_ptr<DictionaryValue> final_manifest(RewriteManifestFile(manifest));
if (!final_manifest.get())
return;
std::string error;
if (!extension_l10n_util::LocalizeExtension(extension_root_,
final_manifest.get(),
&error)) {
ReportFailure(error);
return;
}
extension_ = Extension::Create(
extension_root_, Extension::INTERNAL, *final_manifest, true, &error);
if (!extension_.get()) {
ReportFailure(std::string("Manifest is invalid: ") + error);
return;
}
if (!RewriteImageFiles())
return;
if (!RewriteCatalogFiles())
return;
ReportSuccess();
}
| 6,044 |
90,337 | 0 | static void megasas_flush_cache(struct megasas_instance *instance)
{
struct megasas_cmd *cmd;
struct megasas_dcmd_frame *dcmd;
if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR)
return;
cmd = megasas_get_cmd(instance);
if (!cmd)
return;
dcmd = &cmd->frame->dcmd;
memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE);
dcmd->cmd = MFI_CMD_DCMD;
dcmd->cmd_status = 0x0;
dcmd->sge_count = 0;
dcmd->flags = cpu_to_le16(MFI_FRAME_DIR_NONE);
dcmd->timeout = 0;
dcmd->pad_0 = 0;
dcmd->data_xfer_len = 0;
dcmd->opcode = cpu_to_le32(MR_DCMD_CTRL_CACHE_FLUSH);
dcmd->mbox.b[0] = MR_FLUSH_CTRL_CACHE | MR_FLUSH_DISK_CACHE;
if (megasas_issue_blocked_cmd(instance, cmd, MFI_IO_TIMEOUT_SECS)
!= DCMD_SUCCESS) {
dev_err(&instance->pdev->dev,
"return from %s %d\n", __func__, __LINE__);
return;
}
megasas_return_cmd(instance, cmd);
}
| 6,045 |
77,897 | 0 | test_bson_append_undefined (void)
{
bson_t *b;
bson_t *b2;
b = bson_new ();
BSON_ASSERT (bson_append_undefined (b, "undefined", -1));
b2 = get_bson ("test25.bson");
BSON_ASSERT_BSON_EQUAL (b, b2);
bson_destroy (b);
bson_destroy (b2);
}
| 6,046 |
75,420 | 0 | static int opfsubrp(RAsm *a, ut8 *data, const Opcode *op) {
int l = 0;
switch (op->operands_count) {
case 0:
data[l++] = 0xde;
data[l++] = 0xe1;
break;
case 2:
if ( op->operands[0].type & OT_FPUREG & ~OT_REGALL &&
op->operands[1].type & OT_FPUREG & ~OT_REGALL && op->operands[1].reg == 0 ) {
data[l++] = 0xde;
data[l++] = 0xe0 | op->operands[0].reg;
} else {
return -1;
}
break;
default:
return -1;
}
return l;
}
| 6,047 |
166,908 | 0 | PerformanceEntryVector Performance::getEntries() {
PerformanceEntryVector entries;
entries.AppendVector(resource_timing_buffer_);
if (!navigation_timing_)
navigation_timing_ = CreateNavigationTimingInstance();
if (navigation_timing_)
entries.push_back(navigation_timing_);
entries.AppendVector(frame_timing_buffer_);
if (user_timing_) {
entries.AppendVector(user_timing_->GetMarks());
entries.AppendVector(user_timing_->GetMeasures());
}
if (first_paint_timing_)
entries.push_back(first_paint_timing_);
if (first_contentful_paint_timing_)
entries.push_back(first_contentful_paint_timing_);
std::sort(entries.begin(), entries.end(),
PerformanceEntry::StartTimeCompareLessThan);
return entries;
}
| 6,048 |
49,230 | 0 | static void do_redirect(struct sk_buff *skb, struct sock *sk)
{
struct dst_entry *dst = __sk_dst_check(sk, 0);
if (dst)
dst->ops->redirect(dst, sk, skb);
}
| 6,049 |
91,257 | 0 | static void intf_free(struct kref *ref)
{
struct ipmi_smi *intf = container_of(ref, struct ipmi_smi, refcount);
clean_up_interface_data(intf);
kfree(intf);
}
| 6,050 |
151,649 | 0 | void Browser::ActivateContents(WebContents* contents) {
tab_strip_model_->ActivateTabAt(
tab_strip_model_->GetIndexOfWebContents(contents), false);
window_->Activate();
}
| 6,051 |
185,457 | 1 | bool AsyncPixelTransfersCompletedQuery::End(
base::subtle::Atomic32 submit_count) {
AsyncMemoryParams mem_params;
Buffer buffer = manager()->decoder()->GetSharedMemoryBuffer(shm_id());
if (!buffer.shared_memory)
return false;
mem_params.shared_memory = buffer.shared_memory;
mem_params.shm_size = buffer.size;
mem_params.shm_data_offset = shm_offset();
mem_params.shm_data_size = sizeof(QuerySync);
observer_ = new AsyncPixelTransferCompletionObserverImpl(submit_count);
manager()->decoder()->GetAsyncPixelTransferManager()
->AsyncNotifyCompletion(mem_params, observer_);
return AddToPendingTransferQueue(submit_count);
}
| 6,052 |
21,337 | 0 | static void mpol_set_task_struct_flag(void)
{
mpol_fix_fork_child_flag(current);
}
| 6,053 |
121,606 | 0 | void TextIterator::handleTextNodeFirstLetter(RenderTextFragment* renderer)
{
if (renderer->firstLetter()) {
RenderObject* r = renderer->firstLetter();
if (r->style()->visibility() != VISIBLE && !m_ignoresStyleVisibility)
return;
if (RenderText* firstLetter = firstRenderTextInFirstLetter(r)) {
m_handledFirstLetter = true;
m_remainingTextBox = m_textBox;
m_textBox = firstLetter->firstTextBox();
m_sortedTextBoxes.clear();
m_firstLetterText = firstLetter;
}
}
m_handledFirstLetter = true;
}
| 6,054 |
140,359 | 0 | void Editor::replaceSelectionWithText(const String& text,
bool selectReplacement,
bool smartReplace,
InputEvent::InputType inputType) {
replaceSelectionWithFragment(createFragmentFromText(selectedRange(), text),
selectReplacement, smartReplace, true,
inputType);
}
| 6,055 |
126,072 | 0 | ~AutomationProviderDownloadModelChangedObserver() {}
| 6,056 |
24,940 | 0 | static void unfreeze_slab(struct kmem_cache *s, struct page *page, int tail)
{
struct kmem_cache_node *n = get_node(s, page_to_nid(page));
struct kmem_cache_cpu *c = get_cpu_slab(s, smp_processor_id());
ClearSlabFrozen(page);
if (page->inuse) {
if (page->freelist) {
add_partial(n, page, tail);
stat(c, tail ? DEACTIVATE_TO_TAIL : DEACTIVATE_TO_HEAD);
} else {
stat(c, DEACTIVATE_FULL);
if (SlabDebug(page) && (s->flags & SLAB_STORE_USER))
add_full(n, page);
}
slab_unlock(page);
} else {
stat(c, DEACTIVATE_EMPTY);
if (n->nr_partial < MIN_PARTIAL) {
/*
* Adding an empty slab to the partial slabs in order
* to avoid page allocator overhead. This slab needs
* to come after the other slabs with objects in
* so that the others get filled first. That way the
* size of the partial list stays small.
*
* kmem_cache_shrink can reclaim any empty slabs from the
* partial list.
*/
add_partial(n, page, 1);
slab_unlock(page);
} else {
slab_unlock(page);
stat(get_cpu_slab(s, raw_smp_processor_id()), FREE_SLAB);
discard_slab(s, page);
}
}
}
| 6,057 |
61,202 | 0 | nautilus_mime_activate_file (GtkWindow *parent_window,
NautilusWindowSlot *slot,
NautilusFile *file,
const char *launch_directory,
NautilusWindowOpenFlags flags)
{
GList *files;
g_return_if_fail (NAUTILUS_IS_FILE (file));
files = g_list_prepend (NULL, file);
nautilus_mime_activate_files (parent_window, slot, files, launch_directory, flags, FALSE);
g_list_free (files);
}
| 6,058 |
97,213 | 0 | void WebFrameLoaderClient::frameLoaderDestroyed() {
webframe_->Closing();
webframe_->Release();
}
| 6,059 |
46,111 | 0 | static int dtls1_handshake_write(SSL *s)
{
return dtls1_do_write(s, SSL3_RT_HANDSHAKE);
}
| 6,060 |
78,647 | 0 | piv_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *data, int *tries_left)
{
int r = 0;
piv_private_data_t * priv = PIV_DATA(card);
/* Extra validation of (new) PIN during a PIN change request, to
* ensure it's not outside the FIPS 201 4.1.6.1 (numeric only) and
* FIPS 140-2 (6 character minimum) requirements.
*/
struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
sc_log(card->ctx, "piv_pin_cmd tries_left=%d, logged_in=%d", priv->tries_left, priv->logged_in);
if (data->cmd == SC_PIN_CMD_CHANGE) {
int i = 0;
if (data->pin2.len < 6) {
return SC_ERROR_INVALID_PIN_LENGTH;
}
for(i=0; i < data->pin2.len; ++i) {
if (!isdigit(data->pin2.data[i])) {
return SC_ERROR_INVALID_DATA;
}
}
}
priv->pin_cmd_verify_sw1 = 0x00U;
if (data->cmd == SC_PIN_CMD_GET_INFO) { /* fill in what we think it should be */
data->pin1.logged_in = priv->logged_in;
data->pin1.tries_left = priv->tries_left;
if (tries_left)
*tries_left = priv->tries_left;
/*
* If called to check on the login state for a context specific login
* return not logged in. Needed because of logic in e6f7373ef066
*/
if (data->pin_type == SC_AC_CONTEXT_SPECIFIC) {
data->pin1.logged_in = 0;
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
}
if (priv->logged_in == SC_PIN_STATE_LOGGED_IN) {
/* Avoid status requests when the user is logged in to handle NIST
* 800-73-4 Part 2:
* The PKI cryptographic function (see Table 4b) is protected with
* a “PIN Always” or “OCC Always” access rule. In other words, the
* PIN or OCC data must be submitted and verified every time
* immediately before a digital signature key operation. This
* ensures cardholder participation every time the private key is
* used for digital signature generation */
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
}
}
/*
* If this was for a CKU_CONTEXT_SPECFIC login, lock the card one more time.
* to avoid any interference from other applications.
* Sc_unlock will be called at a later time after the next card command
* that should be a crypto operation. If its not then it is a error by the
* calling application.
*/
if (data->cmd == SC_PIN_CMD_VERIFY && data->pin_type == SC_AC_CONTEXT_SPECIFIC) {
priv->context_specific = 1;
sc_log(card->ctx,"Starting CONTEXT_SPECIFIC verify");
sc_lock(card);
}
priv->pin_cmd_verify = 1; /* tell piv_check_sw its a verify to save sw1, sw2 */
r = iso_drv->ops->pin_cmd(card, data, tries_left);
priv->pin_cmd_verify = 0;
/* if verify failed, release the lock */
if (data->cmd == SC_PIN_CMD_VERIFY && r < 0 && priv->context_specific) {
sc_log(card->ctx,"Clearing CONTEXT_SPECIFIC");
priv->context_specific = 0;
sc_unlock(card);
}
/* if access to applet is know to be reset by other driver we select_aid and try again */
if ( priv->card_issues & CI_OTHER_AID_LOSE_STATE && priv->pin_cmd_verify_sw1 == 0x6DU) {
sc_log(card->ctx, "AID may be lost doing piv_find_aid and retry pin_cmd");
piv_find_aid(card, priv->aid_file); /* return not tested */
priv->pin_cmd_verify = 1; /* tell piv_check_sw its a verify to save sw1, sw2 */
r = iso_drv->ops->pin_cmd(card, data, tries_left);
priv->pin_cmd_verify = 0;
}
/* If verify worked, we are logged_in */
if (data->cmd == SC_PIN_CMD_VERIFY) {
if (r >= 0)
priv->logged_in = SC_PIN_STATE_LOGGED_IN;
else
priv->logged_in = SC_PIN_STATE_LOGGED_OUT;
}
/* Some cards never return 90 00 for SC_PIN_CMD_GET_INFO even if the card state is verified */
/* PR 797 has changed the return codes from pin_cmd, and added a data->pin1.logged_in flag */
if (data->cmd == SC_PIN_CMD_GET_INFO) {
if (priv->card_issues & CI_CANT_USE_GETDATA_FOR_STATE) {
sc_log(card->ctx, "CI_CANT_USE_GETDATA_FOR_STATE set, assume logged_in=%d", priv->logged_in);
data->pin1.logged_in = priv->logged_in; /* use what ever we saw last */
} else if (priv->card_issues & CI_VERIFY_LC0_FAIL
&& priv->pin_cmd_verify_sw1 == 0x63U ) { /* can not use modified return codes from iso->drv->pin_cmd */
/* try another method, looking at a protected object this may require adding one of these to NEO */
r = piv_check_protected_objects(card);
if (r == SC_SUCCESS)
data->pin1.logged_in = SC_PIN_STATE_LOGGED_IN;
else if (r == SC_ERROR_PIN_CODE_INCORRECT) {
if (priv->card_issues & CI_CANT_USE_GETDATA_FOR_STATE) { /* we still can not determine login state */
data->pin1.logged_in = priv->logged_in; /* may have be set from SC_PIN_CMD_VERIFY */
/* TODO a reset may have logged us out. need to detect resets */
} else {
data->pin1.logged_in = SC_PIN_STATE_LOGGED_OUT;
}
r = SC_SUCCESS;
}
}
priv->logged_in = data->pin1.logged_in;
priv->tries_left = data->pin1.tries_left;
}
sc_log(card->ctx, "piv_pin_cmd tries_left=%d, logged_in=%d",priv->tries_left, priv->logged_in);
LOG_FUNC_RETURN(card->ctx, r);
}
| 6,061 |
177,976 | 1 | int tls1_set_server_sigalgs(SSL *s)
{
int al;
size_t i;
/* Clear any shared sigtnature algorithms */
if (s->cert->shared_sigalgs) {
OPENSSL_free(s->cert->shared_sigalgs);
s->cert->shared_sigalgs = NULL;
}
/* Clear certificate digests and validity flags */
for (i = 0; i < SSL_PKEY_NUM; i++) {
s->cert->pkeys[i].valid_flags = 0;
}
/* If sigalgs received process it. */
if (s->cert->peer_sigalgs) {
if (!tls1_process_sigalgs(s)) {
SSLerr(SSL_F_TLS1_SET_SERVER_SIGALGS, ERR_R_MALLOC_FAILURE);
al = SSL_AD_INTERNAL_ERROR;
goto err;
}
/* Fatal error is no shared signature algorithms */
if (!s->cert->shared_sigalgs) {
SSLerr(SSL_F_TLS1_SET_SERVER_SIGALGS,
SSL_R_NO_SHARED_SIGATURE_ALGORITHMS);
al = SSL_AD_ILLEGAL_PARAMETER;
goto err;
}
} else
ssl_cert_set_default_md(s->cert);
return 1;
err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
return 0;
}
| 6,062 |
152,925 | 0 | bool DevToolsClient::isUnderTest() {
return RenderThreadImpl::current()->layout_test_mode();
}
| 6,063 |
124,161 | 0 | void RenderViewHostManager::RendererAbortedProvisionalLoad(
RenderViewHost* render_view_host) {
}
| 6,064 |
116,277 | 0 | int QQuickWebViewExperimental::preferredMinimumContentsWidth() const
{
Q_D(const QQuickWebView);
return d->webPageProxy->pageGroup()->preferences()->layoutFallbackWidth();
}
| 6,065 |
10,802 | 0 | const EVP_MD *tls12_get_hash(unsigned char hash_alg)
{
const tls12_hash_info *inf;
#ifndef OPENSSL_FIPS
if (hash_alg == TLSEXT_hash_md5 && FIPS_mode())
return NULL;
#endif
inf = tls12_get_hash_info(hash_alg);
if (!inf || !inf->mfunc)
return NULL;
return inf->mfunc();
}
| 6,066 |
20,180 | 0 | int sock_no_getname(struct socket *sock, struct sockaddr *saddr,
int *len, int peer)
{
return -EOPNOTSUPP;
}
| 6,067 |
80,532 | 0 | GF_Err tims_Size(GF_Box *s)
{
s->size += 4;
return GF_OK;
}
| 6,068 |
71,698 | 0 | MagickBooleanType sixel_decode(unsigned char /* in */ *p, /* sixel bytes */
unsigned char /* out */ **pixels, /* decoded pixels */
size_t /* out */ *pwidth, /* image width */
size_t /* out */ *pheight, /* image height */
unsigned char /* out */ **palette, /* ARGB palette */
size_t /* out */ *ncolors /* palette size (<= 256) */)
{
int n, i, r, g, b, sixel_vertical_mask, c;
int posision_x, posision_y;
int max_x, max_y;
int attributed_pan, attributed_pad;
int attributed_ph, attributed_pv;
int repeat_count, color_index, max_color_index = 2, background_color_index;
int param[10];
int sixel_palet[SIXEL_PALETTE_MAX];
unsigned char *imbuf, *dmbuf;
int imsx, imsy;
int dmsx, dmsy;
int y;
posision_x = posision_y = 0;
max_x = max_y = 0;
attributed_pan = 2;
attributed_pad = 1;
attributed_ph = attributed_pv = 0;
repeat_count = 1;
color_index = 0;
background_color_index = 0;
imsx = 2048;
imsy = 2048;
imbuf = (unsigned char *) AcquireQuantumMemory(imsx * imsy,1);
if (imbuf == NULL) {
return(MagickFalse);
}
for (n = 0; n < 16; n++) {
sixel_palet[n] = sixel_default_color_table[n];
}
/* colors 16-231 are a 6x6x6 color cube */
for (r = 0; r < 6; r++) {
for (g = 0; g < 6; g++) {
for (b = 0; b < 6; b++) {
sixel_palet[n++] = SIXEL_RGB(r * 51, g * 51, b * 51);
}
}
}
/* colors 232-255 are a grayscale ramp, intentionally leaving out */
for (i = 0; i < 24; i++) {
sixel_palet[n++] = SIXEL_RGB(i * 11, i * 11, i * 11);
}
for (; n < SIXEL_PALETTE_MAX; n++) {
sixel_palet[n] = SIXEL_RGB(255, 255, 255);
}
(void) ResetMagickMemory(imbuf, background_color_index, imsx * imsy);
while (*p != '\0') {
if ((p[0] == '\033' && p[1] == 'P') || *p == 0x90) {
if (*p == '\033') {
p++;
}
p = get_params(++p, param, &n);
if (*p == 'q') {
p++;
if (n > 0) { /* Pn1 */
switch(param[0]) {
case 0:
case 1:
attributed_pad = 2;
break;
case 2:
attributed_pad = 5;
break;
case 3:
attributed_pad = 4;
break;
case 4:
attributed_pad = 4;
break;
case 5:
attributed_pad = 3;
break;
case 6:
attributed_pad = 3;
break;
case 7:
attributed_pad = 2;
break;
case 8:
attributed_pad = 2;
break;
case 9:
attributed_pad = 1;
break;
}
}
if (n > 2) { /* Pn3 */
if (param[2] == 0) {
param[2] = 10;
}
attributed_pan = attributed_pan * param[2] / 10;
attributed_pad = attributed_pad * param[2] / 10;
if (attributed_pan <= 0) attributed_pan = 1;
if (attributed_pad <= 0) attributed_pad = 1;
}
}
} else if ((p[0] == '\033' && p[1] == '\\') || *p == 0x9C) {
break;
} else if (*p == '"') {
/* DECGRA Set Raster Attributes " Pan; Pad; Ph; Pv */
p = get_params(++p, param, &n);
if (n > 0) attributed_pad = param[0];
if (n > 1) attributed_pan = param[1];
if (n > 2 && param[2] > 0) attributed_ph = param[2];
if (n > 3 && param[3] > 0) attributed_pv = param[3];
if (attributed_pan <= 0) attributed_pan = 1;
if (attributed_pad <= 0) attributed_pad = 1;
if (imsx < attributed_ph || imsy < attributed_pv) {
dmsx = imsx > attributed_ph ? imsx : attributed_ph;
dmsy = imsy > attributed_pv ? imsy : attributed_pv;
dmbuf = (unsigned char *) AcquireQuantumMemory(dmsx * dmsy,1);
if (dmbuf == (unsigned char *) NULL) {
imbuf = (unsigned char *) RelinquishMagickMemory(imbuf);
return (MagickFalse);
}
(void) ResetMagickMemory(dmbuf, background_color_index, dmsx * dmsy);
for (y = 0; y < imsy; ++y) {
(void) CopyMagickMemory(dmbuf + dmsx * y, imbuf + imsx * y, imsx);
}
imbuf = (unsigned char *) RelinquishMagickMemory(imbuf);
imsx = dmsx;
imsy = dmsy;
imbuf = dmbuf;
}
} else if (*p == '!') {
/* DECGRI Graphics Repeat Introducer ! Pn Ch */
p = get_params(++p, param, &n);
if (n > 0) {
repeat_count = param[0];
}
} else if (*p == '#') {
/* DECGCI Graphics Color Introducer # Pc; Pu; Px; Py; Pz */
p = get_params(++p, param, &n);
if (n > 0) {
if ((color_index = param[0]) < 0) {
color_index = 0;
} else if (color_index >= SIXEL_PALETTE_MAX) {
color_index = SIXEL_PALETTE_MAX - 1;
}
}
if (n > 4) {
if (param[1] == 1) { /* HLS */
if (param[2] > 360) param[2] = 360;
if (param[3] > 100) param[3] = 100;
if (param[4] > 100) param[4] = 100;
sixel_palet[color_index] = hls_to_rgb(param[2] * 100 / 360, param[3], param[4]);
} else if (param[1] == 2) { /* RGB */
if (param[2] > 100) param[2] = 100;
if (param[3] > 100) param[3] = 100;
if (param[4] > 100) param[4] = 100;
sixel_palet[color_index] = SIXEL_XRGB(param[2], param[3], param[4]);
}
}
} else if (*p == '$') {
/* DECGCR Graphics Carriage Return */
p++;
posision_x = 0;
repeat_count = 1;
} else if (*p == '-') {
/* DECGNL Graphics Next Line */
p++;
posision_x = 0;
posision_y += 6;
repeat_count = 1;
} else if (*p >= '?' && *p <= '\177') {
if (imsx < (posision_x + repeat_count) || imsy < (posision_y + 6)) {
int nx = imsx * 2;
int ny = imsy * 2;
while (nx < (posision_x + repeat_count) || ny < (posision_y + 6)) {
nx *= 2;
ny *= 2;
}
dmsx = nx;
dmsy = ny;
dmbuf = (unsigned char *) AcquireQuantumMemory(dmsx * dmsy,1);
if (dmbuf == (unsigned char *) NULL) {
imbuf = (unsigned char *) RelinquishMagickMemory(imbuf);
return (MagickFalse);
}
(void) ResetMagickMemory(dmbuf, background_color_index, dmsx * dmsy);
for (y = 0; y < imsy; ++y) {
(void) CopyMagickMemory(dmbuf + dmsx * y, imbuf + imsx * y, imsx);
}
imbuf = (unsigned char *) RelinquishMagickMemory(imbuf);
imsx = dmsx;
imsy = dmsy;
imbuf = dmbuf;
}
if (color_index > max_color_index) {
max_color_index = color_index;
}
if ((b = *(p++) - '?') == 0) {
posision_x += repeat_count;
} else {
sixel_vertical_mask = 0x01;
if (repeat_count <= 1) {
for (i = 0; i < 6; i++) {
if ((b & sixel_vertical_mask) != 0) {
imbuf[imsx * (posision_y + i) + posision_x] = color_index;
if (max_x < posision_x) {
max_x = posision_x;
}
if (max_y < (posision_y + i)) {
max_y = posision_y + i;
}
}
sixel_vertical_mask <<= 1;
}
posision_x += 1;
} else { /* repeat_count > 1 */
for (i = 0; i < 6; i++) {
if ((b & sixel_vertical_mask) != 0) {
c = sixel_vertical_mask << 1;
for (n = 1; (i + n) < 6; n++) {
if ((b & c) == 0) {
break;
}
c <<= 1;
}
for (y = posision_y + i; y < posision_y + i + n; ++y) {
(void) ResetMagickMemory(imbuf + imsx * y + posision_x, color_index, repeat_count);
}
if (max_x < (posision_x + repeat_count - 1)) {
max_x = posision_x + repeat_count - 1;
}
if (max_y < (posision_y + i + n - 1)) {
max_y = posision_y + i + n - 1;
}
i += (n - 1);
sixel_vertical_mask <<= (n - 1);
}
sixel_vertical_mask <<= 1;
}
posision_x += repeat_count;
}
}
repeat_count = 1;
} else {
p++;
}
}
if (++max_x < attributed_ph) {
max_x = attributed_ph;
}
if (++max_y < attributed_pv) {
max_y = attributed_pv;
}
if (imsx > max_x || imsy > max_y) {
dmsx = max_x;
dmsy = max_y;
if ((dmbuf = (unsigned char *) AcquireQuantumMemory(dmsx * dmsy,1)) == NULL) {
imbuf = (unsigned char *) RelinquishMagickMemory(imbuf);
return (MagickFalse);
}
for (y = 0; y < dmsy; ++y) {
(void) CopyMagickMemory(dmbuf + dmsx * y, imbuf + imsx * y, dmsx);
}
imbuf = (unsigned char *) RelinquishMagickMemory(imbuf);
imsx = dmsx;
imsy = dmsy;
imbuf = dmbuf;
}
*pixels = imbuf;
*pwidth = imsx;
*pheight = imsy;
*ncolors = max_color_index + 1;
*palette = (unsigned char *) AcquireQuantumMemory(*ncolors,4);
for (n = 0; n < (ssize_t) *ncolors; ++n) {
(*palette)[n * 4 + 0] = sixel_palet[n] >> 16 & 0xff;
(*palette)[n * 4 + 1] = sixel_palet[n] >> 8 & 0xff;
(*palette)[n * 4 + 2] = sixel_palet[n] & 0xff;
(*palette)[n * 4 + 3] = 0xff;
}
return(MagickTrue);
}
| 6,069 |
93,708 | 0 | void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));}
| 6,070 |
48,770 | 0 | static void __net_exit default_device_exit(struct net *net)
{
struct net_device *dev, *aux;
/*
* Push all migratable network devices back to the
* initial network namespace
*/
rtnl_lock();
for_each_netdev_safe(net, dev, aux) {
int err;
char fb_name[IFNAMSIZ];
/* Ignore unmoveable devices (i.e. loopback) */
if (dev->features & NETIF_F_NETNS_LOCAL)
continue;
/* Leave virtual devices for the generic cleanup */
if (dev->rtnl_link_ops)
continue;
/* Push remaining network devices to init_net */
snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex);
err = dev_change_net_namespace(dev, &init_net, fb_name);
if (err) {
pr_emerg("%s: failed to move %s to init_net: %d\n",
__func__, dev->name, err);
BUG();
}
}
rtnl_unlock();
}
| 6,071 |
5,673 | 0 | static void usb_xhci_exit(PCIDevice *dev)
{
int i;
XHCIState *xhci = XHCI(dev);
trace_usb_xhci_exit();
for (i = 0; i < xhci->numslots; i++) {
xhci_disable_slot(xhci, i + 1);
}
if (xhci->mfwrap_timer) {
timer_del(xhci->mfwrap_timer);
timer_free(xhci->mfwrap_timer);
xhci->mfwrap_timer = NULL;
}
memory_region_del_subregion(&xhci->mem, &xhci->mem_cap);
memory_region_del_subregion(&xhci->mem, &xhci->mem_oper);
memory_region_del_subregion(&xhci->mem, &xhci->mem_runtime);
memory_region_del_subregion(&xhci->mem, &xhci->mem_doorbell);
for (i = 0; i < xhci->numports; i++) {
XHCIPort *port = &xhci->ports[i];
memory_region_del_subregion(&xhci->mem, &port->mem);
}
/* destroy msix memory region */
if (dev->msix_table && dev->msix_pba
&& dev->msix_entry_used) {
msix_uninit(dev, &xhci->mem, &xhci->mem);
}
usb_bus_release(&xhci->bus);
}
| 6,072 |
74,423 | 0 | static __inline USHORT CalculateIpv4PseudoHeaderChecksum(IPv4Header *pIpHeader, USHORT headerAndPayloadLen)
{
tIPv4PseudoHeader ipph;
USHORT checksum;
ipph.ipph_src = pIpHeader->ip_src;
ipph.ipph_dest = pIpHeader->ip_dest;
ipph.ipph_zero = 0;
ipph.ipph_protocol = pIpHeader->ip_protocol;
ipph.ipph_length = swap_short(headerAndPayloadLen);
checksum = CheckSumCalculatorFlat(&ipph, sizeof(ipph));
return ~checksum;
}
| 6,073 |
33,459 | 0 | static size_t log_prefix(const char *p, unsigned int *level, char *special)
{
unsigned int lev = 0;
char sp = '\0';
size_t len;
if (p[0] != '<' || !p[1])
return 0;
if (p[2] == '>') {
/* usual single digit level number or special char */
switch (p[1]) {
case '0' ... '7':
lev = p[1] - '0';
break;
case 'c': /* KERN_CONT */
case 'd': /* KERN_DEFAULT */
sp = p[1];
break;
default:
return 0;
}
len = 3;
} else {
/* multi digit including the level and facility number */
char *endp = NULL;
lev = (simple_strtoul(&p[1], &endp, 10) & 7);
if (endp == NULL || endp[0] != '>')
return 0;
len = (endp + 1) - p;
}
/* do not accept special char if not asked for */
if (sp && !special)
return 0;
if (special) {
*special = sp;
/* return special char, do not touch level */
if (sp)
return len;
}
if (level)
*level = lev;
return len;
}
| 6,074 |
173,667 | 0 | status_t ATSParser::Stream::parse(
unsigned continuity_counter,
unsigned payload_unit_start_indicator, ABitReader *br,
SyncEvent *event) {
if (mQueue == NULL) {
return OK;
}
if (mExpectedContinuityCounter >= 0
&& (unsigned)mExpectedContinuityCounter != continuity_counter) {
ALOGI("discontinuity on stream pid 0x%04x", mElementaryPID);
mPayloadStarted = false;
mBuffer->setRange(0, 0);
mExpectedContinuityCounter = -1;
#if 0
if (mStreamType == STREAMTYPE_H264) {
ALOGI("clearing video queue");
mQueue->clear(true /* clearFormat */);
}
#endif
if (!payload_unit_start_indicator) {
return OK;
}
}
mExpectedContinuityCounter = (continuity_counter + 1) & 0x0f;
if (payload_unit_start_indicator) {
off64_t offset = (event != NULL) ? event->getOffset() : 0;
if (mPayloadStarted) {
status_t err = flush(event);
if (err != OK) {
ALOGW("Error (%08x) happened while flushing; we simply discard "
"the PES packet and continue.", err);
}
}
mPayloadStarted = true;
mPesStartOffset = offset;
}
if (!mPayloadStarted) {
return OK;
}
size_t payloadSizeBits = br->numBitsLeft();
if (payloadSizeBits % 8 != 0u) {
ALOGE("Wrong value");
return BAD_VALUE;
}
size_t neededSize = mBuffer->size() + payloadSizeBits / 8;
if (mBuffer->capacity() < neededSize) {
neededSize = (neededSize + 65535) & ~65535;
ALOGI("resizing buffer to %zu bytes", neededSize);
sp<ABuffer> newBuffer = new ABuffer(neededSize);
memcpy(newBuffer->data(), mBuffer->data(), mBuffer->size());
newBuffer->setRange(0, mBuffer->size());
mBuffer = newBuffer;
}
memcpy(mBuffer->data() + mBuffer->size(), br->data(), payloadSizeBits / 8);
mBuffer->setRange(0, mBuffer->size() + payloadSizeBits / 8);
return OK;
}
| 6,075 |
12,711 | 0 | static int dtls1_set_handshake_header(SSL *s, int htype, unsigned long len)
{
dtls1_set_message_header(s, htype, len, 0, len);
s->init_num = (int)len + DTLS1_HM_HEADER_LENGTH;
s->init_off = 0;
/* Buffer the message to handle re-xmits */
if (!dtls1_buffer_message(s, 0))
return 0;
return 1;
}
| 6,076 |
58,934 | 0 | static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u8 *data)
{
struct l2cap_chan_list *list = &conn->chan_list;
struct l2cap_conn_req *req = (struct l2cap_conn_req *) data;
struct l2cap_conn_rsp rsp;
struct sock *sk, *parent;
int result, status = L2CAP_CS_NO_INFO;
u16 dcid = 0, scid = __le16_to_cpu(req->scid);
__le16 psm = req->psm;
BT_DBG("psm 0x%2.2x scid 0x%4.4x", psm, scid);
/* Check if we have socket listening on psm */
parent = l2cap_get_sock_by_psm(BT_LISTEN, psm, conn->src);
if (!parent) {
result = L2CAP_CR_BAD_PSM;
goto sendresp;
}
/* Check if the ACL is secure enough (if not SDP) */
if (psm != cpu_to_le16(0x0001) &&
!hci_conn_check_link_mode(conn->hcon)) {
conn->disc_reason = 0x05;
result = L2CAP_CR_SEC_BLOCK;
goto response;
}
result = L2CAP_CR_NO_MEM;
/* Check for backlog size */
if (sk_acceptq_is_full(parent)) {
BT_DBG("backlog full %d", parent->sk_ack_backlog);
goto response;
}
sk = l2cap_sock_alloc(sock_net(parent), NULL, BTPROTO_L2CAP, GFP_ATOMIC);
if (!sk)
goto response;
write_lock_bh(&list->lock);
/* Check if we already have channel with that dcid */
if (__l2cap_get_chan_by_dcid(list, scid)) {
write_unlock_bh(&list->lock);
sock_set_flag(sk, SOCK_ZAPPED);
l2cap_sock_kill(sk);
goto response;
}
hci_conn_hold(conn->hcon);
l2cap_sock_init(sk, parent);
bacpy(&bt_sk(sk)->src, conn->src);
bacpy(&bt_sk(sk)->dst, conn->dst);
l2cap_pi(sk)->psm = psm;
l2cap_pi(sk)->dcid = scid;
__l2cap_chan_add(conn, sk, parent);
dcid = l2cap_pi(sk)->scid;
l2cap_sock_set_timer(sk, sk->sk_sndtimeo);
l2cap_pi(sk)->ident = cmd->ident;
if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE) {
if (l2cap_check_security(sk)) {
if (bt_sk(sk)->defer_setup) {
sk->sk_state = BT_CONNECT2;
result = L2CAP_CR_PEND;
status = L2CAP_CS_AUTHOR_PEND;
parent->sk_data_ready(parent, 0);
} else {
sk->sk_state = BT_CONFIG;
result = L2CAP_CR_SUCCESS;
status = L2CAP_CS_NO_INFO;
}
} else {
sk->sk_state = BT_CONNECT2;
result = L2CAP_CR_PEND;
status = L2CAP_CS_AUTHEN_PEND;
}
} else {
sk->sk_state = BT_CONNECT2;
result = L2CAP_CR_PEND;
status = L2CAP_CS_NO_INFO;
}
write_unlock_bh(&list->lock);
response:
bh_unlock_sock(parent);
sendresp:
rsp.scid = cpu_to_le16(scid);
rsp.dcid = cpu_to_le16(dcid);
rsp.result = cpu_to_le16(result);
rsp.status = cpu_to_le16(status);
l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
if (result == L2CAP_CR_PEND && status == L2CAP_CS_NO_INFO) {
struct l2cap_info_req info;
info.type = cpu_to_le16(L2CAP_IT_FEAT_MASK);
conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_SENT;
conn->info_ident = l2cap_get_ident(conn);
mod_timer(&conn->info_timer, jiffies +
msecs_to_jiffies(L2CAP_INFO_TIMEOUT));
l2cap_send_cmd(conn, conn->info_ident,
L2CAP_INFO_REQ, sizeof(info), &info);
}
return 0;
}
| 6,077 |
37,373 | 0 | static void write_register_operand(struct operand *op)
{
/* The 4-byte case *is* correct: in 64-bit mode we zero-extend. */
switch (op->bytes) {
case 1:
*(u8 *)op->addr.reg = (u8)op->val;
break;
case 2:
*(u16 *)op->addr.reg = (u16)op->val;
break;
case 4:
*op->addr.reg = (u32)op->val;
break; /* 64b: zero-extend */
case 8:
*op->addr.reg = op->val;
break;
}
}
| 6,078 |
114,045 | 0 | void TaskManagerTableModel::GetGroupRangeForItem(int item,
views::GroupRange* range) {
TaskManagerModel::GroupRange range_pair =
model_->GetGroupRangeForResource(item);
range->start = range_pair.first;
range->length = range_pair.second;
}
| 6,079 |
175,141 | 0 | wifi_error wifi_set_scanning_mac_oui(wifi_interface_handle handle, oui scan_oui)
{
SetPnoMacAddrOuiCommand command(handle, scan_oui);
return (wifi_error)command.start();
}
| 6,080 |
154,327 | 0 | void GLES2DecoderImpl::ReadBackBuffersIntoShadowCopies(
base::flat_set<scoped_refptr<Buffer>> buffers_to_shadow_copy) {
GLuint old_binding =
state_.bound_array_buffer ? state_.bound_array_buffer->service_id() : 0;
for (scoped_refptr<Buffer>& buffer : buffers_to_shadow_copy) {
if (buffer->IsDeleted()) {
continue;
}
void* shadow = nullptr;
scoped_refptr<gpu::Buffer> gpu_buffer =
buffer->TakeReadbackShadowAllocation(&shadow);
if (!shadow) {
continue;
}
if (buffer->GetMappedRange()) {
continue;
}
api()->glBindBufferFn(GL_ARRAY_BUFFER, buffer->service_id());
void* mapped = api()->glMapBufferRangeFn(GL_ARRAY_BUFFER, 0, buffer->size(),
GL_MAP_READ_BIT);
if (!mapped) {
DLOG(ERROR) << "glMapBufferRange unexpectedly returned nullptr";
MarkContextLost(error::kOutOfMemory);
group_->LoseContexts(error::kUnknown);
return;
}
memcpy(shadow, mapped, buffer->size());
bool unmap_ok = api()->glUnmapBufferFn(GL_ARRAY_BUFFER);
if (unmap_ok == GL_FALSE) {
DLOG(ERROR) << "glUnmapBuffer unexpectedly returned GL_FALSE";
MarkContextLost(error::kUnknown);
group_->LoseContexts(error::kUnknown);
return;
}
}
api()->glBindBufferFn(GL_ARRAY_BUFFER, old_binding);
}
| 6,081 |
113,554 | 0 | JSRetainPtr<JSStringRef> AccessibilityUIElement::boundsForRange(unsigned location, unsigned length)
{
return JSStringCreateWithCharacters(0, 0);
}
| 6,082 |
87,052 | 0 | authz_status oidc_authz_checker_claim(request_rec *r, const char *require_args,
const void *parsed_require_args) {
return oidc_authz_checker(r, require_args, parsed_require_args,
oidc_authz_match_claim);
}
| 6,083 |
9,683 | 0 | destroy_size( FT_Memory memory,
FT_Size size,
FT_Driver driver )
{
/* finalize client-specific data */
if ( size->generic.finalizer )
size->generic.finalizer( size );
/* finalize format-specific stuff */
if ( driver->clazz->done_size )
driver->clazz->done_size( size );
FT_FREE( size->internal );
FT_FREE( size );
}
| 6,084 |
153,145 | 0 | void Compositor::DidFailToInitializeLayerTreeFrameSink() {
task_runner_->PostTask(
FROM_HERE,
base::BindOnce(&Compositor::RequestNewLayerTreeFrameSink,
context_creation_weak_ptr_factory_.GetWeakPtr()));
}
| 6,085 |
144,153 | 0 | png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text,
png_size_t text_len, int compression)
{
#ifdef PNG_USE_LOCAL_ARRAYS
PNG_zTXt;
#endif
png_size_t key_len;
char buf[1];
png_charp new_key;
compression_state comp;
png_debug(1, "in png_write_zTXt");
comp.num_output_ptr = 0;
comp.max_output_ptr = 0;
comp.output_ptr = NULL;
comp.input = NULL;
comp.input_len = 0;
if ((key_len = png_check_keyword(png_ptr, key, &new_key))==0)
{
png_free(png_ptr, new_key);
return;
}
if (text == NULL || *text == '\0' || compression==PNG_TEXT_COMPRESSION_NONE)
{
png_write_tEXt(png_ptr, new_key, text, (png_size_t)0);
png_free(png_ptr, new_key);
return;
}
text_len = png_strlen(text);
/* Compute the compressed data; do it now for the length */
text_len = png_text_compress(png_ptr, text, text_len, compression,
&comp);
/* Write start of chunk */
png_write_chunk_start(png_ptr, (png_bytep)png_zTXt,
(png_uint_32)(key_len+text_len + 2));
/* Write key */
png_write_chunk_data(png_ptr, (png_bytep)new_key,
(png_size_t)(key_len + 1));
png_free(png_ptr, new_key);
buf[0] = (png_byte)compression;
/* Write compression */
png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1);
/* Write the compressed data */
png_write_compressed_data_out(png_ptr, &comp);
/* Close the chunk */
png_write_chunk_end(png_ptr);
}
| 6,086 |
14,834 | 0 | static zval *incomplete_class_get_property(zval *object, zval *member, int type, const zend_literal *key TSRMLS_DC) /* {{{ */
{
incomplete_class_message(object, E_NOTICE TSRMLS_CC);
if (type == BP_VAR_W || type == BP_VAR_RW) {
return EG(error_zval_ptr);
} else {
return EG(uninitialized_zval_ptr);
}
}
/* }}} */
| 6,087 |
130,553 | 0 | DisplayItemList& displayItemList() { return *m_displayItemList; }
| 6,088 |
183,093 | 1 | static void scsi_read_data(SCSIRequest *req)
{
SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
uint32_t n;
if (r->sector_count == (uint32_t)-1) {
DPRINTF("Read buf_len=%zd\n", r->iov.iov_len);
r->sector_count = 0;
scsi_req_data(&r->req, r->iov.iov_len);
return;
}
DPRINTF("Read sector_count=%d\n", r->sector_count);
if (r->sector_count == 0) {
/* This also clears the sense buffer for REQUEST SENSE. */
scsi_req_complete(&r->req, GOOD);
return;
}
/* No data transfer may already be in progress */
assert(r->req.aiocb == NULL);
if (r->req.cmd.mode == SCSI_XFER_TO_DEV) {
DPRINTF("Data transfer direction invalid\n");
scsi_read_complete(r, -EINVAL);
return;
}
n = r->sector_count;
if (n > SCSI_DMA_BUF_SIZE / 512)
n = SCSI_DMA_BUF_SIZE / 512;
if (s->tray_open) {
scsi_read_complete(r, -ENOMEDIUM);
}
r->iov.iov_len = n * 512;
qemu_iovec_init_external(&r->qiov, &r->iov, 1);
bdrv_acct_start(s->bs, &r->acct, n * BDRV_SECTOR_SIZE, BDRV_ACCT_READ);
r->req.aiocb = bdrv_aio_readv(s->bs, r->sector, &r->qiov, n,
scsi_read_complete, r);
if (r->req.aiocb == NULL) {
scsi_read_complete(r, -EIO);
}
}
| 6,089 |
149,956 | 0 | bool LayerTreeHostImpl::HaveRootScrollLayer() const {
return !!InnerViewportScrollLayer();
}
| 6,090 |
128,484 | 0 | gfx::Point ShellSurface::GetSurfaceOrigin() const {
gfx::Rect window_bounds = widget_->GetNativeWindow()->bounds();
if (!initial_bounds_.IsEmpty())
return initial_bounds_.origin() - window_bounds.OffsetFromOrigin();
gfx::Rect visible_bounds = GetVisibleBounds();
switch (resize_component_) {
case HTCAPTION:
return origin_ - visible_bounds.OffsetFromOrigin();
case HTBOTTOM:
case HTRIGHT:
case HTBOTTOMRIGHT:
return gfx::Point() - visible_bounds.OffsetFromOrigin();
case HTTOP:
case HTTOPRIGHT:
return gfx::Point(0, window_bounds.height() - visible_bounds.height()) -
visible_bounds.OffsetFromOrigin();
break;
case HTLEFT:
case HTBOTTOMLEFT:
return gfx::Point(window_bounds.width() - visible_bounds.width(), 0) -
visible_bounds.OffsetFromOrigin();
case HTTOPLEFT:
return gfx::Point(window_bounds.width() - visible_bounds.width(),
window_bounds.height() - visible_bounds.height()) -
visible_bounds.OffsetFromOrigin();
default:
NOTREACHED();
return gfx::Point();
}
}
| 6,091 |
71,388 | 0 | static inline Image *GetImageCache(const ImageInfo *image_info,const char *path,
ExceptionInfo *exception)
{
char
key[MaxTextExtent];
ExceptionInfo
*sans_exception;
Image
*image;
ImageInfo
*read_info;
(void) FormatLocaleString(key,MaxTextExtent,"cache:%s",path);
sans_exception=AcquireExceptionInfo();
image=(Image *) GetImageRegistry(ImageRegistryType,key,sans_exception);
sans_exception=DestroyExceptionInfo(sans_exception);
if (image != (Image *) NULL)
return(image);
read_info=CloneImageInfo(image_info);
(void) CopyMagickString(read_info->filename,path,MaxTextExtent);
image=ReadImage(read_info,exception);
read_info=DestroyImageInfo(read_info);
if (image != (Image *) NULL)
(void) SetImageRegistry(ImageRegistryType,key,image,exception);
return(image);
}
| 6,092 |
112,285 | 0 | ShellWindow::CreateParams::CreateParams()
: frame(ShellWindow::CreateParams::FRAME_CHROME),
bounds(10, 10, kDefaultWidth, kDefaultHeight) {
}
| 6,093 |
36,454 | 0 | static int snd_ctl_elem_add_user(struct snd_ctl_file *file,
struct snd_ctl_elem_info __user *_info, int replace)
{
struct snd_ctl_elem_info info;
if (copy_from_user(&info, _info, sizeof(info)))
return -EFAULT;
return snd_ctl_elem_add(file, &info, replace);
}
| 6,094 |
30,426 | 0 | int vmci_transport_send_read_bh(struct sockaddr_vm *dst,
struct sockaddr_vm *src)
{
return vmci_transport_send_control_pkt_bh(
dst, src,
VMCI_TRANSPORT_PACKET_TYPE_READ, 0,
0, NULL, VMCI_INVALID_HANDLE);
}
| 6,095 |
187,766 | 1 | native_handle* Parcel::readNativeHandle() const
{
int numFds, numInts;
status_t err;
err = readInt32(&numFds);
if (err != NO_ERROR) return 0;
err = readInt32(&numInts);
if (err != NO_ERROR) return 0;
native_handle* h = native_handle_create(numFds, numInts);
if (!h) {
return 0;
}
for (int i=0 ; err==NO_ERROR && i<numFds ; i++) {
h->data[i] = dup(readFileDescriptor());
if (h->data[i] < 0) err = BAD_VALUE;
}
err = read(h->data + numFds, sizeof(int)*numInts);
if (err != NO_ERROR) {
native_handle_close(h);
native_handle_delete(h);
h = 0;
}
return h;
}
| 6,096 |
84,198 | 0 | ptaaTruncate(PTAA *ptaa)
{
l_int32 i, n, np;
PTA *pta;
PROCNAME("ptaaTruncate");
if (!ptaa)
return ERROR_INT("ptaa not defined", procName, 1);
n = ptaaGetCount(ptaa);
for (i = n - 1; i >= 0; i--) {
pta = ptaaGetPta(ptaa, i, L_CLONE);
if (!pta) {
ptaa->n--;
continue;
}
np = ptaGetCount(pta);
ptaDestroy(&pta);
if (np == 0) {
ptaDestroy(&ptaa->pta[i]);
ptaa->n--;
} else {
break;
}
}
return 0;
}
| 6,097 |
141,813 | 0 | ChromeMetricsServiceClient::~ChromeMetricsServiceClient() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}
| 6,098 |
129,708 | 0 | ResourcePtr<DocumentResource> ResourceFetcher::fetchSVGDocument(FetchRequest& request)
{
return toDocumentResource(requestResource(Resource::SVGDocument, request));
}
| 6,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.