processed_func string | target int64 | flaw_line string | flaw_line_index int64 | commit_url string | language class label |
|---|---|---|---|---|---|
function tryNextAgentKey() {
if (curAuth === 'agent') {
if (agentKeyPos >= agentKeys.length)
return;
if (++agentKeyPos >= agentKeys.length) {
debug('DEBUG: Agent: No more keys left to try');
debug('DEBUG: Client: agent auth failed');
agentKeys = undefined;
tryNextAuth();
} else {
debug('DEBUG: Agent: Trying key #' + (agentKeyPos + 1));
stream.authPK(self.config.username, agentKeys[agentKeyPos]);
stream.once('USERAUTH_PK_OK', onUSERAUTH_PK_OK);
}
}
} | 1 | 0,1,2,4,5,6,7,8,10,11,12,14,15 | -1 | https://github.com/mscdex/ssh2/commit/f763271f41320e71d5cbee02ea5bc6a2ded3ca21 | 3JavaScript |
function monitor() {
if (main._timer) return;
const ts = Date.now();
if (ts - main._lastTimer > 30000) {
location.reload();
} else {
main._lastTimer = ts;
}
main._timer = setTimeout(() => {
main._timer = null;
monitor();
}, 10000);
} | 0 | null | -1 | https://github.com/ioBroker/ioBroker.admin/commit/16b2b325ab47896090bc7f54b77b0a97ed74f5cd | 3JavaScript |
static void __devexit pmcraid_remove(struct pci_dev *pdev)
{
struct pmcraid_instance *pinstance = pci_get_drvdata(pdev);
pmcraid_release_chrdev(pinstance);
scsi_remove_host(pinstance->host);
scsi_block_requests(pinstance->host);
pmcraid_shutdown(pdev);
pmcraid_disable_interrupts(pinstance, ~0);
flush_work_sync(&pinstance->worker_q);
pmcraid_kill_tasklets(pinstance);
pmcraid_unregister_interrupt_handler(pinstance);
pmcraid_release_buffers(pinstance);
iounmap(pinstance->mapped_dma_addr);
pci_release_regions(pdev);
scsi_host_put(pinstance->host);
pci_disable_device(pdev);
return;
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/b5b515445f4f5a905c5dd27e6e682868ccd6c09d | 0CCPP |
def dump_yaml(data):
return yaml.dump(
data,
indent=2,
encoding=None,
allow_unicode=True,
default_flow_style=False,
Dumper=MyDumper,
)
| 0 | null | -1 | https://github.com/tadashi-aikawa/owlmixin.git/commit/5d0575303f6df869a515ced4285f24ba721e0d4e | 4Python |
int pure_strcmp(const char * const s1, const char * const s2)
{
return pure_memcmp(s1, s2, strlen(s1) + 1U);
} | 1 | 2 | -1 | https://github.com/jedisct1/pure-ftpd/commit/bf6fcd4935e95128cf22af5924cdc8fe5c0579da | 0CCPP |
I.getColor(),z.checked,L.checked,C.checked,D.checked,G.checked,null!=P?P.getLink():null)}),null,d,g);this.showDialog(d.container,340,x,!0,!0);q.focus()};EditorUi.prototype.showPublishLinkDialog=function(d,g,k,l,p,q,x,y){var A=document.createElement("div");A.style.whiteSpace="nowrap";var B=document.createElement("h3");mxUtils.write(B,d||mxResources.get("link"));B.style.cssText="width:100%;text-align:center;margin-top:0px;margin-bottom:12px";A.appendChild(B);var I=this.getCurrentFile();d=0;if(null==
I||I.constructor!=window.DriveFile||g)x=null!=x?x:"https://www.diagrams.net/doc/faq/publish-diagram-as-link";else{d=80;x=null!=x?x:"https://www.diagrams.net/doc/faq/google-drive-publicly-publish-diagram";B=document.createElement("div");B.style.cssText="border-bottom:1px solid lightGray;padding-bottom:14px;padding-top:6px;margin-bottom:14px;text-align:center;";var O=document.createElement("div");O.style.whiteSpace="normal";mxUtils.write(O,mxResources.get("linkAccountRequired"));B.appendChild(O);O=
mxUtils.button(mxResources.get("share"),mxUtils.bind(this,function(){this.drive.showPermissions(I.getId())}));O.style.marginTop="12px";O.className="geBtn";B.appendChild(O);A.appendChild(B);O=document.createElement("a");O.style.paddingLeft="12px";O.style.color="gray";O.style.fontSize="11px";O.style.cursor="pointer";mxUtils.write(O,mxResources.get("check"));B.appendChild(O);mxEvent.addListener(O,"click",mxUtils.bind(this,function(){this.spinner.spin(document.body,mxResources.get("loading"))&&this.getPublicUrl(this.getCurrentFile(),
mxUtils.bind(this,function(H){this.spinner.stop();H=new ErrorDialog(this,null,mxResources.get(null!=H?"diagramIsPublic":"diagramIsNotPublic"),mxResources.get("ok"));this.showDialog(H.container,300,80,!0,!1);H.init()}))}))}var t=null,z=null;if(null!=k||null!=l)d+=30,mxUtils.write(A,mxResources.get("width")+":"),t=document.createElement("input"),t.setAttribute("type","text"),t.style.marginRight="16px",t.style.width="50px",t.style.marginLeft="6px",t.style.marginRight="16px",t.style.marginBottom="10px",
t.value="100%",A.appendChild(t),mxUtils.write(A,mxResources.get("height")+":"),z=document.createElement("input"),z.setAttribute("type","text"),z.style.width="50px",z.style.marginLeft="6px",z.style.marginBottom="10px",z.value=l+"px",A.appendChild(z),mxUtils.br(A);var L=this.addLinkSection(A,q);k=null!=this.pages&&1<this.pages.length;var C=null;if(null==I||I.constructor!=window.DriveFile||g)C=this.addCheckbox(A,mxResources.get("allPages"),k,!k);var D=this.addCheckbox(A,mxResources.get("lightbox"),!0,
null,null,!q),G=this.addEditButton(A,D),P=G.getEditInput();q&&(P.style.marginLeft=D.style.marginLeft,D.style.display="none",d-=20);var K=this.addCheckbox(A,mxResources.get("layers"),!0);K.style.marginLeft=P.style.marginLeft;K.style.marginTop="8px";var F=this.addCheckbox(A,mxResources.get("tags"),!0);F.style.marginLeft=P.style.marginLeft;F.style.marginBottom="16px";F.style.marginTop="16px";mxEvent.addListener(D,"change",function(){D.checked?(K.removeAttribute("disabled"),P.removeAttribute("disabled")):
(K.setAttribute("disabled","disabled"),P.setAttribute("disabled","disabled"));P.checked&&D.checked?G.getEditSelect().removeAttribute("disabled"):G.getEditSelect().setAttribute("disabled","disabled")});g=new CustomDialog(this,A,mxUtils.bind(this,function(){p(L.getTarget(),L.getColor(),null==C?!0:C.checked,D.checked,G.getLink(),K.checked,null!=t?t.value:null,null!=z?z.value:null,F.checked)}),null,mxResources.get("create"),x,y);this.showDialog(g.container,340,300+d,!0,!0);null!=t?(t.focus(),mxClient.IS_GC||
mxClient.IS_FF||5<=document.documentMode?t.select():document.execCommand("selectAll",!1,null)):L.focus()};EditorUi.prototype.showRemoteExportDialog=function(d,g,k,l,p){var q=document.createElement("div");q.style.whiteSpace="nowrap";var x=document.createElement("h3");mxUtils.write(x,mxResources.get("image"));x.style.cssText="width:100%;text-align:center;margin-top:0px;margin-bottom:"+(p?"10":"4")+"px";q.appendChild(x);if(p){mxUtils.write(q,mxResources.get("zoom")+":");var y=document.createElement("input"); | 1 | 0,4,5,6 | -1 | https://github.com/jgraph/drawio/commit/4deecee18191f67e242422abf3ca304e19e49687 | 3JavaScript |
def _on_load_started(self) -> None:
self._progress = 0
self._has_ssl_errors = False
self.data.viewing_source = False
self._set_load_status(usertypes.LoadStatus.loading)
self.load_started.emit()
| 1 | 2 | -1 | https://github.com/qutebrowser/qutebrowser.git/commit/021ab572a319ca3db5907a33a59774f502b3b975 | 4Python |
def main():
global logger
result = 0
parser = argparse.ArgumentParser(
description="Keycloak REST client",
prog=prog_name,
epilog=verbose_help.format(prog_name=prog_name),
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument("-v", "--verbose", action="store_true", help="be chatty")
parser.add_argument("-d", "--debug", action="store_true", help="turn on debug info")
parser.add_argument(
"--show-traceback",
action="store_true",
help="exceptions print traceback in addition to " "error message",
)
parser.add_argument(
"--log-file",
default="{prog_name}.log".format(prog_name=prog_name),
help="log file pathname",
)
parser.add_argument(
"--permit-insecure-transport",
action="store_true",
help="Normally secure transport such as TLS " "is required, defeat this check",
)
parser.add_argument(
"--tls-verify",
action=TlsVerifyAction,
default=True,
help="TLS certificate verification for requests to"
" the server. May be one of case insenstive "
"[true, yes, on] to enable,"
"[false, no, off] to disable."
"Or the pathname to a OpenSSL CA bundle to use."
" Default is True.",
)
group = parser.add_argument_group("Server")
group.add_argument(
"-s",
"--server",
required=True,
help="DNS name or IP address of Keycloak server",
)
group.add_argument(
"-a",
"--auth-role",
choices=AUTH_ROLES,
default="root-admin",
help="authenticating as what type of user (default: root-admin)",
)
group.add_argument(
"-u",
"--admin-username",
default="admin",
help="admin user name (default: admin)",
)
group.add_argument(
"-P",
"--admin-password-file",
type=argparse.FileType("rb"),
help=(
"file containing admin password "
'(or use a hyphen "-" to read the password '
"from stdin)"
),
)
group.add_argument("--admin-realm", default="master", help="realm admin belongs to")
cmd_parsers = parser.add_subparsers(help="available commands")
realm_parser = cmd_parsers.add_parser("realm", help="realm operations")
sub_parser = realm_parser.add_subparsers(help="realm commands")
cmd_parser = sub_parser.add_parser("server_info", help="dump server info")
cmd_parser.set_defaults(func=do_server_info)
cmd_parser = sub_parser.add_parser("list", help="list realm names")
cmd_parser.set_defaults(func=do_list_realms)
cmd_parser = sub_parser.add_parser("create", help="create new realm")
cmd_parser.add_argument("-r", "--realm-name", required=True, help="realm name")
cmd_parser.set_defaults(func=do_create_realm)
cmd_parser = sub_parser.add_parser("delete", help="delete existing realm")
cmd_parser.add_argument("-r", "--realm-name", required=True, help="realm name")
cmd_parser.set_defaults(func=do_delete_realm)
cmd_parser = sub_parser.add_parser("metadata", help="retrieve realm metadata")
cmd_parser.add_argument("-r", "--realm-name", required=True, help="realm name")
cmd_parser.set_defaults(func=do_get_realm_metadata)
client_parser = cmd_parsers.add_parser("client", help="client operations")
sub_parser = client_parser.add_subparsers(help="client commands")
cmd_parser = sub_parser.add_parser("list", help="list client names")
cmd_parser.add_argument("-r", "--realm-name", required=True, help="realm name")
cmd_parser.set_defaults(func=do_list_clients)
cmd_parser = sub_parser.add_parser("create", help="create new client")
cmd_parser.add_argument("-r", "--realm-name", required=True, help="realm name")
cmd_parser.add_argument(
"-m",
"--metadata",
type=argparse.FileType("rb"),
required=True,
help="SP metadata file or stdin",
)
cmd_parser.set_defaults(func=do_create_client)
cmd_parser = sub_parser.add_parser("register", help="register new client")
cmd_parser.add_argument("-r", "--realm-name", required=True, help="realm name")
cmd_parser.add_argument(
"-m",
"--metadata",
type=argparse.FileType("rb"),
required=True,
help="SP metadata file or stdin",
)
cmd_parser.add_argument(
"--initial-access-token",
required=True,
help="realm initial access token for " "client registeration",
)
cmd_parser.set_defaults(func=do_register_client)
cmd_parser = sub_parser.add_parser("delete", help="delete existing client")
cmd_parser.add_argument("-r", "--realm-name", required=True, help="realm name")
cmd_parser.add_argument("-c", "--client-name", required=True, help="client name")
cmd_parser.set_defaults(func=do_delete_client)
cmd_parser = sub_parser.add_parser(
"test", help="experimental test used during " "development"
)
cmd_parser.add_argument("-r", "--realm-name", required=True, help="realm name")
cmd_parser.add_argument("-c", "--client-name", required=True, help="client name")
cmd_parser.set_defaults(func=do_client_test)
options = parser.parse_args()
configure_logging(options)
if options.permit_insecure_transport:
os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
options.admin_password = None
if options.admin_password_file is not None:
options.admin_password = options.keycloak_admin_password_file.readline().strip()
options.keycloak_admin_password_file.close()
if options.admin_password is None:
if ("KEYCLOAK_ADMIN_PASSWORD" in os.environ) and (
os.environ["KEYCLOAK_ADMIN_PASSWORD"]
):
options.admin_password = os.environ["KEYCLOAK_ADMIN_PASSWORD"]
try:
anonymous_conn = KeycloakAnonymousConnection(options.server, options.tls_verify)
admin_conn = KeycloakAdminConnection(
options.server,
options.auth_role,
options.admin_realm,
ADMIN_CLIENT_ID,
options.admin_username,
options.admin_password,
options.tls_verify,
)
except Exception as e:
if options.show_traceback:
traceback.print_exc()
print(six.text_type(e), file=sys.stderr)
result = 1
return result
try:
if options.func == do_register_client:
conn = admin_conn
else:
conn = admin_conn
result = options.func(options, conn)
except Exception as e:
if options.show_traceback:
traceback.print_exc()
print(six.text_type(e), file=sys.stderr)
result = 2
return result
return result
| 0 | null | -1 | https://github.com/jdennis/keycloak-httpd-client-install.git/commit/07f26e213196936fb328ea0c1d5a66a09d8b5440 | 4Python |
SPL_METHOD(SplFileObject, valid)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_AHEAD)) {
RETURN_BOOL(intern->u.file.current_line || intern->u.file.current_zval);
} else {
RETVAL_BOOL(!php_stream_eof(intern->u.file.stream));
}
} | 1 | null | -1 | https://github.com/php/php-src/commit/7245bff300d3fa8bacbef7897ff080a6f1c23eba | 0CCPP |
def __init__(self, reasons, response=None):
_WrapperException.__init__(self, reasons)
self.response = response
| 0 | null | -1 | https://github.com/twisted/twisted.git/commit/6c61fc4503ae39ab8ecee52d10f10ee2c371d7e2 | 4Python |
async def on_send_leave_request(
self, origin: str, content: JsonDict, room_id: str
) -> dict:
logger.debug("on_send_leave_request: content: %s", content)
room_version = await self.store.get_room_version(room_id)
pdu = event_from_pdu_json(content, room_version)
origin_host, _ = parse_server_name(origin)
await self.check_server_matches_acl(origin_host, pdu.room_id)
logger.debug("on_send_leave_request: pdu sigs: %s", pdu.signatures)
pdu = await self._check_sigs_and_hash(room_version, pdu)
await self.handler.on_send_leave_request(origin, pdu)
return {}
| 1 | 0,1,2,4 | -1 | https://github.com/matrix-org/synapse.git/commit/3ce2f303f15f6ac3dc352298972dc6e04d9b7a8b | 4Python |
static Jsi_RC jsi_ArrayFillCmd(Jsi_Interp *interp, Jsi_Value *args, Jsi_Value *_this,Jsi_Value **ret, Jsi_Func *funcPtr) {
if (_this->vt != JSI_VT_OBJECT || !Jsi_ObjIsArray(interp, _this->d.obj))
return Jsi_LogError("expected array object");
Jsi_RC rc = JSI_OK;
int istart = 0, iend, n, nsiz;
Jsi_Number nstart = 0, nend = 0;
Jsi_Value *value = Jsi_ValueArrayIndex(interp, args, 0),
*start = Jsi_ValueArrayIndex(interp, args, 1),
*end = Jsi_ValueArrayIndex(interp, args, 2);
Jsi_Obj *obj = _this->d.obj;
n = Jsi_ObjGetLength(interp, obj);
if (start && Jsi_GetNumberFromValue(interp, start, &nstart) == JSI_OK) {
istart = (int)nstart;
if (istart > n)
goto bail;
if (istart < 0)
istart = (n+istart);
if (istart<0)
goto bail;
}
if (n == 0) {
goto bail;
}
iend = n-1;
if (end && Jsi_GetNumberFromValue(interp,end, &nend) == JSI_OK) {
iend = (int) nend;
if (iend >= n)
iend = n;
if (iend < 0)
iend = (n+iend);
if (iend<0)
goto bail;
}
nsiz = iend-istart+1;
if (nsiz<=0)
goto bail;
int i;
for (i = istart; i <= iend; i++)
{
if (obj->arr[i])
Jsi_ValueCopy(interp, obj->arr[i], value);
else
obj->arr[i] = Jsi_ValueDup(interp, value);
}
bail:
if (_this != *ret) {
Jsi_ValueMove(interp, *ret, _this);
}
return rc;
} | 1 | 10 | -1 | https://github.com/pcmacdon/jsish/commit/5408a6d93f45bf1f7acd9ae5d44e0ebd77379e98 | 0CCPP |
def replace(self, key, value):
self.dict[_hkey(key)] = [
value if isinstance(value, unicode) else str(value)
]
| 1 | 2,3 | -1 | https://github.com/bottlepy/bottle.git/commit/6d7e13da0f998820800ecb3fe9ccee4189aefb54 | 4Python |
json_t *json_object(void)
{
json_object_t *object = jsonp_malloc(sizeof(json_object_t));
if(!object)
return NULL;
json_init(&object->json, JSON_OBJECT);
if(hashtable_init(&object->hashtable))
{
jsonp_free(object);
return NULL;
}
object->serial = 0;
object->visited = 0;
return &object->json;
} | 1 | null | -1 | https://github.com/akheron/jansson/commit/8f80c2d83808150724d31793e6ade92749b1faa4 | 0CCPP |
int md_integrity_register(struct mddev *mddev)
{
struct md_rdev *rdev, *reference = NULL;
if (list_empty(&mddev->disks))
return 0;
if (!mddev->gendisk || blk_get_integrity(mddev->gendisk))
return 0;
rdev_for_each(rdev, mddev) {
if (test_bit(Faulty, &rdev->flags))
continue;
if (rdev->raid_disk < 0)
continue;
if (!reference) {
reference = rdev;
continue;
}
if (blk_integrity_compare(reference->bdev->bd_disk,
rdev->bdev->bd_disk) < 0)
return -EINVAL;
}
if (!reference || !bdev_get_integrity(reference->bdev))
return 0;
if (blk_integrity_register(mddev->gendisk,
bdev_get_integrity(reference->bdev)) != 0) {
printk(KERN_ERR "md: failed to register integrity for %s\n",
mdname(mddev));
return -EINVAL;
}
printk(KERN_NOTICE "md: data integrity enabled on %s\n", mdname(mddev));
if (bioset_integrity_create(mddev->bio_set, BIO_POOL_SIZE)) {
printk(KERN_ERR "md: failed to create integrity pool for %s\n",
mdname(mddev));
return -EINVAL;
}
return 0;
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/b6878d9e03043695dbf3fa1caa6dfc09db225b16 | 0CCPP |
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
const auto* params =
reinterpret_cast<const TfLiteGatherParams*>(node->builtin_data);
const TfLiteTensor* input = GetInput(context, node, kInputTensor);
const TfLiteTensor* positions = GetInput(context, node, kInputPositions);
TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
if (positions->type == kTfLiteInt32) {
switch (input->type) {
case kTfLiteFloat32:
return Gather<float, int32_t>(*params, input, positions, output);
case kTfLiteUInt8:
return Gather<uint8_t, int32_t>(*params, input, positions, output);
case kTfLiteInt8:
return Gather<int8_t, int32_t>(*params, input, positions, output);
case kTfLiteInt16:
return Gather<int16_t, int32_t>(*params, input, positions, output);
case kTfLiteInt32:
return Gather<int32_t, int32_t>(*params, input, positions, output);
case kTfLiteInt64:
return Gather<int64_t, int32_t>(*params, input, positions, output);
case kTfLiteBool:
return Gather<bool, int32_t>(*params, input, positions, output);
case kTfLiteString:
return GatherStrings<int32_t>(context, input, positions, output);
default:
context->ReportError(context, "Type '%s' is not supported by gather.",
TfLiteTypeGetName(input->type));
return kTfLiteError;
}
}
if (positions->type == kTfLiteInt64) {
switch (input->type) {
case kTfLiteFloat32:
return Gather<float, int64_t>(*params, input, positions, output);
case kTfLiteUInt8:
return Gather<uint8_t, int64_t>(*params, input, positions, output);
case kTfLiteInt8:
return Gather<int8_t, int64_t>(*params, input, positions, output);
case kTfLiteInt16:
return Gather<int16_t, int64_t>(*params, input, positions, output);
case kTfLiteInt32:
return Gather<int32_t, int64_t>(*params, input, positions, output);
case kTfLiteInt64:
return Gather<int64_t, int64_t>(*params, input, positions, output);
case kTfLiteBool:
return Gather<bool, int64_t>(*params, input, positions, output);
case kTfLiteString:
return GatherStrings<int64_t>(context, input, positions, output);
default:
context->ReportError(context, "Type '%s' is not supported by gather.",
TfLiteTypeGetName(input->type));
return kTfLiteError;
}
}
context->ReportError(context,
"Positions of type '%s' are not supported by gather.",
TfLiteTypeGetName(positions->type));
return kTfLiteError;
} | 1 | 3,4,5 | -1 | https://github.com/tensorflow/tensorflow/commit/1970c2158b1ffa416d159d03c3370b9a462aee35 | 0CCPP |
static int rdg_bio_write(BIO* bio, const char* buf, int num)
{
int status;
rdpRdg* rdg = (rdpRdg*)BIO_get_data(bio);
BIO_clear_flags(bio, BIO_FLAGS_WRITE);
EnterCriticalSection(&rdg->writeSection);
status = rdg_write_data_packet(rdg, (const BYTE*)buf, num);
LeaveCriticalSection(&rdg->writeSection);
if (status < 0)
{
BIO_clear_flags(bio, BIO_FLAGS_SHOULD_RETRY);
return -1;
}
else if (status < num)
{
BIO_set_flags(bio, BIO_FLAGS_WRITE);
WSASetLastError(WSAEWOULDBLOCK);
}
else
{
BIO_set_flags(bio, BIO_FLAGS_WRITE);
}
return status;
} | 0 | null | -1 | https://github.com/FreeRDP/FreeRDP/commit/6b485b146a1b9d6ce72dfd7b5f36456c166e7a16 | 0CCPP |
njs_vmcode_typeof(njs_vm_t *vm, njs_value_t *value, njs_value_t *invld)
{
static const njs_value_t *types[NJS_VALUE_TYPE_MAX] = {
&njs_string_object,
&njs_string_undefined,
&njs_string_boolean,
&njs_string_number,
&njs_string_symbol,
&njs_string_string,
&njs_string_data,
&njs_string_external,
&njs_string_invalid,
&njs_string_undefined,
&njs_string_undefined,
&njs_string_undefined,
&njs_string_undefined,
&njs_string_undefined,
&njs_string_undefined,
&njs_string_undefined,
&njs_string_object,
&njs_string_object,
&njs_string_function,
&njs_string_object,
&njs_string_object,
&njs_string_object,
&njs_string_object,
&njs_string_object,
&njs_string_object,
};
vm->retval = *types[value->type];
return sizeof(njs_vmcode_2addr_t);
} | 1 | null | -1 | https://github.com/nginx/njs/commit/d457c9545e7e71ebb5c0479eb16b9d33175855e2 | 0CCPP |
int uwsgi_run_command_putenv_and_wait(char *command, char *arg, char **envs, unsigned int nenvs) {
int waitpid_status = 0;
pid_t pid = fork();
if (pid < 0) {
return -1;
}
if (pid > 0) {
if (waitpid(pid, &waitpid_status, 0) < 0) {
uwsgi_error("uwsgi_run_command_and_wait()/waitpid()");
return -1;
}
return WEXITSTATUS(waitpid_status);
}
unsigned int i;
for (i = 0; i < nenvs; i++) {
if (putenv(envs[i])) {
uwsgi_error("uwsgi_run_command_putenv_and_wait()/putenv()");
exit(1);
}
}
return uwsgi_run_command_do(command, arg);
} | 0 | null | -1 | https://github.com/unbit/uwsgi/commit/cb4636f7c0af2e97a4eef7a3cdcbd85a71247bfe | 0CCPP |
"geTempDlgCreateBtn geTempDlgBtnDisabled")}function z(ha,da){if(null!=J){var ca=function(pa){qa.isExternal?g(qa,function(na){la(na,pa)},ia):qa.url?mxUtils.get(TEMPLATE_PATH+"/"+qa.url,mxUtils.bind(this,function(na){200<=na.getStatus()&&299>=na.getStatus()?la(na.getText(),pa):ia()})):la(b.emptyDiagramXml,pa)},la=function(pa,na){y||b.hideDialog(!0);e(pa,na,qa,da)},ia=function(){A(mxResources.get("cannotLoad"));ma()},ma=function(){J=qa;za.className="geTempDlgCreateBtn";da&&(Ga.className="geTempDlgOpenBtn")}, | 1 | 0 | -1 | https://github.com/jgraph/drawio/commit/4deecee18191f67e242422abf3ca304e19e49687 | 3JavaScript |
options.open = function() {
var pane = $(this).next(),
width = parseInt(pane.children(':first').outerWidth() + pane.children(':last').outerWidth());
if (width > parseInt(pane.width())) {
$(this).closest('.elfinder-dialog').width(width+30);
}
} | 1 | 0,1,2,3,4,5,6 | -1 | https://github.com/semplon/GeniXCMS/commit/d885eb20006099262c0278932b9f8aca3c1ac97f | 3JavaScript |
int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature,
char *data, EVP_PKEY *pkey)
{
EVP_MD_CTX ctx;
const EVP_MD *type;
unsigned char *p,*buf_in=NULL;
int ret= -1,i,inl;
EVP_MD_CTX_init(&ctx);
i=OBJ_obj2nid(a->algorithm);
type=EVP_get_digestbyname(OBJ_nid2sn(i));
if (type == NULL)
{
ASN1err(ASN1_F_ASN1_VERIFY,ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM);
goto err;
}
inl=i2d(data,NULL);
buf_in=OPENSSL_malloc((unsigned int)inl);
if (buf_in == NULL)
{
ASN1err(ASN1_F_ASN1_VERIFY,ERR_R_MALLOC_FAILURE);
goto err;
}
p=buf_in;
i2d(data,&p);
ret=
EVP_VerifyInit_ex(&ctx,type, NULL)
&& EVP_VerifyUpdate(&ctx,(unsigned char *)buf_in,inl);
OPENSSL_cleanse(buf_in,(unsigned int)inl);
OPENSSL_free(buf_in);
if (!ret)
{
ASN1err(ASN1_F_ASN1_VERIFY,ERR_R_EVP_LIB);
goto err;
}
ret = -1;
if (EVP_VerifyFinal(&ctx,(unsigned char *)signature->data,
(unsigned int)signature->length,pkey) <= 0)
{
ASN1err(ASN1_F_ASN1_VERIFY,ERR_R_EVP_LIB);
ret=0;
goto err;
}
ret=1;
err:
EVP_MD_CTX_cleanup(&ctx);
return(ret);
} | 1 | null | -1 | https://github.com/openssl/openssl/commit/684400ce192dac51df3d3e92b61830a6ef90be3e | 0CCPP |
static inline int range_is_allowed(unsigned long pfn, unsigned long size)
{
u64 from = ((u64)pfn) << PAGE_SHIFT;
u64 to = from + size;
u64 cursor = from;
while (cursor < to) {
if (!devmem_is_allowed(pfn))
return 0;
cursor += PAGE_SIZE;
pfn++;
}
return 1;
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/a4866aa812518ed1a37d8ea0c881dc946409de94 | 0CCPP |
public void should_throw_UnsuccessfulCommandExecutionException_if_connection_to_updater_service_fails()
{
_sleeper.Expect(x => x.Sleep(Arg<int>.Is.Anything));
_connectionChecker.Stub(x => x.Check())
.Throw(new UnsuccessfulCommandExecutionException("error message", new ExecutableResult { ExitCode = "1" }));
var result = _xentoolsUpdate.Execute(_agentUpdateInfo);
Assert.That(result.ExitCode, Is.EqualTo("1"));
Assert.That(result.Error[0], Is.EqualTo("Update failed"));
} | 1 | 0,1,2,3,4,5,6,7,8 | -1 | https://github.com/rackerlabs/openstack-guest-agents-windows-xenserver/commit/ef16f88f20254b8083e361f11707da25f8482401 | 1CS |
public Media createMedia(String title, String description, Object mediaObject, String businessPath, Identity author) {
Media media = null;
if (mediaObject instanceof EfficiencyStatement) {
EfficiencyStatement statement = (EfficiencyStatement) mediaObject;
String xml = myXStream.toXML(statement);
media = mediaDao.createMedia(title, description, xml, EFF_MEDIA, businessPath, null, 90, author);
ThreadLocalUserActivityLogger.log(PortfolioLoggingAction.PORTFOLIO_MEDIA_ADDED, getClass(),
LoggingResourceable.wrap(media));
}
return media;
} | 1 | 4 | -1 | https://github.com/OpenOLAT/OpenOLAT/commit/3f219ac457afde82e3be57bc614352ab92c05684 | 2Java |
static int packet_set_ring(struct sock *sk, union tpacket_req_u *req_u,
int closing, int tx_ring)
{
struct pgv *pg_vec = NULL;
struct packet_sock *po = pkt_sk(sk);
int was_running, order = 0;
struct packet_ring_buffer *rb;
struct sk_buff_head *rb_queue;
__be16 num;
int err = -EINVAL;
struct tpacket_req *req = &req_u->req;
if (!closing && tx_ring && (po->tp_version > TPACKET_V2)) {
net_warn_ratelimited("Tx-ring is not supported.\n");
goto out;
}
rb = tx_ring ? &po->tx_ring : &po->rx_ring;
rb_queue = tx_ring ? &sk->sk_write_queue : &sk->sk_receive_queue;
err = -EBUSY;
if (!closing) {
if (atomic_read(&po->mapped))
goto out;
if (packet_read_pending(rb))
goto out;
}
if (req->tp_block_nr) {
err = -EBUSY;
if (unlikely(rb->pg_vec))
goto out;
switch (po->tp_version) {
case TPACKET_V1:
po->tp_hdrlen = TPACKET_HDRLEN;
break;
case TPACKET_V2:
po->tp_hdrlen = TPACKET2_HDRLEN;
break;
case TPACKET_V3:
po->tp_hdrlen = TPACKET3_HDRLEN;
break;
}
err = -EINVAL;
if (unlikely((int)req->tp_block_size <= 0))
goto out;
if (unlikely(!PAGE_ALIGNED(req->tp_block_size)))
goto out;
if (po->tp_version >= TPACKET_V3 &&
(int)(req->tp_block_size -
BLK_PLUS_PRIV(req_u->req3.tp_sizeof_priv)) <= 0)
goto out;
if (unlikely(req->tp_frame_size < po->tp_hdrlen +
po->tp_reserve))
goto out;
if (unlikely(req->tp_frame_size & (TPACKET_ALIGNMENT - 1)))
goto out;
rb->frames_per_block = req->tp_block_size / req->tp_frame_size;
if (unlikely(rb->frames_per_block == 0))
goto out;
if (unlikely((rb->frames_per_block * req->tp_block_nr) !=
req->tp_frame_nr))
goto out;
err = -ENOMEM;
order = get_order(req->tp_block_size);
pg_vec = alloc_pg_vec(req, order);
if (unlikely(!pg_vec))
goto out;
switch (po->tp_version) {
case TPACKET_V3:
if (!tx_ring)
init_prb_bdqc(po, rb, pg_vec, req_u);
break;
default:
break;
}
}
else {
err = -EINVAL;
if (unlikely(req->tp_frame_nr))
goto out;
}
lock_sock(sk);
spin_lock(&po->bind_lock);
was_running = po->running;
num = po->num;
if (was_running) {
po->num = 0;
__unregister_prot_hook(sk, false);
}
spin_unlock(&po->bind_lock);
synchronize_net();
err = -EBUSY;
mutex_lock(&po->pg_vec_lock);
if (closing || atomic_read(&po->mapped) == 0) {
err = 0;
spin_lock_bh(&rb_queue->lock);
swap(rb->pg_vec, pg_vec);
rb->frame_max = (req->tp_frame_nr - 1);
rb->head = 0;
rb->frame_size = req->tp_frame_size;
spin_unlock_bh(&rb_queue->lock);
swap(rb->pg_vec_order, order);
swap(rb->pg_vec_len, req->tp_block_nr);
rb->pg_vec_pages = req->tp_block_size/PAGE_SIZE;
po->prot_hook.func = (po->rx_ring.pg_vec) ?
tpacket_rcv : packet_rcv;
skb_queue_purge(rb_queue);
if (atomic_read(&po->mapped))
pr_err("packet_mmap: vma is busy: %d\n",
atomic_read(&po->mapped));
}
mutex_unlock(&po->pg_vec_lock);
spin_lock(&po->bind_lock);
if (was_running) {
po->num = num;
register_prot_hook(sk);
}
spin_unlock(&po->bind_lock);
if (closing && (po->tp_version > TPACKET_V2)) {
if (!tx_ring)
prb_shutdown_retire_blk_timer(po, rb_queue);
}
release_sock(sk);
if (pg_vec)
free_pg_vec(pg_vec, order, req->tp_block_nr);
out:
return err;
} | 1 | 78,119 | -1 | https://github.com/torvalds/linux/commit/84ac7260236a49c79eede91617700174c2c19b0c | 0CCPP |
function drawPointHighlight(series, point) {
var x = point[0], y = point[1],
axisx = series.xaxis, axisy = series.yaxis,
highlightColor = (typeof series.highlightColor === "string") ? series.highlightColor : $.color.parse(series.color).scale('a', 0.5).toString();
if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max)
return;
var pointRadius = series.points.radius + series.points.lineWidth / 2;
octx.lineWidth = pointRadius;
octx.strokeStyle = highlightColor;
var radius = 1.5 * pointRadius;
x = axisx.p2c(x);
y = axisy.p2c(y);
octx.beginPath();
if (series.points.symbol == "circle")
octx.arc(x, y, radius, 0, 2 * Math.PI, false);
else
series.points.symbol(octx, x, y, radius, false);
octx.closePath();
octx.stroke();
} | 0 | null | -1 | https://github.com/semplon/GeniXCMS/commit/d885eb20006099262c0278932b9f8aca3c1ac97f | 3JavaScript |
def __init__(self, directory=None, pattern="__jinja2_%s.cache"):
if directory is None:
directory = tempfile.gettempdir()
self.directory = directory
self.pattern = pattern
| 1 | 2 | -1 | https://github.com/pallets/jinja.git/commit/acb672b6a179567632e032f547582f30fa2f4aa7 | 4Python |
na},null,null,null,ma,x?null:[]),b.showDialog(ha.container,350,80,!0,!0),ha.init())}}function L(ha){za.innerHTML=mxUtils.htmlEntities(mxResources.get(Z||ha?"create":"copy"));ha=ha?"none":"";p&&(Ga.style.display=ha);for(var da=M.querySelectorAll(".geTempDlgLinkToDiagram"),ca=0;ca<da.length;ca++)da[ca].style.display=ha}function C(ha,da,ca,la,ia){ia||(aa.innerHTML="",t(),R=ha,Y=la);var ma=null;if(ca){ma=document.createElement("table");ma.className="geTempDlgDiagramsListGrid";var qa=document.createElement("tr"), | 1 | 0 | -1 | https://github.com/jgraph/drawio/commit/4deecee18191f67e242422abf3ca304e19e49687 | 3JavaScript |
Line.prototype.calc = function() {
this.calcPoints();
return this.generatePaths();
}; | 0 | null | -1 | https://github.com/semplon/GeniXCMS/commit/d885eb20006099262c0278932b9f8aca3c1ac97f | 3JavaScript |
public HudsonPrivateSecurityRealm(boolean allowsSignup, boolean enableCaptcha, CaptchaSupport captchaSupport) {
this.disableSignup = !allowsSignup;
this.enableCaptcha = enableCaptcha;
setCaptchaSupport(captchaSupport);
if(!allowsSignup && !hasSomeUser()) {
try {
PluginServletFilter.addFilter(CREATE_FIRST_USER_FILTER);
} catch (ServletException e) {
throw new AssertionError(e);
}
}
} | 0 | null | -1 | https://github.com/jenkinsci/jenkins/commit/fbf96734470caba9364f04e0b77b0bae7293a1ec | 2Java |
mrb_obj_equal_m(mrb_state *mrb, mrb_value self)
{
mrb_value arg = mrb_get_arg1(mrb);
return mrb_bool_value(mrb_obj_equal(mrb, self, arg));
} | 0 | null | -1 | https://github.com/mruby/mruby/commit/b1d0296a937fe278239bdfac840a3fd0e93b3ee9 | 0CCPP |
static void swap_free_obj(struct page *page, unsigned int a, unsigned int b)
{
swap(((freelist_idx_t *)page->freelist)[a],
((freelist_idx_t *)page->freelist)[b]);
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/c4e490cf148e85ead0d1b1c2caaba833f1d5b29f | 0CCPP |
void CoreUserInputHandler::handleMsg(const BufferInfo &bufferInfo, const QString &msg)
{
Q_UNUSED(bufferInfo);
if (!msg.contains(' '))
return;
QString target = msg.section(' ', 0, 0);
QByteArray encMsg = userEncode(target, msg.section(' ', 1));
#ifdef HAVE_QCA2
putPrivmsg(serverEncode(target), encMsg, network()->cipher(target));
#else
putPrivmsg(serverEncode(target), encMsg);
#endif
} | 1 | 6,8,10 | -1 | https://github.com/quassel/quassel/commit/b5e38970ffd55e2dd9f706ce75af9a8d7730b1b8 | 0CCPP |
protected void setDocumentReference(DocumentReference documentReference)
{
this.documentReference = documentReference;
} | 0 | null | -1 | https://github.com/xwiki/xwiki-platform/commit/4917c8f355717bb636d763844528b1fe0f95e8e2 | 2Java |
static bool tailmatch(const char *little, const char *bigone)
{
size_t littlelen = strlen(little);
size_t biglen = strlen(bigone);
if(littlelen > biglen)
return FALSE;
return Curl_raw_equal(little, bigone+biglen-littlelen) ? TRUE : FALSE;
} | 1 | 0,2,3,4,6 | -1 | https://github.com/curl/curl/commit/2eb8dcf26cb37f09cffe26909a646e702dbcab66 | 0CCPP |
async def check_credentials(username: str, password: str) -> bool:
return (username, password) == credentials
| 1 | 0,1 | -1 | https://github.com/python-websockets/websockets.git/commit/547a26b685d08cac0aa64e5e65f7867ac0ea9bc0 | 4Python |
pci_get_vdev_info(int slot)
{
struct businfo *bi;
struct slotinfo *si;
struct pci_vdev *dev = NULL;
bi = pci_businfo[0];
assert(bi != NULL);
si = &bi->slotinfo[slot];
if (si != NULL)
dev = si->si_funcs[0].fi_devi;
else
fprintf(stderr, "slot=%d is empty!\n", slot);
return dev;
} | 1 | 6 | -1 | https://github.com/projectacrn/acrn-hypervisor/commit/2b3dedfb9ba13f15887f22b935d373f36c9a59fa | 0CCPP |
static int sanitize_ptr_alu(struct bpf_verifier_env *env,
struct bpf_insn *insn,
const struct bpf_reg_state *ptr_reg,
const struct bpf_reg_state *off_reg,
struct bpf_reg_state *dst_reg,
struct bpf_sanitize_info *info,
const bool commit_window)
{
struct bpf_insn_aux_data *aux = commit_window ? cur_aux(env) : &info->aux;
struct bpf_verifier_state *vstate = env->cur_state;
bool off_is_imm = tnum_is_const(off_reg->var_off);
bool off_is_neg = off_reg->smin_value < 0;
bool ptr_is_dst_reg = ptr_reg == dst_reg;
u8 opcode = BPF_OP(insn->code);
u32 alu_state, alu_limit;
struct bpf_reg_state tmp;
bool ret;
int err;
if (can_skip_alu_sanitation(env, insn))
return 0;
if (vstate->speculative)
goto do_sim;
if (!commit_window) {
if (!tnum_is_const(off_reg->var_off) &&
(off_reg->smin_value < 0) != (off_reg->smax_value < 0))
return REASON_BOUNDS;
info->mask_to_left = (opcode == BPF_ADD && off_is_neg) ||
(opcode == BPF_SUB && !off_is_neg);
}
err = retrieve_ptr_limit(ptr_reg, &alu_limit, info->mask_to_left);
if (err < 0)
return err;
if (commit_window) {
alu_state = info->aux.alu_state;
alu_limit = abs(info->aux.alu_limit - alu_limit);
} else {
alu_state = off_is_neg ? BPF_ALU_NEG_VALUE : 0;
alu_state |= off_is_imm ? BPF_ALU_IMMEDIATE : 0;
alu_state |= ptr_is_dst_reg ?
BPF_ALU_SANITIZE_SRC : BPF_ALU_SANITIZE_DST;
}
err = update_alu_sanitation_state(aux, alu_state, alu_limit);
if (err < 0)
return err;
do_sim:
if (commit_window || off_is_imm)
return 0;
if (!ptr_is_dst_reg) {
tmp = *dst_reg;
*dst_reg = *ptr_reg;
}
ret = push_stack(env, env->insn_idx + 1, env->insn_idx, true);
if (!ptr_is_dst_reg && ret)
*dst_reg = tmp;
return !ret ? REASON_STACK : 0;
} | 1 | 51 | -1 | https://github.com/torvalds/linux/commit/9183671af6dbf60a1219371d4ed73e23f43b49db | 0CCPP |
void APE::Properties::analyzeCurrent()
{
d->file->seek(2, File::Current);
ByteVector descriptor = d->file->readBlock(44);
uint descriptorBytes = descriptor.mid(0,4).toUInt(false);
if ((descriptorBytes - 52) > 0)
d->file->seek(descriptorBytes - 52, File::Current);
ByteVector header = d->file->readBlock(24);
d->channels = header.mid(18, 2).toShort(false);
d->sampleRate = header.mid(20, 4).toUInt(false);
d->bitsPerSample = header.mid(16, 2).toShort(false);
uint totalFrames = header.mid(12, 4).toUInt(false);
uint blocksPerFrame = header.mid(4, 4).toUInt(false);
uint finalFrameBlocks = header.mid(8, 4).toUInt(false);
uint totalBlocks = totalFrames > 0 ? (totalFrames - 1) * blocksPerFrame + finalFrameBlocks : 0;
d->length = totalBlocks / d->sampleRate;
d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0;
} | 1 | 15 | -1 | https://github.com/taglib/taglib/commit/77d61c6eca4d08b9b025738acf6b926cc750db23 | 0CCPP |
void QuickOpen::Load(uint64 BlockPos)
{
if (!Loaded) //
{
SeekPos=Arc->Tell();
UnsyncSeekPos=false;
SaveFilePos SavePos(*Arc);
Arc->Seek(BlockPos,SEEK_SET);
if (Arc->ReadHeader()==0 || Arc->GetHeaderType()!=HEAD_SERVICE ||
!Arc->SubHead.CmpName(SUBHEAD_TYPE_QOPEN))
return;
QLHeaderPos=Arc->CurBlockPos;
RawDataStart=Arc->Tell();
RawDataSize=Arc->SubHead.UnpSize;
Loaded=true;
}
if (Arc->SubHead.Encrypted)
{
RAROptions *Cmd=Arc->GetRAROptions();
#ifndef RAR_NOCRYPT
if (Cmd->Password.IsSet())
Crypt.SetCryptKeys(false,CRYPT_RAR50,&Cmd->Password,Arc->SubHead.Salt,
Arc->SubHead.InitV,Arc->SubHead.Lg2Count,
Arc->SubHead.HashKey,Arc->SubHead.PswCheck);
else
#endif
return;
}
RawDataPos=0;
ReadBufSize=0;
ReadBufPos=0;
LastReadHeader.Reset();
LastReadHeaderPos=0;
ReadBuffer();
} | 1 | 2,8 | -1 | https://github.com/aawc/unrar/commit/0ff832d31470471803b175cfff4e40c1b08ee779 | 0CCPP |
static inline int usb_get_std_status(struct usb_device *dev,
int recip, int target, void *data)
{
return usb_get_status(dev, recip, USB_STATUS_TYPE_STANDARD, target,
data);
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/704620afc70cf47abb9d6a1a57f3825d2bca49cf | 0CCPP |
ASC_closeTransportConnection(T_ASC_Association * association)
{
if (association == NULL) return EC_Normal;
if (association->DULassociation == NULL) return EC_Normal;
return DUL_CloseTransportConnection(&association->DULassociation);
} | 0 | null | -1 | https://github.com/DCMTK/dcmtk/commit/a9697dfeb672b0b9412c00c7d36d801e27ec85cb | 0CCPP |
flatpak_fail_error (GError **error, FlatpakError code, const char *fmt, ...)
{
if (error == NULL)
return FALSE;
va_list args;
va_start (args, fmt);
GError *new = g_error_new_valist (FLATPAK_ERROR, code, fmt, args);
va_end (args);
g_propagate_error (error, g_steal_pointer (&new));
return FALSE;
} | 0 | null | -1 | https://github.com/flatpak/flatpak/commit/ba818f504c926baaf6e362be8159cfacf994310e | 0CCPP |
static int vmx_check_intercept(struct kvm_vcpu *vcpu,
struct x86_instruction_info *info,
enum x86_intercept_stage stage)
{
struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
struct x86_emulate_ctxt *ctxt = &vcpu->arch.emulate_ctxt;
if (info->intercept == x86_intercept_rdtscp &&
!nested_cpu_has2(vmcs12, SECONDARY_EXEC_RDTSCP)) {
ctxt->exception.vector = UD_VECTOR;
ctxt->exception.error_code_valid = false;
return X86EMUL_PROPAGATE_FAULT;
}
return X86EMUL_CONTINUE;
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/727ba748e110b4de50d142edca9d6a9b7e6111d8 | 0CCPP |
IW_IMPL(int) iw_get_i32le(const iw_byte *b)
{
return (iw_int32)(iw_uint32)(b[0] | (b[1]<<8) | (b[2]<<16) | (b[3]<<24));
} | 1 | 2 | -1 | https://github.com/jsummers/imageworsener/commit/a00183107d4b84bc8a714290e824ca9c68dac738 | 0CCPP |
static inline int pud_none_or_clear_bad(pud_t *pud)
{
if (pud_none(*pud))
return 1;
if (unlikely(pud_bad(*pud))) {
pud_clear_bad(pud);
return 1;
}
return 0;
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/ee53664bda169f519ce3c6a22d378f0b946c8178 | 0CCPP |
private static async Task<string?> ResponseLootByRealAppIDs(EAccess access, string botNames, string realAppIDsText, bool exclude = false) {
if (!Enum.IsDefined(access)) {
throw new InvalidEnumArgumentException(nameof(access), (int) access, typeof(EAccess));
}
if (string.IsNullOrEmpty(botNames)) {
throw new ArgumentNullException(nameof(botNames));
}
if (string.IsNullOrEmpty(realAppIDsText)) {
throw new ArgumentNullException(nameof(realAppIDsText));
}
HashSet<Bot>? bots = Bot.GetBots(botNames);
if ((bots == null) || (bots.Count == 0)) {
return access >= EAccess.Owner ? FormatStaticResponse(string.Format(CultureInfo.CurrentCulture, Strings.BotNotFound, botNames)) : null;
}
IList<string?> results = await Utilities.InParallel(bots.Select(bot => bot.Commands.ResponseLootByRealAppIDs(access, realAppIDsText, exclude))).ConfigureAwait(false);
List<string> responses = new(results.Where(static result => !string.IsNullOrEmpty(result))!);
return responses.Count > 0 ? string.Join(Environment.NewLine, responses) : null;
} | 1 | 0,14 | -1 | https://github.com/JustArchiNET/ArchiSteamFarm/commit/f807bdb660e75dee5a34994f2ea70970ca6d0492 | 1CS |
DSA_PrivateKey::create_signature_op(RandomNumberGenerator& /*
const std::string& params,
const std::string& provider) const
{
if(provider == "base" || provider.empty())
return std::unique_ptr<PK_Ops::Signature>(new DSA_Signature_Operation(*this, params));
throw Provider_Not_Found(algo_name(), provider);
} | 1 | 0,5 | -1 | https://github.com/randombit/botan/commit/48fc8df51d99f9d8ba251219367b3d629cc848e3 | 0CCPP |
void Compute(OpKernelContext* const context) override {
const Tensor* node_ids_t;
OP_REQUIRES_OK(context, context->input("node_ids", &node_ids_t));
const auto node_ids = node_ids_t->vec<int32>();
const Tensor* gradients_t;
OP_REQUIRES_OK(context, context->input("gradients", &gradients_t));
const auto gradients = gradients_t->matrix<float>();
const Tensor* hessians_t;
OP_REQUIRES_OK(context, context->input("hessians", &hessians_t));
const auto hessians = hessians_t->matrix<float>();
const Tensor* feature_t;
OP_REQUIRES_OK(context, context->input("feature", &feature_t));
const auto feature = feature_t->matrix<int32>();
const int64_t batch_size = node_ids_t->dim_size(0);
const int64_t logits_dims = gradients_t->dim_size(1);
const int64_t hessians_dims = hessians_t->dim_size(1);
const int64_t stats_dims = logits_dims + hessians_dims;
const int64_t feature_dims = feature_t->dim_size(1);
Tensor temp_stats_double_t;
OP_REQUIRES_OK(
context, context->allocate_temp(
DT_DOUBLE,
{max_splits_, feature_dims, num_buckets_ + 1, stats_dims},
&temp_stats_double_t));
auto temp_stats_double = temp_stats_double_t.tensor<double, 4>();
temp_stats_double.setZero();
for (int i = 0; i < batch_size; ++i) {
const int32_t node = node_ids(i);
for (int feature_dim = 0; feature_dim < feature_dims; ++feature_dim) {
const int32_t feature_value = feature(i, feature_dim);
const int32_t bucket =
(feature_value == -1) ? num_buckets_ : feature_value;
for (int stat_dim = 0; stat_dim < logits_dims; ++stat_dim) {
temp_stats_double(node, feature_dim, bucket, stat_dim) +=
gradients(i, stat_dim);
}
for (int stat_dim = logits_dims; stat_dim < stats_dims; ++stat_dim) {
temp_stats_double(node, feature_dim, bucket, stat_dim) +=
hessians(i, stat_dim - logits_dims);
}
}
}
Tensor* output_stats_summary_t = nullptr;
OP_REQUIRES_OK(context, context->allocate_output(
"stats_summary", temp_stats_double_t.shape(),
&output_stats_summary_t));
output_stats_summary_t->tensor<float, 4>() =
temp_stats_double.template cast<float>();
} | 1 | null | -1 | https://github.com/tensorflow/tensorflow/commit/5c8c9a8bfe750f9743d0c859bae112060b216f5c | 0CCPP |
(z=2);return z};var I=mxVertexHandler.prototype.getSelectionBorderBounds;mxVertexHandler.prototype.getSelectionBorderBounds=function(){return I.apply(this,arguments).grow(-this.getSelectionBorderInset())};var V=null,Q=mxVertexHandler.prototype.createCustomHandles;mxVertexHandler.prototype.createCustomHandles=function(){null==V&&(V=mxCellRenderer.defaultShapes.tableLine);var z=Q.apply(this,arguments);if(this.graph.isTable(this.state.cell)){var L=function(Ta,za,wa){for(var Ea=[],Da=0;Da<Ta.length;Da++){var La= | 1 | 0 | -1 | https://github.com/jgraph/drawio/commit/4deecee18191f67e242422abf3ca304e19e49687 | 3JavaScript |
static void ims_pcu_destroy_buttons(struct ims_pcu *pcu)
{
struct ims_pcu_buttons *buttons = &pcu->buttons;
input_unregister_device(buttons->input);
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/a0ad220c96692eda76b2e3fd7279f3dcd1d8a8ff | 0CCPP |
static void ikev2_parent_inI1outR1_continue(struct pluto_crypto_req_cont *pcrc,
struct pluto_crypto_req *r,
err_t ugh)
{
struct ke_continuation *ke = (struct ke_continuation *)pcrc;
struct msg_digest *md = ke->md;
struct state *const st = md->st;
stf_status e;
DBG(DBG_CONTROLMORE,
DBG_log("ikev2 parent inI1outR1: calculated ke+nonce, sending R1"));
if (st == NULL) {
loglog(RC_LOG_SERIOUS,
"%s: Request was disconnected from state",
__FUNCTION__);
if (ke->md)
release_md(ke->md);
return;
}
passert(ugh == NULL);
passert(cur_state == NULL);
passert(st != NULL);
passert(st->st_suspended_md == ke->md);
set_suspended(st, NULL);
set_cur_state(st);
st->st_calculating = FALSE;
e = ikev2_parent_inI1outR1_tail(pcrc, r);
if (ke->md != NULL) {
complete_v2_state_transition(&ke->md, e);
if (ke->md)
release_md(ke->md);
}
reset_globals();
passert(GLOBALS_ARE_RESET());
} | 1 | 32 | -1 | https://github.com/libreswan/libreswan/commit/2899351224fe2940aec37d7656e1e392c0fe07f0 | 0CCPP |
private int
magiccheck(struct magic_set *ms, struct magic *m)
{
uint64_t l = m->value.q;
uint64_t v;
float fl, fv;
double dl, dv;
int matched;
union VALUETYPE *p = &ms->ms_value;
switch (m->type) {
case FILE_BYTE:
v = p->b;
break;
case FILE_SHORT:
case FILE_BESHORT:
case FILE_LESHORT:
v = p->h;
break;
case FILE_LONG:
case FILE_BELONG:
case FILE_LELONG:
case FILE_MELONG:
case FILE_DATE:
case FILE_BEDATE:
case FILE_LEDATE:
case FILE_MEDATE:
case FILE_LDATE:
case FILE_BELDATE:
case FILE_LELDATE:
case FILE_MELDATE:
v = p->l;
break;
case FILE_QUAD:
case FILE_LEQUAD:
case FILE_BEQUAD:
case FILE_QDATE:
case FILE_BEQDATE:
case FILE_LEQDATE:
case FILE_QLDATE:
case FILE_BEQLDATE:
case FILE_LEQLDATE:
case FILE_QWDATE:
case FILE_BEQWDATE:
case FILE_LEQWDATE:
v = p->q;
break;
case FILE_FLOAT:
case FILE_BEFLOAT:
case FILE_LEFLOAT:
fl = m->value.f;
fv = p->f;
switch (m->reln) {
case 'x':
matched = 1;
break;
case '!':
matched = fv != fl;
break;
case '=':
matched = fv == fl;
break;
case '>':
matched = fv > fl;
break;
case '<':
matched = fv < fl;
break;
default:
file_magerror(ms, "cannot happen with float: invalid relation `%c'",
m->reln);
return -1;
}
return matched;
case FILE_DOUBLE:
case FILE_BEDOUBLE:
case FILE_LEDOUBLE:
dl = m->value.d;
dv = p->d;
switch (m->reln) {
case 'x':
matched = 1;
break;
case '!':
matched = dv != dl;
break;
case '=':
matched = dv == dl;
break;
case '>':
matched = dv > dl;
break;
case '<':
matched = dv < dl;
break;
default:
file_magerror(ms, "cannot happen with double: invalid relation `%c'", m->reln);
return -1;
}
return matched;
case FILE_DEFAULT:
case FILE_CLEAR:
l = 0;
v = 0;
break;
case FILE_STRING:
case FILE_PSTRING:
l = 0;
v = file_strncmp(m->value.s, p->s, (size_t)m->vallen, m->str_flags);
break;
case FILE_BESTRING16:
case FILE_LESTRING16:
l = 0;
v = file_strncmp16(m->value.s, p->s, (size_t)m->vallen, m->str_flags);
break;
case FILE_SEARCH: {
size_t slen;
size_t idx;
if (ms->search.s == NULL)
return 0;
slen = MIN(m->vallen, sizeof(m->value.s));
l = 0;
v = 0;
for (idx = 0; m->str_range == 0 || idx < m->str_range; idx++) {
if (slen + idx > ms->search.s_len)
break;
v = file_strncmp(m->value.s, ms->search.s + idx, slen, m->str_flags);
if (v == 0) {
ms->search.offset += idx;
break;
}
}
break;
}
case FILE_REGEX: {
int rc;
file_regex_t rx;
if (ms->search.s == NULL)
return 0;
l = 0;
rc = file_regcomp(&rx, m->value.s,
REG_EXTENDED|REG_NEWLINE|
((m->str_flags & STRING_IGNORE_CASE) ? REG_ICASE : 0));
if (rc) {
file_regerror(&rx, rc, ms);
v = (uint64_t)-1;
} else {
#ifndef REG_STARTEND
char c;
#endif
regmatch_t pmatch[1];
size_t slen = ms->search.s_len;
/* Limit by offset if requested */
if (m->str_range > 0)
slen = MIN(slen, m->str_range);
#ifndef REG_STARTEND
#define REG_STARTEND 0
if (slen != 0)
slen--;
c = ms->search.s[slen];
((char *)(intptr_t)ms->search.s)[slen] = '\0';
#else
pmatch[0].rm_so = 0;
pmatch[0].rm_eo = slen;
#endif
rc = file_regexec(&rx, (const char *)ms->search.s,
1, pmatch, REG_STARTEND);
#if REG_STARTEND == 0
((char *)(intptr_t)ms->search.s)[l] = c;
#endif
switch (rc) {
case 0:
ms->search.s += (int)pmatch[0].rm_so;
ms->search.offset += (size_t)pmatch[0].rm_so;
ms->search.rm_len =
(size_t)(pmatch[0].rm_eo - pmatch[0].rm_so);
v = 0;
break;
case REG_NOMATCH:
v = 1;
break;
default:
file_regerror(&rx, rc, ms);
v = (uint64_t)-1;
break;
}
}
file_regfree(&rx);
if (v == (uint64_t)-1)
return -1;
break;
}
case FILE_INDIRECT:
case FILE_USE:
case FILE_NAME:
return 1;
default:
file_magerror(ms, "invalid type %d in magiccheck()", m->type);
return -1;
}
v = file_signextend(ms, m, v);
switch (m->reln) {
case 'x':
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT
"u == *any* = 1\n", (unsigned long long)v);
matched = 1;
break;
case '!':
matched = v != l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT "u != %"
INT64_T_FORMAT "u = %d\n", (unsigned long long)v,
(unsigned long long)l, matched);
break;
case '=':
matched = v == l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT "u == %"
INT64_T_FORMAT "u = %d\n", (unsigned long long)v,
(unsigned long long)l, matched);
break;
case '>':
if (m->flag & UNSIGNED) {
matched = v > l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT
"u > %" INT64_T_FORMAT "u = %d\n",
(unsigned long long)v,
(unsigned long long)l, matched);
}
else {
matched = (int64_t) v > (int64_t) l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT
"d > %" INT64_T_FORMAT "d = %d\n",
(long long)v, (long long)l, matched);
}
break;
case '<':
if (m->flag & UNSIGNED) {
matched = v < l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT
"u < %" INT64_T_FORMAT "u = %d\n",
(unsigned long long)v,
(unsigned long long)l, matched);
}
else {
matched = (int64_t) v < (int64_t) l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "%" INT64_T_FORMAT
"d < %" INT64_T_FORMAT "d = %d\n",
(long long)v, (long long)l, matched);
}
break;
case '&':
matched = (v & l) == l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "((%" INT64_T_FORMAT "x & %"
INT64_T_FORMAT "x) == %" INT64_T_FORMAT
"x) = %d\n", (unsigned long long)v,
(unsigned long long)l, (unsigned long long)l,
matched);
break;
case '^':
matched = (v & l) != l;
if ((ms->flags & MAGIC_DEBUG) != 0)
(void) fprintf(stderr, "((%" INT64_T_FORMAT "x & %"
INT64_T_FORMAT "x) != %" INT64_T_FORMAT
"x) = %d\n", (unsigned long long)v,
(unsigned long long)l, (unsigned long long)l,
matched);
break;
default:
file_magerror(ms, "cannot happen: invalid relation `%c'",
m->reln);
return -1;
} | 1 | 125,146,147,148,151,152,153 | -1 | https://github.com/file/file/commit/4a284c89d6ef11aca34da65da7d673050a5ea320 | 0CCPP |
static int run_ap_work(struct mp_callback *val, long expire_us)
{
int i;
int cpus_accepted;
struct stopwatch sw;
int cur_cpu;
if (!CONFIG(PARALLEL_MP_AP_WORK)) {
printk(BIOS_ERR, "APs already parked. PARALLEL_MP_AP_WORK not selected.\n");
return -1;
}
cur_cpu = cpu_index();
if (cur_cpu < 0) {
printk(BIOS_ERR, "Invalid CPU index.\n");
return -1;
}
for (i = 0; i < ARRAY_SIZE(ap_callbacks); i++) {
if (cur_cpu == i)
continue;
store_callback(&ap_callbacks[i], val);
}
mfence();
if (expire_us > 0)
stopwatch_init_usecs_expire(&sw, expire_us);
do {
cpus_accepted = 0;
for (i = 0; i < ARRAY_SIZE(ap_callbacks); i++) {
if (cur_cpu == i)
continue;
if (read_callback(&ap_callbacks[i]) == NULL)
cpus_accepted++;
}
if (cpus_accepted == global_num_aps)
return 0;
} while (expire_us <= 0 || !stopwatch_expired(&sw));
printk(BIOS_CRIT, "CRITICAL ERROR: AP call expired. %d/%d CPUs accepted.\n",
cpus_accepted, global_num_aps);
return -1;
} | 0 | null | -1 | https://github.com/coreboot/coreboot/commit/afb7a814783cda12f5b72167163b9109ee1d15a7 | 0CCPP |
public static void copyDb(
String jdbcDriverSource,
String usernameSource,
String passwordSource,
String jdbcUrlSource,
String jdbcDriverTarget,
String usernameTarget,
String passwordTarget,
String jdbcUrlTarget,
List<String> includeDbObjects,
List<String> excludeDbObjects,
List<String> valuePatterns,
List<String> valueReplacements,
PrintStream out
) throws ServiceException {
{
DBOBJECTS.clear();
List<String> tableNames = new ArrayList<String>();
try {
tableNames = DbSchemaUtils.getTableNames();
} catch (Exception e) {
new ServiceException(e).log();
}
for(String tableName : tableNames) {
if(
tableName.indexOf("_") > 0 &&
tableName.indexOf("_TOBJ_") < 0 &&
tableName.indexOf("_JOIN_") < 0 &&
!tableName.endsWith("_")
) {
DBOBJECTS.add(tableName);
}
}
}
try {
Class.forName(jdbcDriverSource);
Properties props = new Properties();
props.put("user", usernameSource);
props.put("password", passwordSource);
Connection connSource = DriverManager.getConnection(jdbcUrlSource, props);
connSource.setAutoCommit(false);
Class.forName(jdbcDriverTarget);
props = new Properties();
props.put("user", usernameTarget);
props.put("password", passwordTarget);
Connection connTarget = DriverManager.getConnection(jdbcUrlTarget, props);
connTarget.setAutoCommit(true);
CopyDb.copyNamespace(
connSource,
connTarget,
filterDbObjects(
DBOBJECTS,
includeDbObjects,
excludeDbObjects
),
valuePatterns,
valueReplacements,
out
);
} catch (Exception e) {
throw new ServiceException(e);
}
out.println();
out.println("!!! DONE !!!");
} | 0 | null | -1 | https://github.com/opencrx/opencrx/commit/14e75f95e5f56fbe7ee897bdf5d858788072e818 | 2Java |
shutdown_mib(void)
{
unload_all_mibs();
if (tree_top) {
if (tree_top->label)
SNMP_FREE(tree_top->label);
SNMP_FREE(tree_top);
}
tree_head = NULL;
Mib = NULL;
if (_mibindexes) {
int i;
for (i = 0; i < _mibindex; ++i)
SNMP_FREE(_mibindexes[i]);
free(_mibindexes);
_mibindex = 0;
_mibindex_max = 0;
_mibindexes = NULL;
}
if (Prefix != NULL && Prefix != &Standard_Prefix[0])
SNMP_FREE(Prefix);
if (Prefix)
Prefix = NULL;
SNMP_FREE(confmibs);
SNMP_FREE(confmibdir);
} | 1 | 10,11,12,13,14,15,16,17,18 | -1 | https://github.com/net-snmp/net-snmp/commit/4fd9a450444a434a993bc72f7c3486ccce41f602 | 0CCPP |
public <T> T toBean(Class<T> beanClass) {
setTag(new Tag(beanClass));
if (getVersion() != null) {
try {
MigrationHelper.migrate(getVersion(), beanClass.newInstance(), this);
removeVersion();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
return (T) new OneYaml().construct(this);
} | 1 | null | -1 | https://github.com/theonedev/onedev/commit/d6fc4212b1ac1e9bbe3ce444e95f9af1e3ab8b66 | 2Java |
function isPromiseLike(obj) {
return obj && isFunction(obj.then);
} | 1 | 1 | -1 | https://github.com/peerigon/angular-expressions/commit/061addfb9a9e932a970e5fcb913d020038e65667 | 3JavaScript |
function cellClicked(cell)
{
if (!ui.editor.isChromelessView())
{
graph.container.focus();
}
if (cell == null)
{
highlight.highlight(null);
div.innerHTML = '<p><i>' + mxResources.get('nothingIsSelected') + '</i></p>';
}
else
{
var attrs = (cell.value != null) ? cell.value.attributes : null;
if (ui.editor.isChromelessView())
{
highlight.highlight(graph.view.getState(cell));
}
if (attrs != null)
{
var label = graph.sanitizeHtml(graph.getLabel(cell));
if (label != null && label.length > 0)
{
div.innerHTML = '<h1>' + label + '</h1>';
}
else
{
div.innerHTML = '';
}
for (var i = 0; i < attrs.length; i++)
{
if (mxUtils.indexOf(ignored, attrs[i].nodeName) < 0 &&
attrs[i].nodeValue.length > 0)
{
var h2 = document.createElement('h2');
mxUtils.write(h2, attrs[i].nodeName);
div.appendChild(h2);
var p = document.createElement('p');
mxUtils.write(p, attrs[i].nodeValue);
div.appendChild(p);
}
}
}
else
{
var label = graph.convertValueToString(cell);
if (label != '')
{
div.innerHTML = '<h1>' + graph.sanitizeHtml(label) + '</h1>';
}
else
{
div.innerHTML = '<p><i>No data</i></p>';
}
}
if (!ui.editor.isChromelessView())
{
var button = document.createElement('button');
button.setAttribute('title', 'Click or Shift+Click to write data for all selected cells to the browser console');
button.style['float'] = 'none';
mxUtils.write(button, 'Write to Console');
mxEvent.addListener(button, 'click', function(evt)
{
extractData(evt);
});
div.appendChild(button);
}
}
}; | 1 | 27 | -1 | https://github.com/jgraph/drawio/commit/3d3f819d7a04da7d53b37cc0ca4269c157ba2825 | 3JavaScript |
function have_wrapping(string, prompt_len) {
var lengths = string.split('\n').map(function(line) {
return $.terminal.length(line);
});
if (prompt_len) {
lengths[0] += prompt_len;
}
var wrap = lengths.filter(function(len) {
return len >= num_chars;
});
return !!wrap.length;
} | 0 | null | -1 | https://github.com/jcubic/jquery.terminal/commit/77eb044d0896e990d48a9157f0bc6648f81a84b5 | 3JavaScript |
TEST_F(OpLevelCostEstimatorTest, AddNExecutionTime) {
OpContext op_context;
SetCpuDevice(&op_context.op_info);
op_context.op_info.set_op("AddN");
DescribeTensor4D(1, 10, 10, 10, op_context.op_info.add_inputs());
DescribeTensor4D(1, 10, 10, 10, op_context.op_info.add_inputs());
DescribeTensor4D(1, 10, 10, 10, op_context.op_info.add_inputs());
auto cost = PredictCosts(op_context);
EXPECT_EQ(Costs::Duration(1200), cost.memory_time);
EXPECT_EQ(Costs::Duration(200), cost.compute_time);
EXPECT_EQ(Costs::Duration(1400), cost.execution_time);
EXPECT_EQ(cost.num_ops_total, 1);
EXPECT_FALSE(cost.inaccurate);
EXPECT_EQ(cost.num_ops_with_unknown_shapes, 0);
EXPECT_EQ(cost.temporary_memory, 0);
EXPECT_EQ(cost.persistent_memory, 0);
} | 0 | null | -1 | https://github.com/tensorflow/tensorflow/commit/3218043d6d3a019756607643cf65574fbfef5d7a | 0CCPP |
__u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr,
__be16 sport, __be16 dport)
{
__u32 seq;
__u32 hash[12];
struct keydata *keyptr = get_keyptr();
/* The procedure is the same as for IPv4, but addresses are longer.
* Thus we must use twothirdsMD4Transform.
*/
memcpy(hash, saddr, 16);
hash[4] = ((__force u16)sport << 16) + (__force u16)dport;
memcpy(&hash[5], keyptr->secret, sizeof(__u32) * 7);
seq = twothirdsMD4Transform((const __u32 *)daddr, hash) & HASH_MASK;
seq += keyptr->count;
seq += ktime_to_ns(ktime_get_real());
return seq;
} | 1 | 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 | -1 | https://github.com/torvalds/linux/commit/6e5714eaf77d79ae1c8b47e3e040ff5411b717ec | 0CCPP |
function getData(callback) {
adapter.log.info('requesting all states');
let tasks = 0;
tasks++;
adapter.getForeignStates('*', (err, res) => {
adapter.log.info('received all states');
states = res;
!--tasks && callback && callback();
});
adapter.log.info('requesting all objects');
tasks++;
adapter.objects.getObjectList({include_docs: true}, (err, res) => {
adapter.log.info('received all objects');
if (res) {
res = res.rows;
objects = {};
let tmpPath = '';
for (let i = 0; i < res.length; i++) {
objects[res[i].doc._id] = res[i].doc;
if (res[i].doc.type === 'instance' && res[i].doc.common && res[i].doc.common.tmpPath) {
tmpPath && adapter.log.warn('tmpPath has multiple definitions!!');
tmpPath = res[i].doc.common.tmpPath;
}
}
if (tmpPath) {
adapter.config.tmpPath = tmpPath;
adapter.config.tmpPathAllow = true;
}
createUpdateInfo();
writeUpdateInfo();
}
!--tasks && callback && callback();
});
} | 1 | 2,8,10,31 | -1 | https://github.com/ioBroker/ioBroker.admin/commit/16b2b325ab47896090bc7f54b77b0a97ed74f5cd | 3JavaScript |
static inline int get_blocktype_secs(struct f2fs_sb_info *sbi, int block_type)
{
unsigned int pages_per_sec = sbi->segs_per_sec * sbi->blocks_per_seg;
unsigned int segs = (get_pages(sbi, block_type) + pages_per_sec - 1) >>
sbi->log_blocks_per_seg;
return segs / sbi->segs_per_sec;
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/638164a2718f337ea224b747cf5977ef143166a4 | 0CCPP |
public static void RestartAgent()
{
_LastSession = Desktop.WTSGetActiveConsoleSessionId();
_CurrentSession = _LastSession;
try
{
agentProcess?.Kill();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Thread.Sleep(3000);
ProcessStarter.PROCESS_INFORMATION agentInfo;
var agentPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),"UlteriusAgent.exe");
ProcessStarter.StartProcessAndBypassUAC(agentPath,
out agentInfo);
agentProcess = Process.GetProcessById((int)agentInfo.dwProcessId);
if (agentProcess != null)
{
Console.WriteLine("Started Monitor on " + _CurrentSession);
}
else
{
Console.WriteLine("Failed to start monitor on " + _CurrentSession);
}
} | 1 | 13,14,15,16,17 | -1 | https://github.com/Ulterius/server/commit/770d1821de43cf1d0a93c79025995bdd812a76ee | 1CS |
public Entry<P> addPrimitive(final P primitive, Keyset.Key key)
throws GeneralSecurityException {
if (key.getStatus() != KeyStatusType.ENABLED) {
throw new GeneralSecurityException("only ENABLED key is allowed");
}
Entry<P> entry =
new Entry<P>(
primitive,
CryptoFormat.getOutputPrefix(key),
key.getStatus(),
key.getOutputPrefixType(),
key.getKeyId());
List<Entry<P>> list = new ArrayList<Entry<P>>();
list.add(entry);
// Cannot use [] as keys in hash map, convert to string.
String identifier = new String(entry.getIdentifier(), UTF_8);
List<Entry<P>> existing = primitives.put(identifier, Collections.unmodifiableList(list));
if (existing != null) {
List<Entry<P>> newList = new ArrayList<Entry<P>>();
newList.addAll(existing);
newList.add(entry);
primitives.put(identifier, Collections.unmodifiableList(newList));
}
return entry;
} | 1 | 14,15 | -1 | https://github.com/google/tink/commit/93d839a5865b9d950dffdc9d0bc99b71280a8899 | 2Java |
static ssize_t cm_write(struct file *file, const char __user * user_buf,
size_t count, loff_t *ppos)
{
static char *buf;
static u32 max_size;
static u32 uncopied_bytes;
struct acpi_table_header table;
acpi_status status;
if (!(*ppos)) {
/* parse the table header to get the table length */
if (count <= sizeof(struct acpi_table_header))
return -EINVAL;
if (copy_from_user(&table, user_buf,
sizeof(struct acpi_table_header)))
return -EFAULT;
uncopied_bytes = max_size = table.length;
buf = kzalloc(max_size, GFP_KERNEL);
if (!buf)
return -ENOMEM;
}
if (buf == NULL)
return -EINVAL;
if ((*ppos > max_size) ||
(*ppos + count > max_size) ||
(*ppos + count < count) ||
(count > uncopied_bytes))
return -EINVAL;
if (copy_from_user(buf + (*ppos), user_buf, count)) {
kfree(buf);
buf = NULL;
return -EFAULT;
}
uncopied_bytes -= count;
*ppos += count;
if (!uncopied_bytes) {
status = acpi_install_method(buf);
kfree(buf);
buf = NULL;
if (ACPI_FAILURE(status))
return -EINVAL;
add_taint(TAINT_OVERRIDDEN_ACPI_TABLE);
}
return count;
} | 1 | 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43 | -1 | https://github.com/torvalds/linux/commit/526b4af47f44148c9d665e57723ed9f86634c6e3 | 0CCPP |
TfLiteStatus EvalLogic(TfLiteContext* context, TfLiteNode* node,
OpContext* op_context, T init_value,
T reducer(const T current, const T in)) {
int64_t num_axis = NumElements(op_context->axis);
TfLiteTensor* temp_index = GetTemporary(context, node, /*;
TfLiteTensor* resolved_axis = GetTemporary(context, node, /*;
if (IsDynamicTensor(op_context->output)) {
TF_LITE_ENSURE_OK(context,
ResizeTempAxis(context, op_context, resolved_axis));
TF_LITE_ENSURE_OK(context, ResizeOutputTensor(context, op_context));
}
if (op_context->input->type == kTfLiteUInt8 ||
op_context->input->type == kTfLiteInt8) {
TF_LITE_ENSURE_EQ(context, op_context->input->params.scale,
op_context->output->params.scale);
TF_LITE_ENSURE_EQ(context, op_context->input->params.zero_point,
op_context->output->params.zero_point);
}
TF_LITE_ENSURE(
context,
reference_ops::ReduceGeneric<T>(
GetTensorData<T>(op_context->input), op_context->input->dims->data,
op_context->input->dims->size, GetTensorData<T>(op_context->output),
op_context->output->dims->data, op_context->output->dims->size,
GetTensorData<int>(op_context->axis), num_axis,
op_context->params->keep_dims, GetTensorData<int>(temp_index),
GetTensorData<int>(resolved_axis), init_value, reducer));
return kTfLiteOk;
} | 1 | 4,5 | -1 | https://github.com/tensorflow/tensorflow/commit/1970c2158b1ffa416d159d03c3370b9a462aee35 | 0CCPP |
protected void onStart() {
super.onStart();
Intent intent = getIntent();
intent.putExtra(
SettingsActivity.SP_FEED_LIST_LAYOUT,
mPrefs.getString(SettingsActivity.SP_FEED_LIST_LAYOUT, "0")
);
setResult(RESULT_OK,intent);
} | 1 | 2,3,4,5,6,7 | -1 | https://github.com/nextcloud/news-android/commit/05449cb666059af7de2302df9d5c02997a23df85 | 2Java |
struct dentry *kern_path_create(int dfd, const char *pathname,
struct path *path, unsigned int lookup_flags)
{
return filename_create(dfd, getname_kernel(pathname),
path, lookup_flags);
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/397d425dc26da728396e66d392d5dcb8dac30c37 | 0CCPP |
static void hns_gmac_set_rx_auto_pause_frames(void *mac_drv, u32 newval)
{
struct mac_driver *drv = (struct mac_driver *)mac_drv;
dsaf_set_dev_bit(drv, GMAC_PAUSE_EN_REG,
GMAC_PAUSE_EN_RX_FDFC_B, !!newval);
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/412b65d15a7f8a93794653968308fc100f2aa87c | 0CCPP |
def basic_auth_protocol_factory(
realm: str,
credentials: Optional[Union[Credentials, Iterable[Credentials]]] = None,
check_credentials: Optional[Callable[[str, str], Awaitable[bool]]] = None,
create_protocol: Optional[Callable[[Any], BasicAuthWebSocketServerProtocol]] = None,
) -> Callable[[Any], BasicAuthWebSocketServerProtocol]:
if (credentials is None) == (check_credentials is None):
raise TypeError("provide either credentials or check_credentials")
if credentials is not None:
if is_credentials(credentials):
async def check_credentials(
username: str, password: str
) -> bool:
return (username, password) == credentials
elif isinstance(credentials, Iterable):
credentials_list = list(credentials)
if all(
is_credentials(item) for item in credentials_list
):
credentials_dict = dict(credentials_list)
async def check_credentials(
username: str, password: str
) -> bool:
return (
credentials_dict.get(username) == password
)
else:
raise TypeError(f"invalid credentials argument: {credentials}")
else:
raise TypeError(f"invalid credentials argument: {credentials}")
if create_protocol is None:
create_protocol = cast(
Callable[[Any], BasicAuthWebSocketServerProtocol],
BasicAuthWebSocketServerProtocol,
)
return functools.partial(
create_protocol,
realm=realm,
check_credentials=check_credentials,
)
| 1 | 13,14,20,21,25,28,30,42 | -1 | https://github.com/python-websockets/websockets.git/commit/547a26b685d08cac0aa64e5e65f7867ac0ea9bc0 | 4Python |
static int epass2003_decipher(struct sc_card *card, const u8 * data, size_t datalen,
u8 * out, size_t outlen)
{
int r;
struct sc_apdu apdu;
u8 rbuf[SC_MAX_APDU_BUFFER_SIZE] = { 0 };
u8 sbuf[SC_MAX_APDU_BUFFER_SIZE] = { 0 };
epass2003_exdata *exdata = NULL;
LOG_FUNC_CALLED(card->ctx);
if (!card->drv_data)
return SC_ERROR_INVALID_ARGUMENTS;
exdata = (epass2003_exdata *)card->drv_data;
if(exdata->currAlg == SC_ALGORITHM_EC)
{
if(exdata->ecAlgFlags & SC_ALGORITHM_ECDSA_HASH_SHA1)
{
r = hash_data(data, datalen, sbuf, SC_ALGORITHM_ECDSA_HASH_SHA1);
LOG_TEST_RET(card->ctx, r, "hash_data failed");
sc_format_apdu(card, &apdu, SC_APDU_CASE_3,0x2A, 0x9E, 0x9A);
apdu.data = sbuf;
apdu.lc = 0x14;
apdu.datalen = 0x14;
}
else if (exdata->ecAlgFlags & SC_ALGORITHM_ECDSA_HASH_SHA256)
{
r = hash_data(data, datalen, sbuf, SC_ALGORITHM_ECDSA_HASH_SHA256);
LOG_TEST_RET(card->ctx, r, "hash_data failed");
sc_format_apdu(card, &apdu, SC_APDU_CASE_3,0x2A, 0x9E, 0x9A);
apdu.data = sbuf;
apdu.lc = 0x20;
apdu.datalen = 0x20;
}
else
{
return SC_ERROR_NOT_SUPPORTED;
}
apdu.resp = rbuf;
apdu.resplen = sizeof(rbuf);
apdu.le = 0;
r = sc_transmit_apdu_t(card, &apdu);
LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
size_t len = apdu.resplen > outlen ? outlen : apdu.resplen;
memcpy(out, apdu.resp, len);
LOG_FUNC_RETURN(card->ctx, len);
}
LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
}
else if(exdata->currAlg == SC_ALGORITHM_RSA)
{
sc_format_apdu(card, &apdu, SC_APDU_CASE_4_EXT, 0x2A, 0x80, 0x86);
apdu.resp = rbuf;
apdu.resplen = sizeof(rbuf);
apdu.le = 0;
memcpy(sbuf, data, datalen);
apdu.data = sbuf;
apdu.lc = datalen;
apdu.datalen = datalen;
}
else
{
sc_format_apdu(card, &apdu, SC_APDU_CASE_4_EXT, 0x2A, 0x80, 0x86);
apdu.resp = rbuf;
apdu.resplen = sizeof(rbuf);
apdu.le = 256;
memcpy(sbuf, data, datalen);
apdu.data = sbuf;
apdu.lc = datalen;
apdu.datalen = datalen;
}
r = sc_transmit_apdu_t(card, &apdu);
LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
size_t len = apdu.resplen > outlen ? outlen : apdu.resplen;
memcpy(out, apdu.resp, len);
LOG_FUNC_RETURN(card->ctx, len);
}
LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
} | 0 | null | -1 | https://github.com/OpenSC/OpenSC/commit/360e95d45ac4123255a4c796db96337f332160ad | 0CCPP |
TEE_Result syscall_cipher_init(unsigned long state, const void *iv,
size_t iv_len)
{
TEE_Result res;
struct tee_cryp_state *cs;
struct tee_ta_session *sess;
struct tee_obj *o;
struct tee_cryp_obj_secret *key1;
struct user_ta_ctx *utc;
res = tee_ta_get_current_session(&sess);
if (res != TEE_SUCCESS)
return res;
utc = to_user_ta_ctx(sess->ctx);
res = tee_svc_cryp_get_state(sess, tee_svc_uref_to_vaddr(state), &cs);
if (res != TEE_SUCCESS)
return res;
if (TEE_ALG_GET_CLASS(cs->algo) != TEE_OPERATION_CIPHER)
return TEE_ERROR_BAD_STATE;
res = tee_mmu_check_access_rights(utc,
TEE_MEMORY_ACCESS_READ |
TEE_MEMORY_ACCESS_ANY_OWNER,
(uaddr_t) iv, iv_len);
if (res != TEE_SUCCESS)
return res;
res = tee_obj_get(utc, cs->key1, &o);
if (res != TEE_SUCCESS)
return res;
if ((o->info.handleFlags & TEE_HANDLE_FLAG_INITIALIZED) == 0)
return TEE_ERROR_BAD_PARAMETERS;
key1 = o->attr;
if (tee_obj_get(utc, cs->key2, &o) == TEE_SUCCESS) {
struct tee_cryp_obj_secret *key2 = o->attr;
if ((o->info.handleFlags & TEE_HANDLE_FLAG_INITIALIZED) == 0)
return TEE_ERROR_BAD_PARAMETERS;
res = crypto_cipher_init(cs->ctx, cs->algo, cs->mode,
(uint8_t *)(key1 + 1), key1->key_size,
(uint8_t *)(key2 + 1), key2->key_size,
iv, iv_len);
} else {
res = crypto_cipher_init(cs->ctx, cs->algo, cs->mode,
(uint8_t *)(key1 + 1), key1->key_size,
NULL, 0, iv, iv_len);
}
if (res != TEE_SUCCESS)
return res;
cs->ctx_finalize = crypto_cipher_final;
return TEE_SUCCESS;
} | 1 | null | -1 | https://github.com/OP-TEE/optee_os/commit/34a08bec755670ea0490cb53bbc68058cafc69b6 | 0CCPP |
activation_mountable_mounted (NautilusFile *file,
GFile *result_location,
GError *error,
gpointer callback_data)
{
ActivateParameters *parameters = callback_data;
NautilusFile *target_file;
LaunchLocation *location;
parameters->mountables = g_list_remove (parameters->mountables, file);
nautilus_file_unref (file);
if (error == NULL)
{
target_file = nautilus_file_get (result_location);
location = find_launch_location_for_file (parameters->locations,
file);
if (location)
{
launch_location_update_from_file (location, target_file);
}
nautilus_file_unref (target_file);
}
else
{
if (error->domain != G_IO_ERROR ||
(error->code != G_IO_ERROR_FAILED_HANDLED &&
error->code != G_IO_ERROR_ALREADY_MOUNTED))
{
location = find_launch_location_for_file (parameters->locations,
file);
if (location)
{
parameters->locations =
g_list_remove (parameters->locations,
location);
launch_location_free (location);
}
}
if (error->domain != G_IO_ERROR ||
(error->code != G_IO_ERROR_CANCELLED &&
error->code != G_IO_ERROR_FAILED_HANDLED &&
error->code != G_IO_ERROR_ALREADY_MOUNTED))
{
eel_show_error_dialog (_("Unable to access location"),
error->message, parameters->parent_window);
}
if (error->code == G_IO_ERROR_CANCELLED)
{
activation_parameters_free (parameters);
return;
}
}
activation_mount_mountables (parameters);
} | 0 | null | -1 | https://github.com/GNOME/nautilus/commit/1630f53481f445ada0a455e9979236d31a8d3bb0 | 0CCPP |
mg_get_valid_option_names(void)
{
static const char *
data[2 * sizeof(config_options) / sizeof(config_options[0])] = {0};
int i;
for (i = 0; config_options[i].name != NULL; i++) {
data[i * 2] = config_options[i].name;
data[i * 2 + 1] = config_options[i].default_value;
}
return data;
} | 0 | null | -1 | https://github.com/civetweb/civetweb/commit/8fd069f6dedb064339f1091069ac96f3f8bdb552 | 0CCPP |
public void contextInitialized(ServletContextEvent event) {
final ServletContext context = event.getServletContext();
File home=null;
try {
LocaleProvider.setProvider(new LocaleProvider() {
public Locale get() {
return Functions.getCurrentLocale();
}
});
JVM jvm;
try {
jvm = new JVM();
new URLClassLoader(new URL[0],getClass().getClassLoader());
} catch(SecurityException e) {
throw new InsufficientPermissionDetected(e);
}
try {
Security.removeProvider("SunPKCS11-Solaris");
} catch (SecurityException e) {
}
installLogger();
final FileAndDescription describedHomeDir = getHomeDir(event);
home = describedHomeDir.file.getAbsoluteFile();
home.mkdirs();
System.out.println("Jenkins home directory: "+home+" found at: "+describedHomeDir.description);
if (!home.exists())
throw new NoHomeDir(home);
recordBootAttempt(home);
if(jvm.bestReflectionProvider().getClass()==PureJavaReflectionProvider.class) {
throw new IncompatibleVMDetected();
}
try {
ServletResponse.class.getMethod("setCharacterEncoding",String.class);
} catch (NoSuchMethodException e) {
throw new IncompatibleServletVersionDetected(ServletResponse.class);
}
try {
FileSet.class.getMethod("getDirectoryScanner");
} catch (NoSuchMethodException e) {
throw new IncompatibleAntVersionDetected(FileSet.class);
}
if(ChartUtil.awtProblemCause!=null) {
throw new AWTProblem(ChartUtil.awtProblemCause);
}
try {
File f = File.createTempFile("test", "test");
f.delete();
} catch (IOException e) {
throw new NoTempDir(e);
}
try {
TransformerFactory.newInstance();
} catch (TransformerFactoryConfigurationError x) {
LOGGER.log(WARNING, "XSLT not configured correctly. Hudson will try to fix this. See http://issues.apache.org/bugzilla/show_bug.cgi?id=40895 for more details",x);
System.setProperty(TransformerFactory.class.getName(),"com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
try {
TransformerFactory.newInstance();
LOGGER.info("XSLT is set to the JAXP RI in JRE");
} catch(TransformerFactoryConfigurationError y) {
LOGGER.log(SEVERE, "Failed to correct the problem.");
}
}
installExpressionFactory(event);
context.setAttribute(APP,new HudsonIsLoading());
final File _home = home;
initThread = new Thread("Jenkins initialization thread") {
@Override
public void run() {
boolean success = false;
try {
Jenkins instance = new Hudson(_home, context);
context.setAttribute(APP, instance);
BootFailure.getBootFailureFile(_home).delete();
LOGGER.info("Jenkins is fully up and running");
success = true;
} catch (Error e) {
new HudsonFailedToLoad(e).publish(context,_home);
throw e;
} catch (Exception e) {
new HudsonFailedToLoad(e).publish(context,_home);
} finally {
Jenkins instance = Jenkins.getInstance();
if(!success && instance!=null)
instance.cleanUp();
}
}
};
initThread.start();
} catch (BootFailure e) {
e.publish(context,home);
} catch (Error e) {
LOGGER.log(SEVERE, "Failed to initialize Jenkins",e);
throw e;
} catch (RuntimeException e) {
LOGGER.log(SEVERE, "Failed to initialize Jenkins",e);
throw e;
}
} | 1 | null | -1 | https://github.com/jenkinsci/jenkins/commit/582128b9ac179a788d43c1478be8a5224dc19710 | 2Java |
_PyObject_Realloc(void *ctx, void *p, size_t nbytes)
{
void *bp;
poolp pool;
size_t size;
if (p == NULL)
return _PyObject_Alloc(0, ctx, 1, nbytes);
#ifdef WITH_VALGRIND
/* Treat running_on_valgrind == -1 the same as 0 */
if (UNLIKELY(running_on_valgrind > 0))
goto redirect;
#endif
pool = POOL_ADDR(p);
if (address_in_range(p, pool)) {
/* We're in charge of this block */
size = INDEX2SIZE(pool->szidx);
if (nbytes <= size) {
/* The block is staying the same or shrinking. If
* it's shrinking, there's a tradeoff: it costs
* cycles to copy the block to a smaller size class,
* but it wastes memory not to copy it. The
* compromise here is to copy on shrink only if at
* least 25% of size can be shaved off.
*/
if (4 * nbytes > 3 * size) {
/* It's the same,
* or shrinking and new/old > 3/4.
*/
return p;
}
size = nbytes;
}
bp = _PyObject_Alloc(0, ctx, 1, nbytes);
if (bp != NULL) {
memcpy(bp, p, size);
_PyObject_Free(ctx, p);
}
return bp;
}
#ifdef WITH_VALGRIND
redirect:
#endif
/* We're not managing this block. If nbytes <=
* SMALL_REQUEST_THRESHOLD, it's tempting to try to take over this
* block. However, if we do, we need to copy the valid data from
* the C-managed block to one of our blocks, and there's no portable
* way to know how much of the memory space starting at p is valid.
* As bug 1185883 pointed out the hard way, it's possible that the
* C-managed block is "at the end" of allocated VM space, so that
* a memory fault can occur if we try to copy nbytes bytes starting
* at p. Instead we punt: let C continue to manage this block.
*/
if (nbytes)
return PyMem_RawRealloc(p, nbytes);
/* C doesn't define the result of realloc(p, 0) (it may or may not
* return NULL then), but Python's docs promise that nbytes==0 never
* returns NULL. We don't pass 0 to realloc(), to avoid that endcase
* to begin with. Even then, we can't be sure that realloc() won't
* return NULL.
*/
bp = PyMem_RawRealloc(p, 1);
return bp ? bp : p;
} | 1 | 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62 | -1 | https://github.com/python/typed_ast/commit/156afcb26c198e162504a57caddfe0acd9ed7dce | 0CCPP |
static ssize_t _hostfs_read(oe_fd_t* desc, void* buf, size_t count)
{
ssize_t ret = -1;
file_t* file = _cast_file(desc);
if (!file)
OE_RAISE_ERRNO(OE_EINVAL);
if (oe_syscall_read_ocall(&ret, file->host_fd, buf, count) != OE_OK)
OE_RAISE_ERRNO(OE_EINVAL);
done:
return ret;
} | 1 | 4 | -1 | https://github.com/openenclave/openenclave/commit/bcac8e7acb514429fee9e0b5d0c7a0308fd4d76b | 0CCPP |
char const* parse_int(char const* start, char const* end, char delimiter, boost::int64_t& val)
{
while (start < end && *start != delimiter)
{
if (!is_digit(*start)) { return 0; }
val *= 10;
val += *start - '0';
++start;
}
return start;
} | 1 | 0,4,6 | -1 | https://github.com/bittorrent/bootstrap-dht/commit/bbc0b7191e3f48461ca6e5b1b34bdf4b3f1e79a9 | 0CCPP |
static const char *parse_object( cJSON *item, const char *value )
{
cJSON *child;
if ( *value != '{' ) {
/* Not an object! */
ep = value;
return 0;
}
item->type = cJSON_Object;
value =skip( value + 1 );
if ( *value == '}' )
return value + 1; /*
if ( ! ( item->child = child = cJSON_New_Item() ) )
return 0;
if ( ! ( value = skip( parse_string( child, skip( value ) ) ) ) )
return 0;
child->string = child->valuestring;
child->valuestring = 0;
if ( *value != ':' ) {
/* Fail! */
ep = value;
return 0;
}
if ( ! ( value = skip( parse_value( child, skip( value + 1 ) ) ) ) )
return 0;
while ( *value == ',' ) {
cJSON *new_item;
if ( ! ( new_item = cJSON_New_Item() ) )
return 0; /*
child->next = new_item;
new_item->prev = child;
child = new_item;
if ( ! ( value = skip( parse_string( child, skip( value + 1 ) ) ) ) )
return 0;
child->string = child->valuestring;
child->valuestring = 0;
if ( *value != ':' ) {
/* Fail! */
ep = value;
return 0;
}
if ( ! ( value = skip( parse_value( child, skip( value + 1 ) ) ) ) )
return 0;
}
if ( *value == '}' )
return value + 1; /*
/* Malformed. */
ep = value;
return 0;
} | 1 | 0,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,44,45,46,47,48 | -1 | https://github.com/esnet/iperf/commit/91f2fa59e8ed80dfbf400add0164ee0e508e412a | 0CCPP |
int AVI_video_frames(avi_t *AVI)
{
return AVI->video_frames;
} | 0 | null | -1 | https://github.com/gpac/gpac/commit/7f060bbb72966cae80d6fee338d0b07fa3fc06e1 | 0CCPP |
nextId: function(skip, init) {
var id = 'v' + (this.state.nextId++);
if (!skip) {
this.current().vars.push(id + (init ? '=' + init : ''));
}
return id;
}, | 1 | 0,1,2,3,4,5,6 | -1 | https://github.com/peerigon/angular-expressions/commit/061addfb9a9e932a970e5fcb913d020038e65667 | 3JavaScript |
bool chopOffDotted(string &domain)
{
if(domain.empty() || (domain.size()==1 && domain[0]=='.'))
return false;
string::size_type fdot=domain.find('.');
if(fdot == string::npos)
return false;
if(fdot==domain.size()-1)
domain=".";
else {
string::size_type remain = domain.length() - (fdot + 1);
char tmp[remain];
memcpy(tmp, domain.c_str()+fdot+1, remain);
domain.assign(tmp, remain);
}
return true;
} | 1 | 4,5,6,7,8,9,10,11,12,13,15 | -1 | https://github.com/PowerDNS/pdns/commit/881b5b03a590198d03008e4200dd00cc537712f3 | 0CCPP |
window.parent;q="json"==urlParams.proto?JSON.stringify({event:"init"}):urlParams.ready||"ready";v.postMessage(q,"*");if("json"==urlParams.proto){var x=this.editor.graph.openLink;this.editor.graph.openLink=function(A,z,L){x.apply(this,arguments);v.postMessage(JSON.stringify({event:"openLink",href:A,target:z,allowOpener:L}),"*")}}};EditorUi.prototype.addEmbedButtons=function(){if(null!=this.menubar&&"1"!=urlParams.embedInline){var c=document.createElement("div");c.style.display="inline-block";c.style.position= | 1 | 0 | -1 | https://github.com/jgraph/drawio/commit/4deecee18191f67e242422abf3ca304e19e49687 | 3JavaScript |
static enum hrtimer_restart sched_rt_period_timer(struct hrtimer *timer)
{
struct rt_bandwidth *rt_b =
container_of(timer, struct rt_bandwidth, rt_period_timer);
ktime_t now;
int overrun;
int idle = 0;
for (;;) {
now = hrtimer_cb_get_time(timer);
overrun = hrtimer_forward(timer, now, rt_b->rt_period);
if (!overrun)
break;
idle = do_sched_rt_period_timer(rt_b, overrun);
}
return idle ? HRTIMER_NORESTART : HRTIMER_RESTART;
} | 0 | null | -1 | https://github.com/torvalds/linux/commit/f26f9aff6aaf67e9a430d16c266f91b13a5bff64 | 0CCPP |
error_t ipv6AddRoute(const Ipv6Addr *prefix, uint_t prefixLen,
NetInterface *interface, const Ipv6Addr *nextHop, uint_t metric)
{
error_t error;
uint_t i;
Ipv6RoutingTableEntry *entry;
Ipv6RoutingTableEntry *firstFreeEntry;
if(prefix == NULL || interface == NULL)
return ERROR_INVALID_PARAMETER;
firstFreeEntry = NULL;
osAcquireMutex(&netMutex);
for(i = 0; i < IPV6_ROUTING_TABLE_SIZE; i++)
{
entry = &ipv6RoutingTable[i];
if(entry->valid)
{
if(entry->prefixLen == prefixLen)
{
if(ipv6CompPrefix(&entry->prefix, prefix, prefixLen))
break;
}
}
else
{
if(firstFreeEntry == NULL)
firstFreeEntry = entry;
}
}
if(i >= IPV6_ROUTING_TABLE_SIZE)
entry = firstFreeEntry;
if(entry != NULL)
{
entry->prefix = *prefix;
entry->prefixLen = prefixLen;
entry->interface = interface;
if(nextHop != NULL)
entry->nextHop = *nextHop;
else
entry->nextHop = IPV6_UNSPECIFIED_ADDR;
entry->metric = metric;
entry->valid = TRUE;
//Sucessful processing
error = NO_ERROR;
}
else
{
error = ERROR_FAILURE;
}
osReleaseMutex(&netMutex);
return error;
} | 1 | 41 | -1 | https://github.com/Oryx-Embedded/CycloneTCP/commit/de5336016edbe1e90327d0ed1cba5c4e49114366 | 0CCPP |
WRITE_JSON_ELEMENT(ObjEnd) {
ctx->depth--;
ctx->commaNeeded[ctx->depth] = true;
return writeChar(ctx, '}');
} | 0 | null | -1 | https://github.com/open62541/open62541/commit/c800e2987b10bb3af6ef644b515b5d6392f8861d | 0CCPP |
user: function (done) {
UserSchema.getUserByUsername(username, function (err, user) {
if (err) return done(err)
if (!user) return done('Invalid User Object')
obj._id = user._id
if (
!_.isUndefined(obj.password) &&
!_.isEmpty(obj.password) &&
!_.isUndefined(obj.passconfirm) &&
!_.isEmpty(obj.passconfirm)
) {
if (obj.password === obj.passconfirm) {
if (passwordComplexityEnabled) {
const passwordComplexity = require('../../../settings/passwordComplexity')
if (!passwordComplexity.validate(obj.password)) return done('Password does not meet requirements')
}
user.password = obj.password
passwordUpdated = true
}
}
if (!_.isUndefined(obj.fullname) && obj.fullname.length > 0) user.fullname = obj.fullname
if (!_.isUndefined(obj.email) && obj.email.length > 0) user.email = obj.email
if (!_.isUndefined(obj.title) && obj.title.length > 0) user.title = obj.title
if (!_.isUndefined(obj.role) && obj.role.length > 0) user.role = obj.role
user.save(function (err, nUser) {
if (err) return done(err)
nUser.populate('role', function (err, populatedUser) {
if (err) return done(err)
const resUser = stripUserFields(populatedUser)
return done(null, resUser)
})
})
})
}, | 1 | null | -1 | https://github.com/polonel/trudesk/commit/83fd5a89319ba2c2f5934722e39b08aba9b3a4ac | 3JavaScript |
static void sqliteViewResetAll(sqlite3 *db, int idx){
HashElem *i;
assert( sqlite3SchemaMutexHeld(db, idx, 0) );
if( !DbHasProperty(db, idx, DB_UnresetViews) ) return;
for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){
Table *pTab = sqliteHashData(i);
if( pTab->pSelect ){
sqlite3DeleteColumnNames(db, pTab);
pTab->aCol = 0;
pTab->nCol = 0;
}
}
DbClearProperty(db, idx, DB_UnresetViews);
} | 0 | null | -1 | https://github.com/sqlite/sqlite/commit/38096961c7cd109110ac21d3ed7dad7e0cb0ae06 | 0CCPP |
this.useCanvasForExport||".png"!=z||(z=".drawio"),".svg"===z||".xml"===z||".html"===z||".png"===z||".drawio"===z)&&(x=A+z)}v=new LocalFile(this,v,null!=urlParams.title?decodeURIComponent(urlParams.title):x,!0);v.getHash=function(){return b};this.fileLoaded(v,!0)?null!=d&&d():m()||this.handleError({message:mxResources.get("fileNotFound")},mxResources.get("errorLoadingFile"))}else m()||this.handleError({message:mxResources.get("fileNotFound")},mxResources.get("errorLoadingFile"))}),mxUtils.bind(this, | 1 | 0 | -1 | https://github.com/jgraph/drawio/commit/4deecee18191f67e242422abf3ca304e19e49687 | 3JavaScript |
$.fn.elfinderpath = function(fm) {
return this.each(function() {
var path = $(this).addClass('elfinder-path').html(' ')
.delegate('a', 'click', function(e) {
var hash = $(this).attr('href').substr(1);
e.preventDefault();
hash != fm.cwd().hash && fm.exec('open', hash);
})
.prependTo(fm.getUI('statusbar').show())
fm.bind('open searchend', function() {
var dirs = [];
$.each(fm.parents(fm.cwd().hash), function(i, hash) {
dirs.push('<a href="#'+hash+'">'+fm.escape(fm.file(hash).name)+'</a>');
});
path.html(dirs.join(fm.option('separator')));
})
.bind('search', function() {
path.html(fm.i18n('searcresult'));
});
});
} | 1 | 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 | -1 | https://github.com/semplon/GeniXCMS/commit/d885eb20006099262c0278932b9f8aca3c1ac97f | 3JavaScript |
static const char *req_canonical_filename_field(request_rec *r)
{
return r->canonical_filename;
} | 0 | null | -1 | https://github.com/apache/httpd/commit/78eb3b9235515652ed141353d98c239237030410 | 0CCPP |
function factory(options) {
options = options || {}
var objectPath = function(obj) {
return Object.keys(objectPath).reduce(function(proxy, prop) {
if(prop === 'create') {
return proxy;
}
if (typeof objectPath[prop] === 'function') {
proxy[prop] = objectPath[prop].bind(objectPath, obj);
}
return proxy;
}, {});
};
var hasShallowProperty
if (options.includeInheritedProps) {
hasShallowProperty = function () {
return true
}
} else {
hasShallowProperty = function (obj, prop) {
return (typeof prop === 'number' && Array.isArray(obj)) || hasOwnProperty(obj, prop)
}
}
function getShallowProperty(obj, prop) {
if (hasShallowProperty(obj, prop)) {
return obj[prop];
}
}
function set(obj, path, value, doNotReplace){
if (typeof path === 'number') {
path = [path];
}
if (!path || path.length === 0) {
return obj;
}
if (typeof path === 'string') {
return set(obj, path.split('.').map(getKey), value, doNotReplace);
}
var currentPath = path[0];
var currentValue = getShallowProperty(obj, currentPath);
if (path.length === 1) {
if (currentValue === void 0 || !doNotReplace) {
obj[currentPath] = value;
}
return currentValue;
}
if (currentValue === void 0) {
if(typeof path[1] === 'number') {
obj[currentPath] = [];
} else {
obj[currentPath] = {};
}
}
return set(obj[currentPath], path.slice(1), value, doNotReplace);
}
objectPath.has = function (obj, path) {
if (typeof path === 'number') {
path = [path];
} else if (typeof path === 'string') {
path = path.split('.');
}
if (!path || path.length === 0) {
return !!obj;
}
for (var i = 0; i < path.length; i++) {
var j = getKey(path[i]);
if((typeof j === 'number' && isArray(obj) && j < obj.length) ||
(options.includeInheritedProps ? (j in Object(obj)) : hasOwnProperty(obj, j))) {
obj = obj[j];
} else {
return false;
}
}
return true;
};
objectPath.ensureExists = function (obj, path, value){
return set(obj, path, value, true);
};
objectPath.set = function (obj, path, value, doNotReplace){
return set(obj, path, value, doNotReplace);
};
objectPath.insert = function (obj, path, value, at){
var arr = objectPath.get(obj, path);
at = ~~at;
if (!isArray(arr)) {
arr = [];
objectPath.set(obj, path, arr);
}
arr.splice(at, 0, value);
};
objectPath.empty = function(obj, path) {
if (isEmpty(path)) {
return void 0;
}
if (obj == null) {
return void 0;
}
var value, i;
if (!(value = objectPath.get(obj, path))) {
return void 0;
}
if (typeof value === 'string') {
return objectPath.set(obj, path, '');
} else if (isBoolean(value)) {
return objectPath.set(obj, path, false);
} else if (typeof value === 'number') {
return objectPath.set(obj, path, 0);
} else if (isArray(value)) {
value.length = 0;
} else if (isObject(value)) {
for (i in value) {
if (hasShallowProperty(value, i)) {
delete value[i];
}
}
} else {
return objectPath.set(obj, path, null);
}
};
objectPath.push = function (obj, path ){
var arr = objectPath.get(obj, path);
if (!isArray(arr)) {
arr = [];
objectPath.set(obj, path, arr);
}
arr.push.apply(arr, Array.prototype.slice.call(arguments, 2));
};
objectPath.coalesce = function (obj, paths, defaultValue) {
var value;
for (var i = 0, len = paths.length; i < len; i++) {
if ((value = objectPath.get(obj, paths[i])) !== void 0) {
return value;
}
}
return defaultValue;
};
objectPath.get = function (obj, path, defaultValue){
if (typeof path === 'number') {
path = [path];
}
if (!path || path.length === 0) {
return obj;
}
if (obj == null) {
return defaultValue;
}
if (typeof path === 'string') {
return objectPath.get(obj, path.split('.'), defaultValue);
}
var currentPath = getKey(path[0]);
var nextObj = getShallowProperty(obj, currentPath)
if (nextObj === void 0) {
return defaultValue;
}
if (path.length === 1) {
return nextObj;
}
return objectPath.get(obj[currentPath], path.slice(1), defaultValue);
};
objectPath.del = function del(obj, path) {
if (typeof path === 'number') {
path = [path];
}
if (obj == null) {
return obj;
}
if (isEmpty(path)) {
return obj;
}
if(typeof path === 'string') {
return objectPath.del(obj, path.split('.'));
}
var currentPath = getKey(path[0]);
if (!hasShallowProperty(obj, currentPath)) {
return obj;
}
if(path.length === 1) {
if (isArray(obj)) {
obj.splice(currentPath, 1);
} else {
delete obj[currentPath];
}
} else {
return objectPath.del(obj[currentPath], path.slice(1));
}
return obj;
}
return objectPath;
} | 1 | null | -1 | https://github.com/mariocasciaro/object-path/commit/2be3354c6c46215c7635eb1b76d80f1319403c68 | 3JavaScript |
static void FVMenuDetachAndRemoveGlyphs(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) {
FontView *fv = (FontView *) GDrawGetUserData(gw);
char *buts[3];
buts[0] = _("_Remove");
buts[1] = _("_Cancel");
buts[2] = NULL;
if ( gwwv_ask(_("Detach & Remove Glyphs"),(const char **) buts,0,1,_("Are you sure you wish to remove these glyphs? This operation cannot be undone."))==1 )
return;
FVDetachAndRemoveGlyphs((FontViewBase *) fv);
} | 0 | null | -1 | https://github.com/fontforge/fontforge/commit/626f751752875a0ddd74b9e217b6f4828713573c | 0CCPP |
get_html_data (MAPI_Attr *a)
{
VarLenData **body = XCALLOC(VarLenData*, a->num_values + 1);
int j;
for (j = 0; j < a->num_values; j++)
{
body[j] = XMALLOC(VarLenData, 1);
body[j]->len = a->values[j].len;
body[j]->data = CHECKED_XCALLOC(unsigned char, a->values[j].len);
memmove (body[j]->data, a->values[j].data.buf, body[j]->len);
}
return body;
} | 1 | 6,7,8,9 | -1 | https://github.com/verdammelt/tnef/commit/8dccf79857ceeb7a6d3e42c1e762e7b865d5344d | 0CCPP |
accept = function() {
if (replied)
return;
replied = true;
stream.channelOpenConfirm(info.sender,
localChan,
Channel.MAX_WINDOW,
Channel.PACKET_SIZE);
return new Session(self, info, localChan);
}; | 1 | 0,1,2,3,4,5,6,7,8,9 | -1 | https://github.com/mscdex/ssh2/commit/f763271f41320e71d5cbee02ea5bc6a2ded3ca21 | 3JavaScript |
void ACLosslessScan::ParseMCU(struct Line **prev,struct Line **top)
{
#if ACCUSOFT_CODE
UBYTE c;
for(c = 0;c < m_ucCount;c++) {
struct QMContextSet &contextset = m_Context[m_ucContext[c]];
struct Line *line = top[c];
struct Line *pline= prev[c];
UBYTE ym = m_ucMCUHeight[c];
ULONG x = m_ulX[c];
class PredictorBase *mcupred = m_pPredict[c];
LONG *lp = line->m_pData + x;
LONG *pp = (pline)?(pline->m_pData + x):(NULL);
do {
class PredictorBase *pred = mcupred;
UBYTE xm = m_ucMCUWidth[c];
do {
LONG v;
struct QMContextSet::ContextZeroSet &zset = contextset.ClassifySignZero(m_plDa[c][ym-1],m_plDb[c][x],
m_ucSmall[c],m_ucLarge[c]);
if (m_Coder.Get(zset.S0)) {
LONG sz = 0;
bool sign = m_Coder.Get(zset.SS);
if (m_Coder.Get((sign)?(zset.SN):(zset.SP))) {
struct QMContextSet::MagnitudeSet &mset = contextset.ClassifyMagnitude(m_plDb[c][x],m_ucLarge[c]);
int i = 0;
LONG m = 2;
while(m_Coder.Get(mset.X[i])) {
m <<= 1;
i++;
}
m >>= 1;
sz = m;
while((m >>= 1)) {
if (m_Coder.Get(mset.M[i])) {
sz |= m;
}
}
}
if (sign) {
v = -sz - 1;
} else {
v = sz + 1;
}
} else {
v = 0;
}
lp[0] = pred->DecodeSample(v,lp,pp);
m_plDb[c][x] = v;
m_plDa[c][ym-1] = v;
} while(--xm && (lp++,pp++,x++,pred = pred->MoveRight(),true));
} while(--ym && (pp = line->m_pData + (x = m_ulX[c]),line = (line->m_pNext)?(line->m_pNext):(line),
lp = line->m_pData + x,mcupred = mcupred->MoveDown(),true));
}
#else
NOREF(prev);
NOREF(top);
#endif
} | 1 | 29 | -1 | https://github.com/thorfdbg/libjpeg/commit/ef4a29a62ab48b8dc235f4af52cfd6319eda9a6a | 0CCPP |
exif_mnote_data_canon_free (ExifMnoteData *n)
{
if (!n) return;
exif_mnote_data_canon_clear ((ExifMnoteDataCanon *) n);
} | 0 | null | -1 | https://github.com/libexif/libexif/commit/ec412aa4583ad71ecabb967d3c77162760169d1f | 0CCPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.