problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
{
VirtualConsole *vc = opaque;
GtkDisplayState *s = vc->s;
int gdk_keycode = key->hardware_keycode;
int qemu_keycode;
int i;
if (key->keyval == GDK_KEY_Pause) {
qemu_input_event_send_key_qcode(vc->gfx.dcl.con, Q_KEY_CODE_PAUSE,
key->type == GDK_KEY_PRESS);
qemu_keycode = gd_map_keycode(s, gtk_widget_get_display(widget),
gdk_keycode);
trace_gd_key_event(vc->label, gdk_keycode, qemu_keycode,
(key->type == GDK_KEY_PRESS) ? "down" : "up");
for (i = 0; i < ARRAY_SIZE(modifier_keycode); i++) {
if (qemu_keycode == modifier_keycode[i]) {
s->modifier_pressed[i] = (key->type == GDK_KEY_PRESS);
qemu_input_event_send_key_number(vc->gfx.dcl.con, qemu_keycode,
key->type == GDK_KEY_PRESS); | 1threat |
static int cmd_valid_while_locked(SDState *sd, SDRequest *req)
{
if (sd->card_status & APP_CMD) {
return req->cmd == 41 || req->cmd == 42;
}
if (req->cmd == 16 || req->cmd == 55) {
return 1;
}
return sd_cmd_class[req->cmd] == 0 || sd_cmd_class[req->cmd] == 7;
}
| 1threat |
C# Proceed If File Doesn't Exist : I have the following code:
public static void readtext(string pathtoText){
if(File.Exists(pathtoText))
{
string[] lines = System.IO.File.ReadAllLines(pathtoText);
// Display the file contents by using a foreach loop.
foreach (string line in lines)
{
clearPath(line);
}
}
else{
Console.WriteLine("{0} doesn't exist, or isn't a valid text file");
}
}
My function reads directories from a text file and passes it to clearPath which checks if the directory exists, and if so, cleans it. My problem is that, if a directory doesn't exist, it stops the program.
How do I get it to the next directory even if specific directory doesn't exist? | 0debug |
check postgres replication status : <p>Can someone suggest the steps to check pgsql replication status and when to say replication is not happening properly?</p>
<p>We use streaming replication with pgsql9.0 and pgsql9.4 </p>
<p>Thanks.</p>
| 0debug |
how come small dataset in dataset has high variance? : Why small dataset has a high variance? Out professor once said it. I just did not understand it. Any help would be greatly appreciated.
Thanks in advance. | 0debug |
String was not recognized as a valid DateTime. : string date1="06/06/2017";
string date2="06/05/2017";
The dates are in format "mm/dd/yyyy".I need to compare two dates
string test = DateTime.ParseExact(date1, "DD/M/yyyy", CultureInfo.InvariantCulture);
iam unable to find out why Iam getting error like String was not recognized as a valid DateTime. | 0debug |
asp net mvc dropdownlist get selected item in controller : i wante to get selected item from dropdownlist in controller
Here is my code
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.DropDownListFor(model => model.td_company_name, ViewBag.Listcompany as IEnumerable<SelectListItem>, new { @class = "form-control" })
} | 0debug |
static void qvirtio_pci_virtqueue_kick(QVirtioDevice *d, QVirtQueue *vq)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
qpci_io_writew(dev->pdev, dev->addr + VIRTIO_PCI_QUEUE_NOTIFY, vq->index);
}
| 1threat |
Elasticsearch.net - Range Query : <p>I'm trying to query an Elasticsearch index from C# via <a href="https://github.com/elastic/elasticsearch-net" rel="noreferrer">Elasticsearch.net</a> (not NEST). Specifically, I need to get all documents with a status of "success" that have been created since a specific date. In an attempt to do this, I have:</p>
<pre><code>var query = new {
query = new {
match = new {
field="status",
query="success"
}
},
range = new {
?
}
};
</code></pre>
<p>I'm not sure what to use for the <code>range</code> part. In fact, I'm not even sure if my syntax for the <code>query</code> is correct. I don't really understand how the C# syntax maps to the Query DSL in Elasticsearch. Any help is appreciated.</p>
<p>Thank you!</p>
| 0debug |
Google Login Failed, Failed to open stream Http request failed and Bad Request. : **How to change file_get_contents() to curl funtion**
Error occured in this below lines like .
Fatal error: Uncaught exception 'Exception' with message 'Required option not passed: access_token ' in E:\xampp\htdocs\google\application\libraries\oauth2\Token\Access.php:44 Stack trace: #0 E:\xampp\htdocs\google\application\libraries\oauth2\Token.php(30): OAuth2_Token_Access->__construct(NULL) #1 E:\xampp\htdocs\google\application\libraries\oauth2\Provider.php(224): OAuth2_Token::factory('access', NULL) #2 E:\xampp\htdocs\google\application\libraries\oauth2\Provider\Google.php(61): OAuth2_Provider->access('4/tJi51U-xhCSYo...', Array) #3 E:\xampp\htdocs\google\application\controllers\auth_oa2.php(32): OAuth2_Provider_Google->access('4/tJi51U-xhCSYo...') #4 [internal function]: Auth_oa2->session('google') ...
$opts = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => http_build_query($params),
)
);
$_default_opts = stream_context_get_params(stream_context_get_default());
$context = stream_context_create(array_merge_recursive($_default_opts['options'], $opts));
$response = file_get_contents($url, false, $context);
$return = json_decode($response, true);
| 0debug |
static int http_server(struct sockaddr_in my_addr)
{
int server_fd, tmp, ret;
struct sockaddr_in from_addr;
struct pollfd poll_table[HTTP_MAX_CONNECTIONS + 1], *poll_entry;
HTTPContext *c, **cp;
long cur_time;
server_fd = socket(AF_INET,SOCK_STREAM,0);
if (server_fd < 0) {
perror ("socket");
return -1;
}
tmp = 1;
setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp));
if (bind (server_fd, (struct sockaddr *) &my_addr, sizeof (my_addr)) < 0) {
perror ("bind");
close(server_fd);
return -1;
}
if (listen (server_fd, 5) < 0) {
perror ("listen");
close(server_fd);
return -1;
}
http_log("ffserver started.\n");
start_children(first_feed);
fcntl(server_fd, F_SETFL, O_NONBLOCK);
first_http_ctx = NULL;
nb_connections = 0;
first_http_ctx = NULL;
for(;;) {
poll_entry = poll_table;
poll_entry->fd = server_fd;
poll_entry->events = POLLIN;
poll_entry++;
c = first_http_ctx;
while (c != NULL) {
int fd;
fd = c->fd;
switch(c->state) {
case HTTPSTATE_WAIT_REQUEST:
c->poll_entry = poll_entry;
poll_entry->fd = fd;
poll_entry->events = POLLIN;
poll_entry++;
break;
case HTTPSTATE_SEND_HEADER:
case HTTPSTATE_SEND_DATA_HEADER:
case HTTPSTATE_SEND_DATA:
case HTTPSTATE_SEND_DATA_TRAILER:
c->poll_entry = poll_entry;
poll_entry->fd = fd;
poll_entry->events = POLLOUT;
poll_entry++;
break;
case HTTPSTATE_RECEIVE_DATA:
c->poll_entry = poll_entry;
poll_entry->fd = fd;
poll_entry->events = POLLIN;
poll_entry++;
break;
case HTTPSTATE_WAIT_FEED:
c->poll_entry = poll_entry;
poll_entry->fd = fd;
poll_entry->events = POLLIN;
poll_entry++;
break;
default:
c->poll_entry = NULL;
break;
}
c = c->next;
}
do {
ret = poll(poll_table, poll_entry - poll_table, 1000);
} while (ret == -1);
cur_time = gettime_ms();
cp = &first_http_ctx;
while ((*cp) != NULL) {
c = *cp;
if (handle_http (c, cur_time) < 0) {
log_connection(c);
close(c->fd);
if (c->fmt_in)
av_close_input_file(c->fmt_in);
*cp = c->next;
nb_bandwidth -= c->bandwidth;
av_free(c->buffer);
av_free(c->pbuffer);
av_free(c);
nb_connections--;
} else {
cp = &c->next;
}
}
poll_entry = poll_table;
if (poll_entry->revents & POLLIN) {
int fd, len;
len = sizeof(from_addr);
fd = accept(server_fd, (struct sockaddr *)&from_addr,
&len);
if (fd >= 0) {
fcntl(fd, F_SETFL, O_NONBLOCK);
if (nb_connections >= nb_max_connections) {
c = NULL;
} else {
c = av_mallocz(sizeof(HTTPContext));
if (c) {
c->next = first_http_ctx;
first_http_ctx = c;
c->fd = fd;
c->poll_entry = NULL;
c->from_addr = from_addr;
c->state = HTTPSTATE_WAIT_REQUEST;
c->buffer = av_malloc(c->buffer_size = IOBUFFER_INIT_SIZE);
c->pbuffer = av_malloc(c->pbuffer_size = PBUFFER_INIT_SIZE);
if (!c->buffer || !c->pbuffer) {
av_free(c->buffer);
av_free(c->pbuffer);
av_freep(&c);
} else {
c->buffer_ptr = c->buffer;
c->buffer_end = c->buffer + c->buffer_size;
c->timeout = cur_time + REQUEST_TIMEOUT;
c->start_time = cur_time;
nb_connections++;
}
}
}
if (!c) {
close(fd);
}
}
}
poll_entry++;
}
}
| 1threat |
can you help me to make like this navbare : [enter image description here][1]
[1]: https://i.stack.imgur.com/UJzl6.jpg
hello ca you help me to make like this navbar .. actually i make on but it's not good , it's working with just one width , and if i a change the width lettel it ust doen't work good`<nav>
<ul class="beg-container"> <!-- beg-->
<li> <!-- insusfful-->
<ul class="left-container"><!-- left-->
<li class="protectionn" style="width: 276px; border-right: 1px solid lightgray;"><a href="#"><img src="images/protection.png" width="20px;">payment protection program</a></li>
<li style="width: 119px; border-right: 1px solid lightgray; "><a href="#">how we work</a></li>
<li class="televesionn" style=" padding-left: 10px"><a href="#"><img src="images/televesion.png" width="20px"> watch our latest film</a></li>
</ul>
</li>
<li> <!-- insusfful-->
<ul class="right-container"><!-- right -->
<li><a href="#">post buy requirement</a></li>
<li style="width: 150px; border-left: 1px solid lightgray;" style="width: 276"><a href="#">dowload app</a></li>
<li style="width: 50px; border-left: 1px solid lightgray;"><a href="#">help</a></li>
<li style="width: 175px; border-left: 1px solid lightgray;"><a href="#">+9196969696</a></li>
</ul>
</li>
</ul>
</nav> <!-- end of navbar -->` | 0debug |
Html Calculator input trigger result : I have a very simple html calculator. I want when i type into the input for example `2+2` and press enter key to get result in the same field.
<div id="calculator">
<div id='calc-contain'>
<form name="calculator">
<input id='result' type="text" name="answer" />
<br>
<input type="button" value=" 1 " onclick="calculator.answer.value += '1'" />
<input type="button" value=" 2 " onclick="calculator.answer.value += '2'" />
<input type="button" value=" 3 " onclick="calculator.answer.value += '3'" />
<br/>
<input type="button" value=" 4 " onclick="calculator.answer.value += '4'" />
<input type="button" value=" 5 " onclick="calculator.answer.value += '5'" />
<input type="button" value=" 6 " onclick="calculator.answer.value += '6'" />
</br>
<input type="button" value=" 7 " onclick="calculator.answer.value += '7'" />
<input type="button" value=" 8 " onclick="calculator.answer.value += '8'" />
<input type="button" value=" 9 " onclick="calculator.answer.value += '9'" />
</br>
<input type="button" value=" x " onclick="calculator.answer.value += '*'" />
<input type="button" value=" c " onclick="calculator.answer.value = ''" />
<input type="button" value=" 0 " onclick="calculator.answer.value += '0'" />
<input type="button" value=" / " onclick="calculator.answer.value += '/'" />
<input type="button" value=" + " onclick="calculator.answer.value += '+'" />
<input type="button" value=" - " onclick="calculator.answer.value += '-'" />
</br>
<input style='width:97%;' type="button" value=" = " onclick="calculator.answer.value = eval(calculator.answer.value)" />
</form>
</div>
</div> | 0debug |
static void css_init(void)
{
QTAILQ_INIT(&channel_subsys.pending_crws);
channel_subsys.sei_pending = false;
channel_subsys.do_crw_mchk = true;
channel_subsys.crws_lost = false;
channel_subsys.chnmon_active = false;
QTAILQ_INIT(&channel_subsys.io_adapters);
QTAILQ_INIT(&channel_subsys.indicator_addresses);
}
| 1threat |
Creating a access db from a template DELPHI : i have an access db template. i want to copy that template and rename table1 in the template as table1 already contains certain fields
Also is there any way to copy table1 and create a table2, rename it and keep the fields in table1.
Any way to do this in Delphi
Thanks | 0debug |
Merge two or more []map[string]interface{} types into one in Golang : <p>I'm using Golang and for some reason, I need to merge results from different database queries, all of which return me a <code>[]map[string]interface{}</code>
I'm thinking of Append but its just not clear enough if this is even possible.
What is the final datatype I'm looking at?</p>
<p>Clearly, an array of maps of interfaces with keys as strings should be able to simply 'attach' (concat, if you may) to another array of maps of interfaces with keys as strings!</p>
<p>So what is the mechanism to achieve this?</p>
| 0debug |
ipython - "cannot import name 'create_prompt_application' from 'prompt_toolkit.shortcuts' : <p>I'm trying to get ipython working on my windows 10 64 bit computer. When I try to start ipython from the command line, I get the error pictured in the screenshot attached to this question. </p>
<p>Has anyone encountered this? How I might I fix this problem? </p>
<p><a href="https://i.stack.imgur.com/nSgSW.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/nSgSW.jpg" alt="Ipython Error"></a></p>
| 0debug |
c atoi() function not working : <p>Here is my code. The statement, int value=atoi(ptr[index]) in findMin() function ,gives an error as shown in screenshot. </p>
<p><a href="https://i.stack.imgur.com/drRaB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/drRaB.png" alt="enter image description here"></a></p>
<p>The strange thing is that when I use the same atoi() function in main, everything works pretty fine but it screams in findMin!</p>
<pre><code>CODE:
void* findMin(void *param);
int main(int argc, char *argv[])
{
pthread_t t2; //for min
num=argc;
/*int index=1; THIS WORKS
int value=atoi(argv[index]);*/
//creating worker thread
pthread_create(&t1,NULL,findMin,argv);
pthread_join(t2,NULL); //wait for min
printf("The minimum value is %d\n",min);
return 0;
}
void* findMin(void *param)
{
char *ptr=(char *) param; //casting
int index=1;
min=ptr[1];
for(index; index<num; index++)
{
int value=atoi(ptr[index]); //THIS SCREAMS LIKE HELL!
if(comp<min) min=value;
}
}
</code></pre>
| 0debug |
How are large codebase for a large software written? : <p>i was trying to solve some bugs (easyhacks) for libreoffice , but i had problem understanding the code . It may be because of the way i have learnt programming and never working with a large codebase before.<br>
Below is how coding looks in my textbook and school..<br></p>
<pre><code>#include<header1>
#include<header2>
using some namespace
class MyClass1{
.....
.....
};
class MyClass2 : public MyClass1{
.....
.....
};
int main() //entry point
{
int a , b ;
string str ; //use basic data types
MyClass1 Ca
.....
.....
}
</code></pre>
<p>This is roughly what programs look like even if something complex is to be learnt.<br>
Now the bug i was looking at had specific code pointers to it , so i looked into it , this is how it looked like to me</p>
<pre><code>//mediaItem.hxx --> represents embedded media object
#include<several_headers.hxx>
class RANDOM_MACRO MediaItem : public SomeOtherClass{
public :
const sal_uint& some_var ;
const OUString& some_str ; \\never before seen data types
virtual void someFoo ;
Virtual OUString getURL() ; \\function i am supposed to look into
private :
struct Impl ;
...
};
</code></pre>
<p>and then there is a .cxx file defining the functions. <br>
so i have a few questions</p>
<ol>
<li>Why aren't basic data types like int , string ever used in writing such programs?</li>
<li>Where is the entry point for such large programs , i.e there is always a main() when i write a program. </li>
<li>What are terms like pImpl , Impl that i frequently come across inside classes .
<br></li>
</ol>
<p>P.S. perhaps this should be a seperate question , but people have advised me to understand large codebases using debugger , now again i have used debugger before to understand small programs but i dont understand how i can use it over here especially without knowing an entry point . Thank you.... </p>
| 0debug |
static SocketAddress *nbd_build_socket_address(const char *sockpath,
const char *bindto,
const char *port)
{
SocketAddress *saddr;
saddr = g_new0(SocketAddress, 1);
if (sockpath) {
saddr->type = SOCKET_ADDRESS_KIND_UNIX;
saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
saddr->u.q_unix.data->path = g_strdup(sockpath);
} else {
InetSocketAddress *inet;
saddr->type = SOCKET_ADDRESS_KIND_INET;
inet = saddr->u.inet.data = g_new0(InetSocketAddress, 1);
inet->host = g_strdup(bindto);
if (port) {
inet->port = g_strdup(port);
} else {
inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT);
}
}
return saddr;
}
| 1threat |
Python from django.contrib.auth.views import logout ImportError: cannot import name 'logout' : <p>I have configured my python env with python 3.5, but I am getting the following error when I run my server with the command <code>python manage.py runserver</code></p>
<pre><code>from django.contrib.auth.views import logout
ImportError: cannot import name 'logout'
</code></pre>
<p>this is my config</p>
<pre><code>dj-database-url==0.5.0
Django==2.1a.1
gunicorn==19.8.1
numpy==1.14.3
psycopg2==2.7.4
pytz==2018.4
whitenoise==4.0b4
</code></pre>
<p>I tried reinstalling my env and changing python version but issue stills happening.</p>
<p>Thanks for your questions guys</p>
| 0debug |
How to Hide API_KEY in browzer's Source Code? : Can anyone help me? Suppose i'm sending **API_KEY** from Server to Client Side and at client side i'm using JavaScript/jquery. How can i protect my API_KEY so that no one can see this API_KEY by "Right Click-> View Page Source" in js Part. | 0debug |
static void encode_header(SnowContext *s){
int plane_index, level, orientation;
put_cabac(&s->c, s->header_state, s->keyframe);
if(s->keyframe){
put_symbol(&s->c, s->header_state, s->version, 0);
put_symbol(&s->c, s->header_state, s->temporal_decomposition_type, 0);
put_symbol(&s->c, s->header_state, s->temporal_decomposition_count, 0);
put_symbol(&s->c, s->header_state, s->spatial_decomposition_count, 0);
put_symbol(&s->c, s->header_state, s->colorspace_type, 0);
put_symbol(&s->c, s->header_state, s->b_width, 0);
put_symbol(&s->c, s->header_state, s->b_height, 0);
put_symbol(&s->c, s->header_state, s->chroma_h_shift, 0);
put_symbol(&s->c, s->header_state, s->chroma_v_shift, 0);
put_cabac(&s->c, s->header_state, s->spatial_scalability);
for(plane_index=0; plane_index<2; plane_index++){
for(level=0; level<s->spatial_decomposition_count; level++){
for(orientation=level ? 1:0; orientation<4; orientation++){
if(orientation==2) continue;
put_symbol(&s->c, s->header_state, s->plane[plane_index].band[level][orientation].qlog, 1);
}
}
}
}
put_symbol(&s->c, s->header_state, s->spatial_decomposition_type, 0);
put_symbol(&s->c, s->header_state, s->qlog, 1);
put_symbol(&s->c, s->header_state, s->mv_scale, 0);
put_symbol(&s->c, s->header_state, s->qbias, 1);
}
| 1threat |
Jackson deserialize JSON with timestamp field : <p>I have such string:</p>
<pre><code>{
"debug":"false",
"switchTime":"2017-04-12 17:04:42.896026"
}
</code></pre>
<p>I'm trying to get object in such approach:</p>
<pre><code>new ObjectMapper().readValue(string, MyObject.class);
</code></pre>
<p>And MyObject class:</p>
<pre><code>class MyObject {
private Boolean debug;
private Timestamp switchTime;
//...getters, setters, constructors
}
</code></pre>
<p>I have such exception:</p>
<pre><code>com.fasterxml.jackson.databind.exc.InvalidFormatException:
Can not deserialize value of type java.sql.Timestamp from String
"2017-04-12 17:04:42.896026": not a valid representation (error:
Failed to parse Date value '2017-04-12 17:04:42.896026':
Can not parse date "2017-04-12 17:04:42.896026Z": while it seems
to fit format 'yyyy-MM-dd'T'HH:mm:ss.SSS'Z'',
parsing fails (leniency? null)) at [Source:
{"debug":"false", "switchTime":"2017-04-12 17:04:42.896026"};
</code></pre>
<p>I don't understand why...If i use in debug mode Timestamp.valueOf() with "2017-04-12 17:04:42.896026" - i have success</p>
| 0debug |
How to this box in C? : %@@@%
%...%
%...%
%...%
%@@@%
Where is my mistake pls let me know i am beginner i just started programing. I would apreciate your help
#include<stdio.h>
int main(){
int i,j,num;
scanf("%d", &num);
for(i=0;i<num;i++){
for(j=0;j<num;j++){
if((i==0)||(i==num-1)){
printf("@");
}
else if((j==i-1)||(j==num-1)){
printf("%");
}
else
printf(".");
}
printf("\n");
}
}
| 0debug |
I have a dobut about VBA - EXCEL : Firstly, Good afternoon to all
I have a doubt about my program to the VBA/EXCEL
I made a file called "MASTER WORKSHEET" with various data from a client, my goal is: To create a VBA to open any file in Excel and that I import chosen cells to fill out all data of the "MASTER WORKSHEET", for example, all excel file I open with the button "IMPORT DATA", it will automatically capture only those cells that I choose, but my program it captures but is with configuration problems on VALUE or NUMBER. | 0debug |
Accessing an array in different class files SWIFT 3 : I am trying to make an event panning app where the user enter various entries to plan an event (eg: Title, location, when, etc). Users have options to choose from different themes, such as, birthday party, graduation party, house party, baby shower, etc.
I am using different viewcontrollers for each theme. I am using my viewController.swift file to show data in a tableview. and for my other viewControllers, i have cocoa-touch files assigned to each of them.
Now let's pretend a user wants to plan a house party. First user will click on the house party button. That will direct the user to a different viewController (houseParty.swift). Here, user will be able to enter all the data necessary to organize the event (Title, location, when, why, etc). Everything will be stored in an arrays of each type, meaning, Titles will have a different array, location will have a different array, etc.
Now, I want to be able to access those arrays in my viewController.swift file to preset those data in a tableview cell. How do i do that? I am making an object/instance of a class houseParty.swift in viewController.swift file and trying to access arrays but i am unable to do so.
var house = houseParty()
house.arrayName //Getting error here. It wont recognize an array from that file.
Any help would be appreciated. Thank you in advance. | 0debug |
Syntax Erro Python : Estou iniciando python pouco tempo. Não estou conseguindo resolver esse erro.
import pygame, sys
from pygame.locals import *
pygame.init()
DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('Hello World!')
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
[enter image description here][1]
[1]: http://i.stack.imgur.com/PsYSU.png | 0debug |
static void xen_platform_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->init = xen_platform_initfn;
k->vendor_id = PCI_VENDOR_ID_XEN;
k->device_id = PCI_DEVICE_ID_XEN_PLATFORM;
k->class_id = PCI_CLASS_OTHERS << 8 | 0x80;
k->subsystem_vendor_id = PCI_VENDOR_ID_XEN;
k->subsystem_id = PCI_DEVICE_ID_XEN_PLATFORM;
k->revision = 1;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
dc->desc = "XEN platform pci device";
dc->reset = platform_reset;
dc->vmsd = &vmstate_xen_platform;
}
| 1threat |
static void kvm_do_inject_x86_mce(void *_data)
{
struct kvm_x86_mce_data *data = _data;
int r;
if ((data->env->mcg_cap & MCG_SER_P) &&
!(data->mce->status & MCI_STATUS_AR)) {
r = kvm_mce_in_exception(data->env);
if (r == -1) {
fprintf(stderr, "Failed to get MCE status\n");
} else if (r) {
return;
}
}
r = kvm_set_mce(data->env, data->mce);
if (r < 0) {
perror("kvm_set_mce FAILED");
if (data->abort_on_error) {
abort();
}
}
}
| 1threat |
Can someone explain this behavior with Python? : <p>Can someone explain this behavior?</p>
<pre><code>print("%.2f" % (model.x[1].value))
X = int(model.x[1].value)
print("%.2f" % X)
</code></pre>
<p>Output:</p>
<pre><code>3.00
2.00
</code></pre>
<p>Thanks</p>
| 0debug |
Use vm.$on to listen to event emitted from child in vue.js 2.0 : <p>I've been through the vue.js events section on events but it seems to only give examples of how to listen to events using the vm.$on handler within html. Between that and the new changes for 2.0 I'm unsure how to simply transmit a event from child -> parent.</p>
<p>I need to transmit an event because after parent receiving i want to broadcast it to another child.</p>
<p>I'm using single page components, this is my setup:</p>
<pre><code>// parent
export default {
mounted: function () {
this.$on('myEvent', function (msg) {
console.log('caught in parent', msg)
});
},
components: {
'child': child,
},
}
// child
this.$emit('myEvent', true)
</code></pre>
<p>How can I receive this event on the parent vm please? Note, I don't want to use $on in the html. I want the event receiving logic in the vm where it should be.</p>
<p>Thanks, </p>
| 0debug |
static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
{
IEC61937Context *ctx = s->priv_data;
int ret, padding;
ctx->out_buf = pkt->data;
ctx->out_bytes = pkt->size;
ctx->length_code = FFALIGN(pkt->size, 2) << 3;
ctx->use_preamble = 1;
ctx->extra_bswap = 0;
ret = ctx->header_info(s, pkt);
if (ret < 0)
return ret;
if (!ctx->pkt_offset)
return 0;
padding = (ctx->pkt_offset - ctx->use_preamble * BURST_HEADER_SIZE - ctx->out_bytes) & ~1;
if (padding < 0) {
av_log(s, AV_LOG_ERROR, "bitrate is too high\n");
return AVERROR(EINVAL);
}
if (ctx->use_preamble) {
put_le16(s->pb, SYNCWORD1);
put_le16(s->pb, SYNCWORD2);
put_le16(s->pb, ctx->data_type);
put_le16(s->pb, ctx->length_code);
}
if (HAVE_BIGENDIAN ^ ctx->extra_bswap) {
put_buffer(s->pb, ctx->out_buf, ctx->out_bytes & ~1);
} else {
av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->out_bytes + FF_INPUT_BUFFER_PADDING_SIZE);
if (!ctx->buffer)
return AVERROR(ENOMEM);
ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (uint16_t *)ctx->out_buf, ctx->out_bytes >> 1);
put_buffer(s->pb, ctx->buffer, ctx->out_bytes & ~1);
}
if (ctx->out_bytes & 1)
put_be16(s->pb, ctx->out_buf[ctx->out_bytes - 1]);
put_nbyte(s->pb, 0, padding);
av_log(s, AV_LOG_DEBUG, "type=%x len=%i pkt_offset=%i\n",
ctx->data_type, ctx->out_bytes, ctx->pkt_offset);
put_flush_packet(s->pb);
return 0;
}
| 1threat |
void put_no_rnd_pixels16_xy2_altivec(uint8_t * block, const uint8_t * pixels, int line_size, int h)
{
POWERPC_TBL_DECLARE(altivec_put_no_rnd_pixels16_xy2_num, 1);
#ifdef ALTIVEC_USE_REFERENCE_C_CODE
int j;
POWERPC_TBL_START_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
for (j = 0; j < 4; j++) {
int i;
const uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
const uint32_t b =
(((const struct unaligned_32 *) (pixels + 1))->l);
uint32_t l0 =
(a & 0x03030303UL) + (b & 0x03030303UL) + 0x01010101UL;
uint32_t h0 =
((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
uint32_t l1, h1;
pixels += line_size;
for (i = 0; i < h; i += 2) {
uint32_t a = (((const struct unaligned_32 *) (pixels))->l);
uint32_t b = (((const struct unaligned_32 *) (pixels + 1))->l);
l1 = (a & 0x03030303UL) + (b & 0x03030303UL);
h1 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
*((uint32_t *) block) =
h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL);
pixels += line_size;
block += line_size;
a = (((const struct unaligned_32 *) (pixels))->l);
b = (((const struct unaligned_32 *) (pixels + 1))->l);
l0 = (a & 0x03030303UL) + (b & 0x03030303UL) + 0x01010101UL;
h0 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2);
*((uint32_t *) block) =
h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL);
pixels += line_size;
block += line_size;
} pixels += 4 - line_size * (h + 1);
block += 4 - line_size * h;
}
POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
#else
register int i;
register vector unsigned char
pixelsv1, pixelsv2, pixelsv3, pixelsv4;
register vector unsigned char
blockv, temp1, temp2;
register vector unsigned short
pixelssum1, pixelssum2, temp3,
pixelssum3, pixelssum4, temp4;
register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0);
register const vector unsigned short vcone = (const vector unsigned short)vec_splat_u16(1);
register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2);
POWERPC_TBL_START_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
temp1 = vec_ld(0, pixels);
temp2 = vec_ld(16, pixels);
pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels));
if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F)
{
pixelsv2 = temp2;
}
else
{
pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels));
}
pixelsv3 = vec_mergel(vczero, pixelsv1);
pixelsv4 = vec_mergel(vczero, pixelsv2);
pixelsv1 = vec_mergeh(vczero, pixelsv1);
pixelsv2 = vec_mergeh(vczero, pixelsv2);
pixelssum3 = vec_add((vector unsigned short)pixelsv3,
(vector unsigned short)pixelsv4);
pixelssum3 = vec_add(pixelssum3, vcone);
pixelssum1 = vec_add((vector unsigned short)pixelsv1,
(vector unsigned short)pixelsv2);
pixelssum1 = vec_add(pixelssum1, vcone);
for (i = 0; i < h ; i++) {
blockv = vec_ld(0, block);
temp1 = vec_ld(line_size, pixels);
temp2 = vec_ld(line_size + 16, pixels);
pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels));
if (((((unsigned long)pixels) + line_size) & 0x0000000F) == 0x0000000F)
{
pixelsv2 = temp2;
}
else
{
pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels));
}
pixelsv3 = vec_mergel(vczero, pixelsv1);
pixelsv4 = vec_mergel(vczero, pixelsv2);
pixelsv1 = vec_mergeh(vczero, pixelsv1);
pixelsv2 = vec_mergeh(vczero, pixelsv2);
pixelssum4 = vec_add((vector unsigned short)pixelsv3,
(vector unsigned short)pixelsv4);
pixelssum2 = vec_add((vector unsigned short)pixelsv1,
(vector unsigned short)pixelsv2);
temp4 = vec_add(pixelssum3, pixelssum4);
temp4 = vec_sra(temp4, vctwo);
temp3 = vec_add(pixelssum1, pixelssum2);
temp3 = vec_sra(temp3, vctwo);
pixelssum3 = vec_add(pixelssum4, vcone);
pixelssum1 = vec_add(pixelssum2, vcone);
blockv = vec_packsu(temp3, temp4);
vec_st(blockv, 0, block);
block += line_size;
pixels += line_size;
}
POWERPC_TBL_STOP_COUNT(altivec_put_no_rnd_pixels16_xy2_num, 1);
#endif
}
| 1threat |
Angular2 run animation on leave & observable filter : <p>I have a component that I can animate on entry like this, the entry animation works fine. The handleRemoval method gets executed and an event emitter filters the component from the list of components (using observables). But the :leave animation does not run:</p>
<pre><code> @Component({
animations: [
trigger(
'enterAnimation', [
transition(':enter', [
style({transform: 'translateY(100%)', opacity: 0}),
animate('500ms', style({transform: 'translateY(0)', opacity: 1}))
]),
transition(':leave', [
style({transform: 'translateY(0)', opacity: 1}),
animate('500ms', style({transform: 'translateY(100%)', opacity: 0}))
])
]
)
],
template: `
<div class="mb1 card text-xs-center rounded" [@enterAnimation]="show">
</code></pre>
<p>
...</p>
<pre><code>export class ContentPropertyComponent {
show: boolean = false;
constructor(private router: Router) {
this.show = true;
}
handleRemoval(contentProperty: PropertyModel) {
this.show = false;
this.delete.emit(this.contentProperty);
}
}
</code></pre>
<p>Any help appreciated.</p>
| 0debug |
Files missing in Google Cloud Platform : <p>I'm surprised to learn that all my files under the home directory got deleted. Please help.</p>
<p>This is on my Google cloud service. I use to see files via ssh and/or gcloud command line. Now, I see all files under my HOME gone.</p>
<p>That's very disappointing.</p>
| 0debug |
static int bdrv_prwv_co(BlockDriverState *bs, int64_t offset,
QEMUIOVector *qiov, bool is_write,
BdrvRequestFlags flags)
{
Coroutine *co;
RwCo rwco = {
.bs = bs,
.offset = offset,
.qiov = qiov,
.is_write = is_write,
.ret = NOT_DONE,
.flags = flags,
};
if (bs->io_limits_enabled) {
fprintf(stderr, "Disabling I/O throttling on '%s' due "
"to synchronous I/O.\n", bdrv_get_device_name(bs));
bdrv_io_limits_disable(bs);
}
if (qemu_in_coroutine()) {
bdrv_rw_co_entry(&rwco);
} else {
AioContext *aio_context = bdrv_get_aio_context(bs);
co = qemu_coroutine_create(bdrv_rw_co_entry);
qemu_coroutine_enter(co, &rwco);
while (rwco.ret == NOT_DONE) {
aio_poll(aio_context, true);
}
}
return rwco.ret;
}
| 1threat |
MSSQL Update Statement : I want to update the TimeOccurred column in all tables in a database (also fine with doing 1 table at a time if that is necessary). This is what the current values in this column look like:
2017-06-12 14:34:00
I would like to replace that value in all tables in the column TimeOccurred by changing just the year to the current year and the month to the previous month.
So 2012-03-14 14:34:00 becomes 2017-05-14 14:34:00.
It would also help if I could check the day and if it was 29,30,or 31 change it to 25. | 0debug |
static void pmac_dma_read(BlockBackend *blk,
int64_t offset, unsigned int bytes,
void (*cb)(void *opaque, int ret), void *opaque)
{
DBDMA_io *io = opaque;
MACIOIDEState *m = io->opaque;
IDEState *s = idebus_active_if(&m->bus);
dma_addr_t dma_addr, dma_len;
void *mem;
int64_t sector_num;
int nsector;
uint64_t align = BDRV_SECTOR_SIZE;
size_t head_bytes, tail_bytes;
qemu_iovec_destroy(&io->iov);
qemu_iovec_init(&io->iov, io->len / MACIO_PAGE_SIZE + 1);
sector_num = (offset >> 9);
nsector = (io->len >> 9);
MACIO_DPRINTF("--- DMA read transfer (0x%" HWADDR_PRIx ",0x%x): "
"sector_num: %" PRId64 ", nsector: %d\n", io->addr, io->len,
sector_num, nsector);
dma_addr = io->addr;
dma_len = io->len;
mem = dma_memory_map(&address_space_memory, dma_addr, &dma_len,
DMA_DIRECTION_FROM_DEVICE);
if (offset & (align - 1)) {
head_bytes = offset & (align - 1);
MACIO_DPRINTF("--- DMA unaligned head: sector %" PRId64 ", "
"discarding %zu bytes\n", sector_num, head_bytes);
qemu_iovec_add(&io->iov, &io->remainder, head_bytes);
bytes += offset & (align - 1);
offset = offset & ~(align - 1);
}
qemu_iovec_add(&io->iov, mem, io->len);
if ((offset + bytes) & (align - 1)) {
tail_bytes = (offset + bytes) & (align - 1);
MACIO_DPRINTF("--- DMA unaligned tail: sector %" PRId64 ", "
"discarding bytes %zu\n", sector_num, tail_bytes);
qemu_iovec_add(&io->iov, &io->remainder, align - tail_bytes);
bytes = ROUND_UP(bytes, align);
}
s->io_buffer_size -= io->len;
s->io_buffer_index += io->len;
io->len = 0;
MACIO_DPRINTF("--- Block read transfer - sector_num: %" PRIx64 " "
"nsector: %x\n", (offset >> 9), (bytes >> 9));
m->aiocb = blk_aio_readv(blk, (offset >> 9), &io->iov, (bytes >> 9),
cb, io);
}
| 1threat |
static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
{
int ret = 0, i, got_packet = 0;
AVDictionary *metadata = NULL;
av_init_packet(pkt);
while (!got_packet && !s->parse_queue) {
AVStream *st;
AVPacket cur_pkt;
ret = ff_read_packet(s, &cur_pkt);
if (ret < 0) {
if (ret == AVERROR(EAGAIN))
return ret;
for (i = 0; i < s->nb_streams; i++) {
st = s->streams[i];
if (st->parser && st->need_parsing)
parse_packet(s, NULL, st->index);
}
break;
}
ret = 0;
st = s->streams[cur_pkt.stream_index];
if (cur_pkt.pts != AV_NOPTS_VALUE &&
cur_pkt.dts != AV_NOPTS_VALUE &&
cur_pkt.pts < cur_pkt.dts) {
av_log(s, AV_LOG_WARNING,
"Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
cur_pkt.stream_index,
av_ts2str(cur_pkt.pts),
av_ts2str(cur_pkt.dts),
cur_pkt.size);
}
if (s->debug & FF_FDEBUG_TS)
av_log(s, AV_LOG_DEBUG,
"ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%d, flags=%d\n",
cur_pkt.stream_index,
av_ts2str(cur_pkt.pts),
av_ts2str(cur_pkt.dts),
cur_pkt.size, cur_pkt.duration, cur_pkt.flags);
if (st->need_parsing && !st->parser && !(s->flags & AVFMT_FLAG_NOPARSE)) {
st->parser = av_parser_init(st->codec->codec_id);
if (!st->parser) {
av_log(s, AV_LOG_VERBOSE, "parser not found for codec "
"%s, packets or times may be invalid.\n",
avcodec_get_name(st->codec->codec_id));
st->need_parsing = AVSTREAM_PARSE_NONE;
} else if (st->need_parsing == AVSTREAM_PARSE_HEADERS)
st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
else if (st->need_parsing == AVSTREAM_PARSE_FULL_ONCE)
st->parser->flags |= PARSER_FLAG_ONCE;
else if (st->need_parsing == AVSTREAM_PARSE_FULL_RAW)
st->parser->flags |= PARSER_FLAG_USE_CODEC_TS;
}
if (!st->need_parsing || !st->parser) {
*pkt = cur_pkt;
compute_pkt_fields(s, st, NULL, pkt);
if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
(pkt->flags & AV_PKT_FLAG_KEY) && pkt->dts != AV_NOPTS_VALUE) {
ff_reduce_index(s, st->index);
av_add_index_entry(st, pkt->pos, pkt->dts,
0, 0, AVINDEX_KEYFRAME);
}
got_packet = 1;
} else if (st->discard < AVDISCARD_ALL) {
if ((ret = parse_packet(s, &cur_pkt, cur_pkt.stream_index)) < 0)
return ret;
} else {
av_free_packet(&cur_pkt);
}
if (pkt->flags & AV_PKT_FLAG_KEY)
st->skip_to_keyframe = 0;
if (st->skip_to_keyframe) {
av_free_packet(&cur_pkt);
if (got_packet) {
*pkt = cur_pkt;
}
got_packet = 0;
}
}
if (!got_packet && s->parse_queue)
ret = read_from_packet_buffer(&s->parse_queue, &s->parse_queue_end, pkt);
if (ret >= 0) {
AVStream *st = s->streams[pkt->stream_index];
int discard_padding = 0;
if (st->end_discard_sample && pkt->pts != AV_NOPTS_VALUE) {
int64_t pts = pkt->pts - (is_relative(pkt->pts) ? RELATIVE_TS_BASE : 0);
int64_t sample = ts_to_samples(st, pts);
int duration = ts_to_samples(st, pkt->duration);
int64_t end_sample = sample + duration;
if (duration > 0 && end_sample >= st->end_discard_sample)
discard_padding = FFMIN(end_sample - st->end_discard_sample, duration);
}
if (st->skip_samples || discard_padding) {
uint8_t *p = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10);
if (p) {
AV_WL32(p, st->skip_samples);
AV_WL32(p + 4, discard_padding);
av_log(s, AV_LOG_DEBUG, "demuxer injecting skip %d\n", st->skip_samples);
}
st->skip_samples = 0;
}
if (st->inject_global_side_data) {
for (i = 0; i < st->nb_side_data; i++) {
AVPacketSideData *src_sd = &st->side_data[i];
uint8_t *dst_data;
if (av_packet_get_side_data(pkt, src_sd->type, NULL))
continue;
dst_data = av_packet_new_side_data(pkt, src_sd->type, src_sd->size);
if (!dst_data) {
av_log(s, AV_LOG_WARNING, "Could not inject global side data\n");
continue;
}
memcpy(dst_data, src_sd->data, src_sd->size);
}
st->inject_global_side_data = 0;
}
if (!(s->flags & AVFMT_FLAG_KEEP_SIDE_DATA))
av_packet_merge_side_data(pkt);
}
av_opt_get_dict_val(s, "metadata", AV_OPT_SEARCH_CHILDREN, &metadata);
if (metadata) {
s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
av_dict_copy(&s->metadata, metadata, 0);
av_dict_free(&metadata);
av_opt_set_dict_val(s, "metadata", NULL, AV_OPT_SEARCH_CHILDREN);
}
if (s->debug & FF_FDEBUG_TS)
av_log(s, AV_LOG_DEBUG,
"read_frame_internal stream=%d, pts=%s, dts=%s, "
"size=%d, duration=%d, flags=%d\n",
pkt->stream_index,
av_ts2str(pkt->pts),
av_ts2str(pkt->dts),
pkt->size, pkt->duration, pkt->flags);
return ret;
}
| 1threat |
static void dvbsub_parse_region_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
DVBSubContext *ctx = avctx->priv_data;
const uint8_t *buf_end = buf + buf_size;
int region_id, object_id;
int av_unused version;
DVBSubRegion *region;
DVBSubObject *object;
DVBSubObjectDisplay *display;
int fill;
if (buf_size < 10)
region_id = *buf++;
region = get_region(ctx, region_id);
if (!region) {
region = av_mallocz(sizeof(DVBSubRegion));
region->id = region_id;
region->version = -1;
region->next = ctx->region_list;
ctx->region_list = region;
}
version = ((*buf)>>4) & 15;
fill = ((*buf++) >> 3) & 1;
region->width = AV_RB16(buf);
buf += 2;
region->height = AV_RB16(buf);
buf += 2;
if (region->width * region->height != region->buf_size) {
av_free(region->pbuf);
region->buf_size = region->width * region->height;
region->pbuf = av_malloc(region->buf_size);
fill = 1;
region->dirty = 0;
}
region->depth = 1 << (((*buf++) >> 2) & 7);
if(region->depth<2 || region->depth>8){
av_log(avctx, AV_LOG_ERROR, "region depth %d is invalid\n", region->depth);
region->depth= 4;
}
region->clut = *buf++;
if (region->depth == 8) {
region->bgcolor = *buf++;
buf += 1;
} else {
buf += 1;
if (region->depth == 4)
region->bgcolor = (((*buf++) >> 4) & 15);
else
region->bgcolor = (((*buf++) >> 2) & 3);
}
av_dlog(avctx, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
if (fill) {
memset(region->pbuf, region->bgcolor, region->buf_size);
av_dlog(avctx, "Fill region (%d)\n", region->bgcolor);
}
delete_region_display_list(ctx, region);
while (buf + 5 < buf_end) {
object_id = AV_RB16(buf);
buf += 2;
object = get_object(ctx, object_id);
if (!object) {
object = av_mallocz(sizeof(DVBSubObject));
object->id = object_id;
object->next = ctx->object_list;
ctx->object_list = object;
}
object->type = (*buf) >> 6;
display = av_mallocz(sizeof(DVBSubObjectDisplay));
display->object_id = object_id;
display->region_id = region_id;
display->x_pos = AV_RB16(buf) & 0xfff;
buf += 2;
display->y_pos = AV_RB16(buf) & 0xfff;
buf += 2;
if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) {
display->fgcolor = *buf++;
display->bgcolor = *buf++;
}
display->region_list_next = region->display_list;
region->display_list = display;
display->object_list_next = object->display_list;
object->display_list = display;
}
} | 1threat |
long disas_insn(DisasContext *s, uint8_t *pc_start)
{
int b, prefixes, aflag, dflag;
int shift, ot;
int modrm, reg, rm, mod, reg_addr, op, opreg, offset_addr, val;
unsigned int next_eip;
s->pc = pc_start;
prefixes = 0;
aflag = s->code32;
dflag = s->code32;
next_byte:
b = ldub(s->pc);
s->pc++;
switch (b) {
case 0xf3:
prefixes |= PREFIX_REPZ;
goto next_byte;
case 0xf2:
prefixes |= PREFIX_REPNZ;
goto next_byte;
case 0xf0:
prefixes |= PREFIX_LOCK;
goto next_byte;
case 0x2e:
prefixes |= PREFIX_CS;
goto next_byte;
case 0x36:
prefixes |= PREFIX_SS;
goto next_byte;
case 0x3e:
prefixes |= PREFIX_DS;
goto next_byte;
case 0x26:
prefixes |= PREFIX_ES;
goto next_byte;
case 0x64:
prefixes |= PREFIX_FS;
goto next_byte;
case 0x65:
prefixes |= PREFIX_GS;
goto next_byte;
case 0x66:
prefixes |= PREFIX_DATA;
goto next_byte;
case 0x67:
prefixes |= PREFIX_ADR;
goto next_byte;
case 0x9b:
prefixes |= PREFIX_FWAIT;
goto next_byte;
}
if (prefixes & PREFIX_DATA)
dflag ^= 1;
if (prefixes & PREFIX_ADR)
aflag ^= 1;
s->prefix = prefixes;
s->aflag = aflag;
s->dflag = dflag;
if (prefixes & PREFIX_LOCK)
gen_op_lock();
reswitch:
switch(b) {
case 0x0f:
b = ldub(s->pc++) | 0x100;
goto reswitch;
case 0x00 ... 0x05:
case 0x08 ... 0x0d:
case 0x10 ... 0x15:
case 0x18 ... 0x1d:
case 0x20 ... 0x25:
case 0x28 ... 0x2d:
case 0x30 ... 0x35:
case 0x38 ... 0x3d:
{
int op, f, val;
op = (b >> 3) & 7;
f = (b >> 1) & 3;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
switch(f) {
case 0:
modrm = ldub(s->pc++);
reg = ((modrm >> 3) & 7) + OR_EAX;
mod = (modrm >> 6) & 3;
rm = modrm & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0[ot]();
opreg = OR_TMP0;
} else {
opreg = OR_EAX + rm;
}
gen_op(s, op, ot, opreg, reg);
if (mod != 3 && op != 7) {
gen_op_st_T0_A0[ot]();
}
break;
case 1:
modrm = ldub(s->pc++);
mod = (modrm >> 6) & 3;
reg = ((modrm >> 3) & 7) + OR_EAX;
rm = modrm & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0[ot]();
opreg = OR_TMP1;
} else {
opreg = OR_EAX + rm;
}
gen_op(s, op, ot, reg, opreg);
break;
case 2:
val = insn_get(s, ot);
gen_opi(s, op, ot, OR_EAX, val);
break;
}
}
break;
case 0x80:
case 0x81:
case 0x83:
{
int val;
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = (modrm >> 3) & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0[ot]();
opreg = OR_TMP0;
} else {
opreg = rm + OR_EAX;
}
switch(b) {
default:
case 0x80:
case 0x81:
val = insn_get(s, ot);
break;
case 0x83:
val = (int8_t)insn_get(s, OT_BYTE);
break;
}
gen_opi(s, op, ot, opreg, val);
if (op != 7 && mod != 3) {
gen_op_st_T0_A0[ot]();
}
}
break;
case 0x40 ... 0x47:
ot = dflag ? OT_LONG : OT_WORD;
gen_inc(s, ot, OR_EAX + (b & 7), 1);
break;
case 0x48 ... 0x4f:
ot = dflag ? OT_LONG : OT_WORD;
gen_inc(s, ot, OR_EAX + (b & 7), -1);
break;
case 0xf6:
case 0xf7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = (modrm >> 3) & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0[ot]();
} else {
gen_op_mov_TN_reg[ot][0][rm]();
}
switch(op) {
case 0:
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 2:
gen_op_notl_T0();
if (mod != 3) {
gen_op_st_T0_A0[ot]();
} else {
gen_op_mov_reg_T0[ot][rm]();
}
break;
case 3:
gen_op_negl_T0_cc();
if (mod != 3) {
gen_op_st_T0_A0[ot]();
} else {
gen_op_mov_reg_T0[ot][rm]();
}
s->cc_op = CC_OP_SUBB + ot;
break;
case 4:
switch(ot) {
case OT_BYTE:
gen_op_mulb_AL_T0();
break;
case OT_WORD:
gen_op_mulw_AX_T0();
break;
default:
case OT_LONG:
gen_op_mull_EAX_T0();
break;
}
s->cc_op = CC_OP_MUL;
break;
case 5:
switch(ot) {
case OT_BYTE:
gen_op_imulb_AL_T0();
break;
case OT_WORD:
gen_op_imulw_AX_T0();
break;
default:
case OT_LONG:
gen_op_imull_EAX_T0();
break;
}
s->cc_op = CC_OP_MUL;
break;
case 6:
switch(ot) {
case OT_BYTE:
gen_op_divb_AL_T0();
break;
case OT_WORD:
gen_op_divw_AX_T0();
break;
default:
case OT_LONG:
gen_op_divl_EAX_T0();
break;
}
break;
case 7:
switch(ot) {
case OT_BYTE:
gen_op_idivb_AL_T0();
break;
case OT_WORD:
gen_op_idivw_AX_T0();
break;
default:
case OT_LONG:
gen_op_idivl_EAX_T0();
break;
}
break;
default:
goto illegal_op;
}
break;
case 0xfe:
case 0xff:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = (modrm >> 3) & 7;
if (op >= 2 && b == 0xfe) {
goto illegal_op;
}
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (op != 3 && op != 5)
gen_op_ld_T0_A0[ot]();
} else {
gen_op_mov_TN_reg[ot][0][rm]();
}
switch(op) {
case 0:
gen_inc(s, ot, OR_TMP0, 1);
if (mod != 3)
gen_op_st_T0_A0[ot]();
else
gen_op_mov_reg_T0[ot][rm]();
break;
case 1:
gen_inc(s, ot, OR_TMP0, -1);
if (mod != 3)
gen_op_st_T0_A0[ot]();
else
gen_op_mov_reg_T0[ot][rm]();
break;
case 2:
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
next_eip = s->pc - s->cs_base;
gen_op_movl_T0_im(next_eip);
gen_push_T0(s);
s->is_jmp = 1;
break;
case 3:
gen_op_movl_T0_seg(R_CS);
gen_push_T0(s);
next_eip = s->pc - s->cs_base;
gen_op_movl_T0_im(next_eip);
gen_push_T0(s);
gen_op_ld_T1_A0[ot]();
gen_op_addl_A0_im(1 << (ot - OT_WORD + 1));
gen_op_lduw_T0_A0();
gen_movl_seg_T0(s, R_CS);
gen_op_movl_T0_T1();
gen_op_jmp_T0();
s->is_jmp = 1;
break;
case 4:
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
s->is_jmp = 1;
break;
case 5:
gen_op_ld_T1_A0[ot]();
gen_op_addl_A0_im(1 << (ot - OT_WORD + 1));
gen_op_lduw_T0_A0();
gen_movl_seg_T0(s, R_CS);
gen_op_movl_T0_T1();
gen_op_jmp_T0();
s->is_jmp = 1;
break;
case 6:
gen_push_T0(s);
break;
default:
goto illegal_op;
}
break;
case 0x84:
case 0x85:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
reg = (modrm >> 3) & 7;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_op_mov_TN_reg[ot][1][reg + OR_EAX]();
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 0xa8:
case 0xa9:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
val = insn_get(s, ot);
gen_op_mov_TN_reg[ot][0][OR_EAX]();
gen_op_movl_T1_im(val);
gen_op_testl_T0_T1_cc();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 0x98:
if (dflag)
gen_op_movswl_EAX_AX();
else
gen_op_movsbw_AX_AL();
break;
case 0x99:
if (dflag)
gen_op_movslq_EDX_EAX();
else
gen_op_movswl_DX_AX();
break;
case 0x1af:
case 0x69:
case 0x6b:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
reg = ((modrm >> 3) & 7) + OR_EAX;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
if (b == 0x69) {
val = insn_get(s, ot);
gen_op_movl_T1_im(val);
} else if (b == 0x6b) {
val = insn_get(s, OT_BYTE);
gen_op_movl_T1_im(val);
} else {
gen_op_mov_TN_reg[ot][1][reg]();
}
if (ot == OT_LONG) {
gen_op_imull_T0_T1();
} else {
gen_op_imulw_T0_T1();
}
gen_op_mov_reg_T0[ot][reg]();
s->cc_op = CC_OP_MUL;
break;
case 0x1c0:
case 0x1c1:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (mod == 3) {
rm = modrm & 7;
gen_op_mov_TN_reg[ot][0][reg]();
gen_op_mov_TN_reg[ot][1][rm]();
gen_op_addl_T0_T1_cc();
gen_op_mov_reg_T0[ot][rm]();
gen_op_mov_reg_T1[ot][reg]();
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_mov_TN_reg[ot][0][reg]();
gen_op_ld_T1_A0[ot]();
gen_op_addl_T0_T1_cc();
gen_op_st_T0_A0[ot]();
gen_op_mov_reg_T1[ot][reg]();
}
s->cc_op = CC_OP_ADDB + ot;
break;
case 0x1b0:
case 0x1b1:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
gen_op_mov_TN_reg[ot][1][reg]();
if (mod == 3) {
rm = modrm & 7;
gen_op_mov_TN_reg[ot][0][rm]();
gen_op_cmpxchg_T0_T1_EAX_cc[ot]();
gen_op_mov_reg_T0[ot][rm]();
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0[ot]();
gen_op_cmpxchg_T0_T1_EAX_cc[ot]();
gen_op_st_T0_A0[ot]();
}
s->cc_op = CC_OP_SUBB + ot;
break;
case 0x50 ... 0x57:
gen_op_mov_TN_reg[OT_LONG][0][b & 7]();
gen_push_T0(s);
break;
case 0x58 ... 0x5f:
ot = dflag ? OT_LONG : OT_WORD;
gen_pop_T0(s);
gen_op_mov_reg_T0[ot][b & 7]();
gen_pop_update(s);
break;
case 0x60:
gen_pusha(s);
break;
case 0x61:
gen_popa(s);
break;
case 0x68:
case 0x6a:
ot = dflag ? OT_LONG : OT_WORD;
if (b == 0x68)
val = insn_get(s, ot);
else
val = (int8_t)insn_get(s, OT_BYTE);
gen_op_movl_T0_im(val);
gen_push_T0(s);
break;
case 0x8f:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
gen_pop_T0(s);
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
gen_pop_update(s);
break;
case 0xc8:
{
int level;
val = lduw(s->pc);
s->pc += 2;
level = ldub(s->pc++);
gen_enter(s, val, level);
}
break;
case 0xc9:
if (s->ss32) {
gen_op_mov_TN_reg[OT_LONG][0][R_EBP]();
gen_op_mov_reg_T0[OT_LONG][R_ESP]();
} else {
gen_op_mov_TN_reg[OT_WORD][0][R_EBP]();
gen_op_mov_reg_T0[OT_WORD][R_ESP]();
}
gen_pop_T0(s);
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_reg_T0[ot][R_EBP]();
gen_pop_update(s);
break;
case 0x06:
case 0x0e:
case 0x16:
case 0x1e:
gen_op_movl_T0_seg(b >> 3);
gen_push_T0(s);
break;
case 0x1a0:
case 0x1a8:
gen_op_movl_T0_seg(((b >> 3) & 7) + R_FS);
gen_push_T0(s);
break;
case 0x07:
case 0x17:
case 0x1f:
gen_pop_T0(s);
gen_movl_seg_T0(s, b >> 3);
gen_pop_update(s);
break;
case 0x1a1:
case 0x1a9:
gen_pop_T0(s);
gen_movl_seg_T0(s, ((b >> 3) & 7) + R_FS);
gen_pop_update(s);
break;
case 0x88:
case 0x89:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
reg = (modrm >> 3) & 7;
gen_ldst_modrm(s, modrm, ot, OR_EAX + reg, 1);
break;
case 0xc6:
case 0xc7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
mod = (modrm >> 6) & 3;
if (mod != 3)
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
val = insn_get(s, ot);
gen_op_movl_T0_im(val);
if (mod != 3)
gen_op_st_T0_A0[ot]();
else
gen_op_mov_reg_T0[ot][modrm & 7]();
break;
case 0x8a:
case 0x8b:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
reg = (modrm >> 3) & 7;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_op_mov_reg_T0[ot][reg]();
break;
case 0x8e:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
reg = (modrm >> 3) & 7;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
if (reg >= 6 || reg == R_CS)
goto illegal_op;
gen_movl_seg_T0(s, reg);
break;
case 0x8c:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
reg = (modrm >> 3) & 7;
if (reg >= 6)
goto illegal_op;
gen_op_movl_T0_seg(reg);
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
break;
case 0x1b6:
case 0x1b7:
case 0x1be:
case 0x1bf:
{
int d_ot;
d_ot = dflag + OT_WORD;
ot = (b & 1) + OT_BYTE;
modrm = ldub(s->pc++);
reg = ((modrm >> 3) & 7) + OR_EAX;
mod = (modrm >> 6) & 3;
rm = modrm & 7;
if (mod == 3) {
gen_op_mov_TN_reg[ot][0][rm]();
switch(ot | (b & 8)) {
case OT_BYTE:
gen_op_movzbl_T0_T0();
break;
case OT_BYTE | 8:
gen_op_movsbl_T0_T0();
break;
case OT_WORD:
gen_op_movzwl_T0_T0();
break;
default:
case OT_WORD | 8:
gen_op_movswl_T0_T0();
break;
}
gen_op_mov_reg_T0[d_ot][reg]();
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (b & 8) {
gen_op_lds_T0_A0[ot]();
} else {
gen_op_ldu_T0_A0[ot]();
}
gen_op_mov_reg_T0[d_ot][reg]();
}
}
break;
case 0x8d:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
reg = (modrm >> 3) & 7;
s->prefix &= ~(PREFIX_CS | PREFIX_SS | PREFIX_DS |
PREFIX_ES | PREFIX_FS | PREFIX_GS);
val = s->addseg;
s->addseg = 0;
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
s->addseg = val;
gen_op_mov_reg_A0[ot - OT_WORD][reg]();
break;
case 0xa0:
case 0xa1:
case 0xa2:
case 0xa3:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (s->aflag)
offset_addr = insn_get(s, OT_LONG);
else
offset_addr = insn_get(s, OT_WORD);
gen_op_movl_A0_im(offset_addr);
{
int override, must_add_seg;
override = R_DS;
must_add_seg = s->addseg;
if (s->prefix & (PREFIX_CS | PREFIX_SS | PREFIX_DS |
PREFIX_ES | PREFIX_FS | PREFIX_GS)) {
if (s->prefix & PREFIX_ES)
override = R_ES;
else if (s->prefix & PREFIX_CS)
override = R_CS;
else if (s->prefix & PREFIX_SS)
override = R_SS;
else if (s->prefix & PREFIX_DS)
override = R_DS;
else if (s->prefix & PREFIX_FS)
override = R_FS;
else
override = R_GS;
must_add_seg = 1;
}
if (must_add_seg) {
gen_op_addl_A0_seg(offsetof(CPUX86State,seg_cache[override].base));
}
}
if ((b & 2) == 0) {
gen_op_ld_T0_A0[ot]();
gen_op_mov_reg_T0[ot][R_EAX]();
} else {
gen_op_mov_TN_reg[ot][0][R_EAX]();
gen_op_st_T0_A0[ot]();
}
break;
case 0xd7:
gen_op_movl_A0_reg[R_EBX]();
gen_op_addl_A0_AL();
if (s->aflag == 0)
gen_op_andl_A0_ffff();
{
int override, must_add_seg;
override = R_DS;
must_add_seg = s->addseg;
if (s->prefix & (PREFIX_CS | PREFIX_SS | PREFIX_DS |
PREFIX_ES | PREFIX_FS | PREFIX_GS)) {
if (s->prefix & PREFIX_ES)
override = R_ES;
else if (s->prefix & PREFIX_CS)
override = R_CS;
else if (s->prefix & PREFIX_SS)
override = R_SS;
else if (s->prefix & PREFIX_DS)
override = R_DS;
else if (s->prefix & PREFIX_FS)
override = R_FS;
else
override = R_GS;
must_add_seg = 1;
}
if (must_add_seg) {
gen_op_addl_A0_seg(offsetof(CPUX86State,seg_cache[override].base));
}
}
gen_op_ldub_T0_A0();
gen_op_mov_reg_T0[OT_BYTE][R_EAX]();
break;
case 0xb0 ... 0xb7:
val = insn_get(s, OT_BYTE);
gen_op_movl_T0_im(val);
gen_op_mov_reg_T0[OT_BYTE][b & 7]();
break;
case 0xb8 ... 0xbf:
ot = dflag ? OT_LONG : OT_WORD;
val = insn_get(s, ot);
reg = OR_EAX + (b & 7);
gen_op_movl_T0_im(val);
gen_op_mov_reg_T0[ot][reg]();
break;
case 0x91 ... 0x97:
ot = dflag ? OT_LONG : OT_WORD;
reg = b & 7;
rm = R_EAX;
goto do_xchg_reg;
case 0x86:
case 0x87:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (mod == 3) {
rm = modrm & 7;
do_xchg_reg:
gen_op_mov_TN_reg[ot][0][reg]();
gen_op_mov_TN_reg[ot][1][rm]();
gen_op_mov_reg_T0[ot][rm]();
gen_op_mov_reg_T1[ot][reg]();
} else {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_mov_TN_reg[ot][0][reg]();
if (!(prefixes & PREFIX_LOCK))
gen_op_lock();
gen_op_ld_T1_A0[ot]();
gen_op_st_T0_A0[ot]();
if (!(prefixes & PREFIX_LOCK))
gen_op_unlock();
gen_op_mov_reg_T1[ot][reg]();
}
break;
case 0xc4:
op = R_ES;
goto do_lxx;
case 0xc5:
op = R_DS;
goto do_lxx;
case 0x1b2:
op = R_SS;
goto do_lxx;
case 0x1b4:
op = R_FS;
goto do_lxx;
case 0x1b5:
op = R_GS;
do_lxx:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
if (mod == 3)
goto illegal_op;
gen_op_ld_T1_A0[ot]();
gen_op_addl_A0_im(1 << (ot - OT_WORD + 1));
gen_op_lduw_T0_A0();
gen_movl_seg_T0(s, op);
gen_op_mov_reg_T1[ot][reg]();
break;
case 0xc0:
case 0xc1:
shift = 2;
grp2:
{
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = (modrm >> 3) & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0[ot]();
opreg = OR_TMP0;
} else {
opreg = rm + OR_EAX;
}
if (shift == 0) {
gen_shift(s, op, ot, opreg, OR_ECX);
} else {
if (shift == 2) {
shift = ldub(s->pc++);
}
gen_shifti(s, op, ot, opreg, shift);
}
if (mod != 3) {
gen_op_st_T0_A0[ot]();
}
}
break;
case 0xd0:
case 0xd1:
shift = 1;
goto grp2;
case 0xd2:
case 0xd3:
shift = 0;
goto grp2;
case 0x1a4:
op = 0;
shift = 1;
goto do_shiftd;
case 0x1a5:
op = 0;
shift = 0;
goto do_shiftd;
case 0x1ac:
op = 1;
shift = 1;
goto do_shiftd;
case 0x1ad:
op = 1;
shift = 0;
do_shiftd:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
reg = (modrm >> 3) & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0[ot]();
} else {
gen_op_mov_TN_reg[ot][0][rm]();
}
gen_op_mov_TN_reg[ot][1][reg]();
if (shift) {
val = ldub(s->pc++);
val &= 0x1f;
if (val) {
gen_op_shiftd_T0_T1_im_cc[ot - OT_WORD][op](val);
if (op == 0 && ot != OT_WORD)
s->cc_op = CC_OP_SHLB + ot;
else
s->cc_op = CC_OP_SARB + ot;
}
} else {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_shiftd_T0_T1_ECX_cc[ot - OT_WORD][op]();
s->cc_op = CC_OP_DYNAMIC;
}
if (mod != 3) {
gen_op_st_T0_A0[ot]();
} else {
gen_op_mov_reg_T0[ot][rm]();
}
break;
case 0xd8 ... 0xdf:
modrm = ldub(s->pc++);
mod = (modrm >> 6) & 3;
rm = modrm & 7;
op = ((b & 7) << 3) | ((modrm >> 3) & 7);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
switch(op) {
case 0x00 ... 0x07:
case 0x10 ... 0x17:
case 0x20 ... 0x27:
case 0x30 ... 0x37:
{
int op1;
op1 = op & 7;
switch(op >> 4) {
case 0:
gen_op_flds_FT0_A0();
break;
case 1:
gen_op_fildl_FT0_A0();
break;
case 2:
gen_op_fldl_FT0_A0();
break;
case 3:
default:
gen_op_fild_FT0_A0();
break;
}
gen_op_fp_arith_ST0_FT0[op1]();
if (op1 == 3) {
gen_op_fpop();
}
}
break;
case 0x08:
case 0x0a:
case 0x0b:
case 0x18:
case 0x1a:
case 0x1b:
case 0x28:
case 0x2a:
case 0x2b:
case 0x38:
case 0x3a:
case 0x3b:
switch(op & 7) {
case 0:
gen_op_fpush();
switch(op >> 4) {
case 0:
gen_op_flds_ST0_A0();
break;
case 1:
gen_op_fildl_ST0_A0();
break;
case 2:
gen_op_fldl_ST0_A0();
break;
case 3:
default:
gen_op_fild_ST0_A0();
break;
}
break;
default:
switch(op >> 4) {
case 0:
gen_op_fsts_ST0_A0();
break;
case 1:
gen_op_fistl_ST0_A0();
break;
case 2:
gen_op_fstl_ST0_A0();
break;
case 3:
default:
gen_op_fist_ST0_A0();
break;
}
if ((op & 7) == 3)
gen_op_fpop();
break;
}
break;
case 0x0d:
gen_op_fldcw_A0();
break;
case 0x0f:
gen_op_fnstcw_A0();
break;
case 0x1d:
gen_op_fpush();
gen_op_fldt_ST0_A0();
break;
case 0x1f:
gen_op_fstt_ST0_A0();
gen_op_fpop();
break;
case 0x2f:
gen_op_fnstsw_A0();
break;
case 0x3c:
gen_op_fpush();
gen_op_fbld_ST0_A0();
break;
case 0x3e:
gen_op_fbst_ST0_A0();
gen_op_fpop();
break;
case 0x3d:
gen_op_fpush();
gen_op_fildll_ST0_A0();
break;
case 0x3f:
gen_op_fistll_ST0_A0();
gen_op_fpop();
break;
default:
goto illegal_op;
}
} else {
opreg = rm;
switch(op) {
case 0x08:
gen_op_fpush();
gen_op_fmov_ST0_STN((opreg + 1) & 7);
break;
case 0x09:
gen_op_fxchg_ST0_STN(opreg);
break;
case 0x0a:
switch(rm) {
case 0:
break;
default:
goto illegal_op;
}
break;
case 0x0c:
switch(rm) {
case 0:
gen_op_fchs_ST0();
break;
case 1:
gen_op_fabs_ST0();
break;
case 4:
gen_op_fldz_FT0();
gen_op_fcom_ST0_FT0();
break;
case 5:
gen_op_fxam_ST0();
break;
default:
goto illegal_op;
}
break;
case 0x0d:
{
switch(rm) {
case 0:
gen_op_fpush();
gen_op_fld1_ST0();
break;
case 1:
gen_op_fpush();
gen_op_fldl2t_ST0();
break;
case 2:
gen_op_fpush();
gen_op_fldl2e_ST0();
break;
case 3:
gen_op_fpush();
gen_op_fldpi_ST0();
break;
case 4:
gen_op_fpush();
gen_op_fldlg2_ST0();
break;
case 5:
gen_op_fpush();
gen_op_fldln2_ST0();
break;
case 6:
gen_op_fpush();
gen_op_fldz_ST0();
break;
default:
goto illegal_op;
}
}
break;
case 0x0e:
switch(rm) {
case 0:
gen_op_f2xm1();
break;
case 1:
gen_op_fyl2x();
break;
case 2:
gen_op_fptan();
break;
case 3:
gen_op_fpatan();
break;
case 4:
gen_op_fxtract();
break;
case 5:
gen_op_fprem1();
break;
case 6:
gen_op_fdecstp();
break;
default:
case 7:
gen_op_fincstp();
break;
}
break;
case 0x0f:
switch(rm) {
case 0:
gen_op_fprem();
break;
case 1:
gen_op_fyl2xp1();
break;
case 2:
gen_op_fsqrt();
break;
case 3:
gen_op_fsincos();
break;
case 5:
gen_op_fscale();
break;
case 4:
gen_op_frndint();
break;
case 6:
gen_op_fsin();
break;
default:
case 7:
gen_op_fcos();
break;
}
break;
case 0x00: case 0x01: case 0x04 ... 0x07:
case 0x20: case 0x21: case 0x24 ... 0x27:
case 0x30: case 0x31: case 0x34 ... 0x37:
{
int op1;
op1 = op & 7;
if (op >= 0x20) {
gen_op_fp_arith_STN_ST0[op1](opreg);
if (op >= 0x30)
gen_op_fpop();
} else {
gen_op_fmov_FT0_STN(opreg);
gen_op_fp_arith_ST0_FT0[op1]();
}
}
break;
case 0x02:
gen_op_fmov_FT0_STN(opreg);
gen_op_fcom_ST0_FT0();
break;
case 0x03:
gen_op_fmov_FT0_STN(opreg);
gen_op_fcom_ST0_FT0();
gen_op_fpop();
break;
case 0x15:
switch(rm) {
case 1:
gen_op_fmov_FT0_STN(1);
gen_op_fucom_ST0_FT0();
gen_op_fpop();
gen_op_fpop();
break;
default:
goto illegal_op;
}
break;
case 0x1c:
switch(rm) {
case 2:
gen_op_fclex();
break;
case 3:
gen_op_fninit();
break;
default:
goto illegal_op;
}
break;
case 0x2a:
gen_op_fmov_STN_ST0(opreg);
break;
case 0x2b:
gen_op_fmov_STN_ST0(opreg);
gen_op_fpop();
break;
case 0x2c:
gen_op_fmov_FT0_STN(opreg);
gen_op_fucom_ST0_FT0();
break;
case 0x2d:
gen_op_fmov_FT0_STN(opreg);
gen_op_fucom_ST0_FT0();
gen_op_fpop();
break;
case 0x33:
switch(rm) {
case 1:
gen_op_fmov_FT0_STN(1);
gen_op_fcom_ST0_FT0();
gen_op_fpop();
gen_op_fpop();
break;
default:
goto illegal_op;
}
break;
case 0x3c:
switch(rm) {
case 0:
gen_op_fnstsw_EAX();
break;
default:
goto illegal_op;
}
break;
default:
goto illegal_op;
}
}
break;
case 0xa4:
case 0xa5:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (prefixes & PREFIX_REPZ) {
gen_op_movs[3 + ot]();
} else {
gen_op_movs[ot]();
}
break;
case 0xaa:
case 0xab:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (prefixes & PREFIX_REPZ) {
gen_op_stos[3 + ot]();
} else {
gen_op_stos[ot]();
}
break;
case 0xac:
case 0xad:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (prefixes & PREFIX_REPZ) {
gen_op_lods[3 + ot]();
} else {
gen_op_lods[ot]();
}
break;
case 0xae:
case 0xaf:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (prefixes & PREFIX_REPNZ) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_scas[6 + ot]();
s->cc_op = CC_OP_DYNAMIC;
} else if (prefixes & PREFIX_REPZ) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_scas[3 + ot]();
s->cc_op = CC_OP_DYNAMIC;
} else {
gen_op_scas[ot]();
s->cc_op = CC_OP_SUBB + ot;
}
break;
case 0xa6:
case 0xa7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (prefixes & PREFIX_REPNZ) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_cmps[6 + ot]();
s->cc_op = CC_OP_DYNAMIC;
} else if (prefixes & PREFIX_REPZ) {
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_cmps[3 + ot]();
s->cc_op = CC_OP_DYNAMIC;
} else {
gen_op_cmps[ot]();
s->cc_op = CC_OP_SUBB + ot;
}
break;
case 0x6c:
case 0x6d:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (prefixes & PREFIX_REPZ) {
gen_op_ins[3 + ot]();
} else {
gen_op_ins[ot]();
}
break;
case 0x6e:
case 0x6f:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
if (prefixes & PREFIX_REPZ) {
gen_op_outs[3 + ot]();
} else {
gen_op_outs[ot]();
}
break;
case 0xe4:
case 0xe5:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
val = ldub(s->pc++);
gen_op_movl_T0_im(val);
gen_op_in[ot]();
gen_op_mov_reg_T1[ot][R_EAX]();
break;
case 0xe6:
case 0xe7:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
val = ldub(s->pc++);
gen_op_movl_T0_im(val);
gen_op_mov_TN_reg[ot][1][R_EAX]();
gen_op_out[ot]();
break;
case 0xec:
case 0xed:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg[OT_WORD][0][R_EDX]();
gen_op_in[ot]();
gen_op_mov_reg_T1[ot][R_EAX]();
break;
case 0xee:
case 0xef:
if ((b & 1) == 0)
ot = OT_BYTE;
else
ot = dflag ? OT_LONG : OT_WORD;
gen_op_mov_TN_reg[OT_WORD][0][R_EDX]();
gen_op_mov_TN_reg[ot][1][R_EAX]();
gen_op_out[ot]();
break;
case 0xc2:
val = ldsw(s->pc);
s->pc += 2;
gen_pop_T0(s);
if (s->ss32)
gen_op_addl_ESP_im(val + (2 << s->dflag));
else
gen_op_addw_ESP_im(val + (2 << s->dflag));
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
s->is_jmp = 1;
break;
case 0xc3:
gen_pop_T0(s);
gen_pop_update(s);
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
s->is_jmp = 1;
break;
case 0xca:
val = ldsw(s->pc);
s->pc += 2;
gen_pop_T0(s);
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_pop_update(s);
gen_pop_T0(s);
gen_movl_seg_T0(s, R_CS);
gen_pop_update(s);
if (s->ss32)
gen_op_addl_ESP_im(val + (2 << s->dflag));
else
gen_op_addw_ESP_im(val + (2 << s->dflag));
s->is_jmp = 1;
break;
case 0xcb:
gen_pop_T0(s);
if (s->dflag == 0)
gen_op_andl_T0_ffff();
gen_op_jmp_T0();
gen_pop_update(s);
gen_pop_T0(s);
gen_movl_seg_T0(s, R_CS);
gen_pop_update(s);
s->is_jmp = 1;
break;
case 0xe8:
{
unsigned int next_eip;
ot = dflag ? OT_LONG : OT_WORD;
val = insn_get(s, ot);
next_eip = s->pc - s->cs_base;
val += next_eip;
if (s->dflag == 0)
val &= 0xffff;
gen_op_movl_T0_im(next_eip);
gen_push_T0(s);
gen_op_jmp_im(val);
s->is_jmp = 1;
}
break;
case 0x9a:
{
unsigned int selector, offset;
ot = dflag ? OT_LONG : OT_WORD;
offset = insn_get(s, ot);
selector = insn_get(s, OT_WORD);
gen_op_movl_T0_seg(R_CS);
gen_push_T0(s);
next_eip = s->pc - s->cs_base;
gen_op_movl_T0_im(next_eip);
gen_push_T0(s);
gen_op_movl_T0_im(selector);
gen_movl_seg_T0(s, R_CS);
gen_op_jmp_im((unsigned long)offset);
s->is_jmp = 1;
}
break;
case 0xe9:
ot = dflag ? OT_LONG : OT_WORD;
val = insn_get(s, ot);
val += s->pc - s->cs_base;
if (s->dflag == 0)
val = val & 0xffff;
gen_op_jmp_im(val);
s->is_jmp = 1;
break;
case 0xea:
{
unsigned int selector, offset;
ot = dflag ? OT_LONG : OT_WORD;
offset = insn_get(s, ot);
selector = insn_get(s, OT_WORD);
gen_op_movl_T0_im(selector);
gen_movl_seg_T0(s, R_CS);
gen_op_jmp_im((unsigned long)offset);
s->is_jmp = 1;
}
break;
case 0xeb:
val = (int8_t)insn_get(s, OT_BYTE);
val += s->pc - s->cs_base;
if (s->dflag == 0)
val = val & 0xffff;
gen_op_jmp_im(val);
s->is_jmp = 1;
break;
case 0x70 ... 0x7f:
val = (int8_t)insn_get(s, OT_BYTE);
goto do_jcc;
case 0x180 ... 0x18f:
if (dflag) {
val = insn_get(s, OT_LONG);
} else {
val = (int16_t)insn_get(s, OT_WORD);
}
do_jcc:
next_eip = s->pc - s->cs_base;
val += next_eip;
if (s->dflag == 0)
val &= 0xffff;
gen_jcc(s, b, val, next_eip);
s->is_jmp = 1;
break;
case 0x190 ... 0x19f:
modrm = ldub(s->pc++);
gen_setcc(s, b);
gen_ldst_modrm(s, modrm, OT_BYTE, OR_TMP0, 1);
break;
case 0x140 ... 0x14f:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
gen_setcc(s, b);
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T1_A0[ot]();
} else {
rm = modrm & 7;
gen_op_mov_TN_reg[ot][1][rm]();
}
gen_op_cmov_reg_T1_T0[ot - OT_WORD][reg]();
break;
case 0x9c:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_movl_T0_eflags();
gen_push_T0(s);
break;
case 0x9d:
gen_pop_T0(s);
gen_op_movl_eflags_T0();
gen_pop_update(s);
s->cc_op = CC_OP_EFLAGS;
break;
case 0x9e:
gen_op_mov_TN_reg[OT_BYTE][0][R_AH]();
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_movb_eflags_T0();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x9f:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_movl_T0_eflags();
gen_op_mov_reg_T0[OT_BYTE][R_AH]();
break;
case 0xf5:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_cmc();
s->cc_op = CC_OP_EFLAGS;
break;
case 0xf8:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_clc();
s->cc_op = CC_OP_EFLAGS;
break;
case 0xf9:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_stc();
s->cc_op = CC_OP_EFLAGS;
break;
case 0xfc:
gen_op_cld();
break;
case 0xfd:
gen_op_std();
break;
case 0x1ba:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
op = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
rm = modrm & 7;
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
gen_op_ld_T0_A0[ot]();
} else {
gen_op_mov_TN_reg[ot][0][rm]();
}
val = ldub(s->pc++);
gen_op_movl_T1_im(val);
if (op < 4)
goto illegal_op;
op -= 4;
gen_op_btx_T0_T1_cc[ot - OT_WORD][op]();
s->cc_op = CC_OP_SARB + ot;
if (op != 0) {
if (mod != 3)
gen_op_st_T0_A0[ot]();
else
gen_op_mov_reg_T0[ot][rm]();
}
break;
case 0x1a3:
op = 0;
goto do_btx;
case 0x1ab:
op = 1;
goto do_btx;
case 0x1b3:
op = 2;
goto do_btx;
case 0x1bb:
op = 3;
do_btx:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
reg = (modrm >> 3) & 7;
mod = (modrm >> 6) & 3;
rm = modrm & 7;
gen_op_mov_TN_reg[OT_LONG][1][reg]();
if (mod != 3) {
gen_lea_modrm(s, modrm, ®_addr, &offset_addr);
if (ot == OT_WORD)
gen_op_add_bitw_A0_T1();
else
gen_op_add_bitl_A0_T1();
gen_op_ld_T0_A0[ot]();
} else {
gen_op_mov_TN_reg[ot][0][rm]();
}
gen_op_btx_T0_T1_cc[ot - OT_WORD][op]();
s->cc_op = CC_OP_SARB + ot;
if (op != 0) {
if (mod != 3)
gen_op_st_T0_A0[ot]();
else
gen_op_mov_reg_T0[ot][rm]();
}
break;
case 0x1bc:
case 0x1bd:
ot = dflag ? OT_LONG : OT_WORD;
modrm = ldub(s->pc++);
reg = (modrm >> 3) & 7;
gen_ldst_modrm(s, modrm, ot, OR_TMP0, 0);
gen_op_bsx_T0_cc[ot - OT_WORD][b & 1]();
gen_op_mov_reg_T0[ot][reg]();
s->cc_op = CC_OP_LOGICB + ot;
break;
case 0x27:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_daa();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x2f:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_das();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x37:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_aaa();
s->cc_op = CC_OP_EFLAGS;
break;
case 0x3f:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_aas();
s->cc_op = CC_OP_EFLAGS;
break;
case 0xd4:
val = ldub(s->pc++);
gen_op_aam(val);
s->cc_op = CC_OP_LOGICB;
break;
case 0xd5:
val = ldub(s->pc++);
gen_op_aad(val);
s->cc_op = CC_OP_LOGICB;
break;
case 0x90:
break;
case 0xcc:
gen_op_int3((long)pc_start);
s->is_jmp = 1;
break;
case 0xcd:
val = ldub(s->pc++);
gen_op_int_im((long)pc_start);
s->is_jmp = 1;
break;
case 0xce:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_into((long)pc_start, (long)s->pc);
s->is_jmp = 1;
break;
case 0x1c8 ... 0x1cf:
reg = b & 7;
gen_op_mov_TN_reg[OT_LONG][0][reg]();
gen_op_bswapl_T0();
gen_op_mov_reg_T0[OT_LONG][reg]();
break;
case 0xd6:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
gen_op_salc();
break;
case 0xe0:
case 0xe1:
if (s->cc_op != CC_OP_DYNAMIC)
gen_op_set_cc_op(s->cc_op);
case 0xe2:
case 0xe3:
val = (int8_t)insn_get(s, OT_BYTE);
next_eip = s->pc - s->cs_base;
val += next_eip;
if (s->dflag == 0)
val &= 0xffff;
gen_op_loop[s->aflag][b & 3](val, next_eip);
s->is_jmp = 1;
break;
case 0x131:
gen_op_rdtsc();
break;
#if 0
case 0x1a2:
gen_insn0(OP_ASM);
break;
#endif
default:
goto illegal_op;
}
if (s->prefix & PREFIX_LOCK)
gen_op_unlock();
return (long)s->pc;
illegal_op:
return -1;
}
| 1threat |
c system function gets before other strings : <p>i am trying to write a simple c program that prints the C compiler version. so i wrote:</p>
<pre><code>#include <stdio.h>
int main() {
printf("you have %d", system("gcc --version");
}
</code></pre>
<p>the output:</p>
<pre><code>gcc (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
you have compiler 0
</code></pre>
<p>any idea?</p>
| 0debug |
Jest: Difference betwen --runInBand and --maxWorkers 1 : <p>When is it appropriate to use each of <code>--runInBand</code> or <code>--maxWorkers 1</code> options?</p>
<p>If my intent is to run all tests in sequence (one at a time, in order), which of these is the right option?</p>
<hr>
<p>Extra detail:</p>
<p>I'm using Jest to test a NodeJs <code>express</code> application, with integration tests hitting the HTTP endpoints via <code>supertest</code>. This may not make any difference to the answer, just mentioning in case it is relevant.</p>
<p>Here's the Jest CLI reference: </p>
<p><a href="https://facebook.github.io/jest/docs/cli.html" rel="noreferrer">https://facebook.github.io/jest/docs/cli.html</a></p>
<p>Relevant parts:</p>
<p><code>--maxWorkers=<num></code></p>
<p>Alias: -w. Specifies the maximum number of workers the worker-pool will spawn for running tests. This defaults to the number of the cores available on your machine. It may be useful to adjust this in resource limited environments like CIs but the default should be adequate for most use-cases.</p>
<p><code>--runInBand</code></p>
<p>Alias: -i. Run all tests serially in the current process, rather than creating a worker pool of child processes that run tests. This can be useful for debugging.</p>
| 0debug |
C# Error : " is a namespace but is used like a variable " : error : when iam trying to call language folder the next message appear as error message , "WebApplication5.language is a namespace but is used like a variable"
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/fYOPd.png | 0debug |
abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size)
{
void *ptr, *prev;
abi_ulong addr;
int wrapped, repeat;
if (start == 0) {
start = mmap_next_start;
} else {
start &= qemu_host_page_mask;
}
size = HOST_PAGE_ALIGN(size);
if (RESERVED_VA) {
return mmap_find_vma_reserved(start, size);
}
addr = start;
wrapped = repeat = 0;
prev = 0;
for (;; prev = ptr) {
ptr = mmap(g2h(addr), size, PROT_NONE,
MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0);
if (ptr == MAP_FAILED) {
return (abi_ulong)-1;
}
repeat = (ptr == prev ? repeat + 1 : 0);
if (h2g_valid(ptr + size - 1)) {
addr = h2g(ptr);
if ((addr & ~TARGET_PAGE_MASK) == 0) {
if (start == mmap_next_start && addr >= TASK_UNMAPPED_BASE) {
mmap_next_start = addr + size;
}
return addr;
}
switch (repeat) {
case 0:
addr = TARGET_PAGE_ALIGN(addr);
break;
case 1:
addr &= TARGET_PAGE_MASK;
break;
case 2:
addr = 0;
break;
default:
addr = -1;
break;
}
} else {
addr = (repeat ? -1 : 0);
}
munmap(ptr, size);
if (addr == -1ul) {
return (abi_ulong)-1;
} else if (addr == 0) {
if (wrapped) {
return (abi_ulong)-1;
}
wrapped = 1;
addr = (mmap_min_addr > TARGET_PAGE_SIZE
? TARGET_PAGE_ALIGN(mmap_min_addr)
: TARGET_PAGE_SIZE);
} else if (wrapped && addr >= start) {
return (abi_ulong)-1;
}
}
}
| 1threat |
static uint32_t virtio_console_get_features(VirtIODevice *vdev)
{
return 0;
}
| 1threat |
static void mark_request_serialising(BdrvTrackedRequest *req, uint64_t align)
{
int64_t overlap_offset = req->offset & ~(align - 1);
unsigned int overlap_bytes = ROUND_UP(req->offset + req->bytes, align)
- overlap_offset;
if (!req->serialising) {
req->bs->serialising_in_flight++;
req->serialising = true;
}
req->overlap_offset = MIN(req->overlap_offset, overlap_offset);
req->overlap_bytes = MAX(req->overlap_bytes, overlap_bytes);
}
| 1threat |
How is the following output coming??what is the value of '2'? : I tried running this program but I never understood how this result turned up...I tried to add the ASCII value of B to 2 and that would have made the output 68 but the actual answer is completely different....
char a = 'B',b='2'; into c= a+b; System.out.println(c);.
Output:116
I don't understand how is this even coming?? | 0debug |
void vnc_flush(VncState *vs)
{
vnc_lock_output(vs);
if (vs->csock != -1 && (vs->output.offset
#ifdef CONFIG_VNC_WS
|| vs->ws_output.offset
#endif
)) {
vnc_client_write_locked(vs);
}
vnc_unlock_output(vs);
}
| 1threat |
Python: Rotate Block of Text : <p>Let's say we have the following (but actually on a much larger scale):</p>
<pre><code>ABCDEF
GHIJKL
MNOPQR
</code></pre>
<p>Is there a way to rotate it to read as the following:</p>
<pre><code>FLR
DKQ
DJP
CIO
BHN
AGM
</code></pre>
<p>I wouldn't know where to start on account of it being Monday morning. Thanks,</p>
<p>JJ</p>
| 0debug |
static int bdrv_qed_check(BlockDriverState *bs, BdrvCheckResult *result)
{
BDRVQEDState *s = bs->opaque;
return qed_check(s, result, false);
}
| 1threat |
Merge array where same key : <pre><code>I have following 2 arrays:
$arr1 = [
0 => [
'id' => 1,
'name' => 'Peter',
],
1 => [
'id' => 2,
'name' => 'John',
]
]
$arr2 = [
0 => [
'id' => 1,
'surname' => 'Newman',
],
1 => [
'id' => 2,
'surname' => 'Cena',
]
]
</code></pre>
<p>What I want to do is merge these arrays referencing on the same key. In this case I would like to merge them where the <code>id</code> is matching. So the output I would expect would be:</p>
<pre><code>$finalArr = [
0 => [
'id' => 1,
'name' => 'Peter',
'surname' => 'Newman',
],
1 => [
'id' => 2,
'name' => 'John',
'surname' => 'Cena',
]
]
</code></pre>
<p>I am using laravel but the language should not matter too much. I would like to use <code>collections</code> if possible.</p>
| 0debug |
Propagate HTTP header (JWT Token) over services using spring rest template : <p>I have a microservice architecture, both of them securized by spring security an JWT tokens.</p>
<p>So, when I call my first microservice, I want to take the JWT token and send a request to another service using those credentials.</p>
<p>How can I retrieve the token and sent again to the other service?</p>
| 0debug |
static void qed_aio_write_alloc(QEDAIOCB *acb, size_t len)
{
BDRVQEDState *s = acb_to_s(acb);
if (acb != QSIMPLEQ_FIRST(&s->allocating_write_reqs)) {
QSIMPLEQ_INSERT_TAIL(&s->allocating_write_reqs, acb, next);
}
if (acb != QSIMPLEQ_FIRST(&s->allocating_write_reqs)) {
return;
}
acb->cur_nclusters = qed_bytes_to_clusters(s,
qed_offset_into_cluster(s, acb->cur_pos) + len);
acb->cur_cluster = qed_alloc_clusters(s, acb->cur_nclusters);
qemu_iovec_copy(&acb->cur_qiov, acb->qiov, acb->qiov_offset, len);
if (qed_should_set_need_check(s)) {
s->header.features |= QED_F_NEED_CHECK;
qed_write_header(s, qed_aio_write_prefill, acb);
} else {
qed_aio_write_prefill(acb, 0);
}
}
| 1threat |
PyLint not recognizing cv2 members : <p>I am running pylint on an opencv project and I am getting many pylint errors in VS code about members not being present.</p>
<p>Example code:</p>
<pre><code>import cv2
cv2.imshow(....)
</code></pre>
<p>Errors obtained: </p>
<p><a href="https://i.stack.imgur.com/4Kbdh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4Kbdh.png" alt="enter image description here"></a></p>
<p>However , the code runs correctly without any errors.</p>
<p>Versions : pylint 1.8.1 , astroid 1.6.0</p>
| 0debug |
jquery $(this).css(); is producing Uncaught TypeError: Cannot read property 'defaultView' of undefined : I have a the below code where I would like to check the id of an element. but when i put
$(this).attr("Id");
it returned "undefined". So I checked with
.css("width");
and it returns: Uncaught TypeError: Cannot read property 'defaultView' of undefined.
Below is my code:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
function create_login_dialog()
{
$(this).on("click",function(){
element_id = $(this).css("width");
if(element_id=="#login")
{
var login_dialog = "<form id='login_dialog' method='post' action=''></form>";
$("body").append(login_dialog);
console.log("logindialog is working");
}
else
{
console.log(element_id);
}
});
console.log("loginquery.js is working");
}
<!-- language: lang-html -->
<div id="login">the login div</div>
<!-- end snippet -->
Please point me what's wrong with this! | 0debug |
Instagram /v1/tags/{tag-name}/media/recent endpoint doesn't return min_tag_id in pagination block : <p>According to <a href="https://www.instagram.com/developer/endpoints/tags/">https://www.instagram.com/developer/endpoints/tags/</a>, we used to get the <strong>min_tag_id</strong> in the pagination part of the <a href="https://api.instagram.com/v1/tags/tag-name/media/recent?access_token=ACCESS-TOKEN">https://api.instagram.com/v1/tags/tag-name/media/recent?access_token=ACCESS-TOKEN</a> response which we then used in the request to poll for newer posts.</p>
<p>As of this morning, we saw that Instagram changed the form of the pagination response. It now looks something like: </p>
<pre><code>"pagination": {
"next_max_tag_id": "AQBy529IMOAlOvp6EI5zrYZRZbUbNW2oGQjgdvfVi5I_7wTIKzqE2nfsSBHvCkPmWOMKV7kmNcMPErenGJsbDtIk013aPZ_xo4vFYuXqtDGz3ZS0ZBrnTSjtuGjtnEOHiDJlAp8lI99AuwAgObnaf6tYhkoiDajEkg5E2zOFuDZFfQ",
"next_url": "https://api.instagram.com/v1/tags/enplug/media/recent?access_token=1573931388.852f6fb.2ee7fb644c5341dd813bd3bbc4c687ec&max_tag_id=AQBy529IMOAlOvp6EI5zrYZRZbUbNW2oGQjgdvfVi5I_7wTIKzqE2nfsSBHvCkPmWOMKV7kmNcMPErenGJsbDtIk013aPZ_xo4vFYuXqtDGz3ZS0ZBrnTSjtuGjtnEOHiDJlAp8lI99AuwAgObnaf6tYhkoiDajEkg5E2zOFuDZFfQ",
"deprecation_warning": "next_max_id and min_id are deprecated for this endpoint; use min_tag_id and max_tag_id instead",
"next_max_id": "AQBy529IMOAlOvp6EI5zrYZRZbUbNW2oGQjgdvfVi5I_7wTIKzqE2nfsSBHvCkPmWOMKV7kmNcMPErenGJsbDtIk013aPZ_xo4vFYuXqtDGz3ZS0ZBrnTSjtuGjtnEOHiDJlAp8lI99AuwAgObnaf6tYhkoiDajEkg5E2zOFuDZFfQ"
}
</code></pre>
<p>Is <strong>min_tag_id</strong> now deprecated? The developer docs don't mention anything about this. </p>
| 0debug |
cp -R: create special files rather than copying them as normal files : <p>Reading up on <code>cp -R</code>, what do these mean:</p>
<ul>
<li><code>create special files rather than copying them as normal files</code></li>
<li><code>Created directories have the same mode as the corresponding source directory, unmodified by the process' umask</code></li>
</ul>
<p>I assume by mode they mean for example <code>0755</code>.</p>
| 0debug |
Error on java indexOf in android : <p>in a block of my java code for an android project I'm trying to get position of a character in a string but application closes unexpectedly.</p>
<p>java code :</p>
<pre><code> public void onClickGet(View v){
String getInput = editText.getText().toString();
if(getInput.contains("(") ) {
//inputEx(getInput);
int a = getInput.indexOf("(");
Toast.makeText(getApplicationContext(),a,Toast.LENGTH_LONG).show();
}
</code></pre>
| 0debug |
sdl2 - ImportError: DLL load failed: The specified module could not be found and [CRITICAL] [App] Unable to get a Window, abort : <ul>
<li>Python: 3.6.4</li>
<li>OS: Windows 10</li>
<li>Kivy: 1.10.0</li>
</ul>
<h3>Kivy Installation Method</h3>
<pre><code>python -m pip install --upgrade pip wheel setuptools
python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew
python -m pip install kivy.deps.gstreamer
python -m pip install kivy.deps.angle
python -m pip install kivy
python -m pip install kivy_examples
python -m pip install Pillow
python -m pip install cython
python -m pip install PyEnchant
</code></pre>
<h3>Description</h3>
<p>Hi, I am trying to run the example code from the install Kivy. The following is the error I receive back. Any help would be great. I have tried looking at previous enquiries about similar problems, but nothing suggested on them has worked so far. </p>
<pre><code>[INFO ] [Logger ] Record log in C:\Users\DoddJ\.kivy\logs\kivy_18-03-26_52.txt
[INFO ] [Kivy ] v1.10.0
[INFO ] [Python ] v3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
[INFO ] [Factory ] 194 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_pil, img_gif (img_sdl2, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: pil(['text_sdl2'] ignored)
[CRITICAL] [Window ] Unable to find any valuable Window provider.
sdl2 - ImportError: DLL load failed: The specified module could not be found.
File "C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\core\window\window_sdl2.py", line 26, in <module>
from kivy.core.window._window_sdl2 import _WindowSDL2Storage
[CRITICAL] [App ] Unable to get a Window, abort.
Exception ignored in: 'kivy.properties.dpi2px'
Traceback (most recent call last):
File "C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\utils.py", line 496, in __get__
retval = self.func(inst)
File "C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\metrics.py", line 174, in dpi
EventLoop.ensure_window()
File "C:\Users\dev.DoddJ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\kivy\base.py", line 127, in ensure_window
sys.exit(1)
SystemExit: 1
[CRITICAL] [App ] Unable to get a Window, abort.
</code></pre>
<h3>Code and Logs</h3>
<p>Code that I am trying to run:</p>
<pre><code>import kivy
kivy.require('1.10.0') # replace with your current kivy version !
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text='Hello world')
if __name__ == '__main__':
MyApp().run()
</code></pre>
| 0debug |
is protected accessible to other classes other than the sub classes? : <p>So I know this is a beginner question, but I got confused, because from what I understand is that protected is only accessible to sub-classes / classes that extend the super class .. <strong>but I'm working on a project and weirdly enough, I was able to access a protected instance variable from class A , in class B (class B does not extend class A).</strong>
Can someone please explain this?</p>
| 0debug |
Can a progressive web app be registered as a share option in Android? : <p>Total newbie question.</p>
<p>Tl;dr - Can a progressive web app be registered as a share option in Android?</p>
<p>In Android, we can “Share” things to other installed Android apps. For example, let’s say I have Chrome for Android and the Google+ app installed on my Android device. I can share a web site which I am viewing in Chrome to Google+ by going to Chrome’s hamburger menu → Share… → Google+ (with a list of other installed native apps). Can a progressive web app be registered in this list of installed native apps?
If yes, can you show me some examples or code labs?
If no, is this feature in progressive web app or Android’s roadmap?</p>
| 0debug |
static MegasasCmd *megasas_enqueue_frame(MegasasState *s,
target_phys_addr_t frame, uint64_t context, int count)
{
MegasasCmd *cmd = NULL;
int frame_size = MFI_FRAME_SIZE * 16;
target_phys_addr_t frame_size_p = frame_size;
cmd = megasas_next_frame(s, frame);
if (!cmd) {
return NULL;
}
if (!cmd->pa) {
cmd->pa = frame;
cmd->frame = cpu_physical_memory_map(frame, &frame_size_p, 0);
if (frame_size_p != frame_size) {
trace_megasas_qf_map_failed(cmd->index, (unsigned long)frame);
if (cmd->frame) {
cpu_physical_memory_unmap(cmd->frame, frame_size_p, 0, 0);
cmd->frame = NULL;
cmd->pa = 0;
}
s->event_count++;
return NULL;
}
cmd->pa_size = frame_size_p;
cmd->context = context;
if (!megasas_use_queue64(s)) {
cmd->context &= (uint64_t)0xFFFFFFFF;
}
}
cmd->count = count;
s->busy++;
trace_megasas_qf_enqueue(cmd->index, cmd->count, cmd->context,
s->reply_queue_head, s->busy);
return cmd;
}
| 1threat |
Ruby Array .delete : I'm having an issue with the .delete command for ruby arrays.
I am defining a method that has two arguments (an array and a string) and trying to delete the string from the array.
The test is not passing and here is what I have so far:
def using_delete(instructors, x="Steven")
instructors = ["Josh", "Steven", "Sophie", "Steven", "Amanda", "Steven"]
instructors.delete ("Steven"
instructors
end
The test has to show that all instances of "Steven" have been deleted.
Thanks for your help. | 0debug |
How to undo setting Elasticsearch Index to readonly? : <p>So I just set one of my indices to readonly, and now want to delete it.</p>
<p>To set it to readonly:</p>
<pre><code>PUT my_index/_settings
{ "index": { "index.blocks.read_only" : true } }
</code></pre>
<p>When I tried to delete it I got this response:</p>
<pre><code>ClusterBlockException[blocked by: [FORBIDDEN/5/index read-only (api)];]
</code></pre>
<p>Then I tried to set the index to readonly false:</p>
<pre><code>PUT my_index/_settings
{ "index": { "index.blocks.read_only" : false } }
</code></pre>
<p>But that gives the same error message as above. So how to set readonly back to false?</p>
| 0debug |
Can't find the difference why one code works and other shows runtime error? : The code is for the question [SPREAD2][1] asked in the snackdown'19 qualifier round. As the contest is over so I want to clarify why [this code][2] shows runtime error while doing it with while loop in [this code][3] works perfectly fine. Please help.
[1]: https://www.codechef.com/SNCKQL19/problems/SPREAD2
[2]: https://www.codechef.com/viewsolution/20871155
[3]: https://www.codechef.com/viewsolution/20871904 | 0debug |
"Code Cleanup..." feature of Android Studio v2.2.2 : <p>In Android Studio v2.2.2, <strong>Code Cleanup</strong> feature available under <code>Analyze</code> option.</p>
<pre><code>Analyze >> Code Cleanup
</code></pre>
<p>What this option exactly do with code ?</p>
<p>Please explain in details.</p>
| 0debug |
static uint32_t dp8393x_readb(void *opaque, target_phys_addr_t addr)
{
uint16_t v = dp8393x_readw(opaque, addr & ~0x1);
return (v >> (8 * (addr & 0x1))) & 0xff;
}
| 1threat |
How to get Sum of Group in last row of group in SQL SERVER : Here is Example.
ID Prod --- Price <br>
01 Vios --- 150<br>
01 Vios ----120<br>
02 Copax --100<br>
02 Copax --200<br>
Desire Result should be
ID Prod ---Price Total<br>
01 Vios -- 150 -- 0<br>
01 Vios -- 120 -- 270<br>
02 Copax 100 ---0<br>
02 Copax 200 ---300<br>
| 0debug |
Type casting within a template in Angular 2 : <p>I'm working on an Angular project (Angular 4.0.0) and I'm having trouble binding a property of an abstract class to ngModel because I first need to cast it as the concrete class it actually is in order to access the property.</p>
<p>i.e. I have an AbstractEvent class this has a a concrete implementation Event which has a boolean property 'acknowledged' which I need a two way binding via ngModel to set with a checkbox.</p>
<p>I currently have this element in my DOM:</p>
<pre><code><input type="checkbox" *ngIf="event.end" [(ngModel)]="(event as Event).acknowledged"
[disabled]="(event as Event).acknowledged">
</code></pre>
<p>Unfortunately this is throwing the following error:</p>
<blockquote>
<p>Uncaught Error: Template parse errors:
Parser Error: Missing expected ) at column 8 in [(event as Event).acknowledged]</p>
</blockquote>
<p>Googling around seemed to suggest this might be because using 'as' is not supported when using it inside a template? Although I'm not certain about this.</p>
<p>I also can't work out how to just write a function for it in my typescript file driving the template because this would break the two way binding on ngModel that I require.</p>
<p>If anyone has any way to get around this or perform type casting in angular templates correctly I would be very appreciative! </p>
| 0debug |
how to avoid the or neglect the retriving image while inserting into the phpmyadmin in php : hi guys i am new to php and i am getting Could not retrieve image: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax but i dont want to retrive the image i want avoid it so..so how to fix it... thank you in advance
if(!isset($_SESSION["username"])){
header("location:index.php");
}
if(!empty($_SESSION['uid'])){$uidval=$_SESSION['uid'];}
$uidval="";
if((isset($_GET['user_avatar']))&&(!empty($_GET['user_avatar']))){
$user_avatar = $_GET['user_avatar'];
}
$getImage=mysqli_query($db, "SELECT user_avatar FROM user where
uid=".$uidval) or die("Could not retrieve image: " .mysqli_error($db));
$path=mysqli_fetch_assoc($getImage) or die("Could not fetch array : "
.mysqli_error($db));
| 0debug |
Javascript - print all names in array containing multiple objects : <p>So I'm new to javascript and programming in general and I have an array of objects below. I'm trying to generate and print an array containing the full names of students (first and last name separated by “ “) of all students who received an exam grade of 80 or higher. Sort of in the format like [ 'James Johnson', 'Stephanie Ottesen', 'Leonard Arvan', 'Beverly Mott', 'Beatrice Jaco' ].</p>
<p>I made a separate array already but I'm having trouble figuring out how to access only certain objects in an array and add them to my new array. From googling, I've come across the .map(), .reduce(), and .filter() methods but I'm struggling to figure out how to take these methods and format them into my program. Any help or references would be appreciated.</p>
<pre><code>let students = [{fname: "Jane", lname: "Brazier", snum: "100366942", agrade: 67.59127376966494, tgrade: 64.86530868914188, egrade: 70.52944558104066}, {fname: "Ricardo", lname: "Allen", snum: "100345641", agrade: 65.80370345301014, tgrade: 75.40211705841241, egrade: 55.39348896202821}, {fname: "Mary", lname: "Hernandez", snum: "100221207", agrade: 71.20761408935981, tgrade: 71.37529197926764, egrade: 75.82038980457698}, {fname: "James", lname: "Johnson", snum: "100200842", agrade: 72.5791318299902, tgrade: 81.65883679807183, egrade: 85.19664228946989}, {fname: "Stephanie", lname: "Ottesen", snum: "100225067", agrade: 88.19738810849226, tgrade: 84.68339894849353, egrade: 82.23947265645927}, {fname: "Martin", lname: "Conway", snum: "100358379", agrade: 71.28759059295344, tgrade: 79.13194908266965, egrade: 77.61880623797336}, {fname: "Andrew", lname: "Weaver", snum: "100376243", agrade: 70.01798139244363, tgrade: 78.64811561086252, egrade: 78.68650242850617}, {fname: "Rhonda", lname: "Ford", snum: "100296902", agrade: 56.14580882764524, tgrade: 63.9209865108888, egrade: 60.186613967770334}, {fname: "Leonard", lname: "Arvan", snum: "100220616", agrade: 80.67865525396981, tgrade: 92.73557717342663, egrade: 88.32126970338336}, {fname: "William", lname: "Culler", snum: "100307637", agrade: 65.75251699043244, tgrade: 62.18172136246404, egrade: 63.065185542933094}, {fname: "David", lname: "Nakasone", snum: "100353719", agrade: 62.63260239883763, tgrade: 58.352794766947866, egrade: 59.80461902691901}, {fname: "Maria", lname: "Young", snum: "100311331", agrade: 70.13767021264486, tgrade: 76.09348747016176, egrade: 79.99207130929622}, {fname: "Beverly", lname: "Mott", snum: "100325579", agrade: 83.08140516644137, tgrade: 94.80666640692787, egrade: 85.15875656837004}, {fname: "Patrick", lname: "Francis", snum: "100257773", agrade: 66.79534616079296, tgrade: 47.744928296560076, egrade: 64.05723052865763}, {fname: "Tracy", lname: "Bonds", snum: "100233277", agrade: 70.2289028670531, tgrade: 65.32258294210156, egrade: 77.04816321925091}, {fname: "Richard", lname: "Akers", snum: "100216705", agrade: 52.446722363991015, tgrade: 49.205597783687374, egrade: 53.72940974941982}, {fname: "Beatrice", lname: "Jaco", snum: "100233935", agrade: 81.89338938644417, tgrade: 71.05459078971688, egrade: 83.08235397281308}, {fname: "Guy", lname: "Wendelin", snum: "100336379", agrade: 68.17788319655493, tgrade: 63.82273085525137, egrade: 68.31559946786807}, {fname: "Logan", lname: "Olsen", snum: "100265736", agrade: 59.89037739094347, tgrade: 71.76550299333657, egrade: 64.61665695830132}, {fname: "Gene", lname: "Jeanlouis", snum: "100341666", agrade: 74.16481515505846, tgrade: 68.20592386917109, egrade: 78.25975050135006}]
let studentNames = [];
</code></pre>
| 0debug |
How can I make image as background? App keeps crashing : <p>I want to make image/picture as background but using <code>android:background="#ffff"</code> makes it white and it works. As soon as I change to <code>android:background="@drawable/background_image"</code> and run it, crash.</p>
| 0debug |
static ssize_t mp_pacl_getxattr(FsContext *ctx, const char *path,
const char *name, void *value, size_t size)
{
char buffer[PATH_MAX];
return lgetxattr(rpath(ctx, path, buffer), MAP_ACL_ACCESS, value, size);
}
| 1threat |
How to deploy angular-cli app on iis : <p>I have simple angular2-cli app (one page with model driven form - no router involved). With "ng serve" all works fine. I made production version with ng build --product. I copied all ./dist folder content into new folder under C:\inetpub\wwwroot. I made virtual app from IIS managment console. Defualt app file is index.html. I browse to app uri and i get only page with "Loading...". I try build without --product switch (only ng build) but result is the same. Angular app is not loading. Is there anything else needed to publish angular app on IIS?</p>
| 0debug |
static void display_mouse_set(DisplayChangeListener *dcl,
int x, int y, int on)
{
SimpleSpiceDisplay *ssd = container_of(dcl, SimpleSpiceDisplay, dcl);
qemu_mutex_lock(&ssd->lock);
ssd->ptr_x = x;
ssd->ptr_y = y;
if (ssd->ptr_move) {
g_free(ssd->ptr_move);
}
ssd->ptr_move = qemu_spice_create_cursor_update(ssd, NULL, on);
qemu_mutex_unlock(&ssd->lock);
}
| 1threat |
static void icount_dummy_timer(void *opaque)
{
(void)opaque;
}
| 1threat |
create DOMs programmatically : <p>After calling an API, I can get an array of data.
For example, I can get a list of objects, each object contains 1 unique id, 1 author, 1 article, 1 picture...etc.</p>
<p>I created the div template already. There are many div and bootstrap classes inside.</p>
<pre><code> <div class="col-sm-4" id="test">
<div class="box" style="padding-bottom: 10px;">
<div class="row">
<div class="col-xs-12">
<div class="col-xs-12">
<video class ="col-xs-12" controls>
<source src="../data.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
<div class="col-xs-12" style="margin-top: 10px;">
<div class="col-xs-12" style="margin-top: 5px">
<div class="avatar col-xs-2">
<img src="../data.jpg">
</div>
<div class="col-xs-6">
<p class="pull-left"> data(Author) </p>
</div>
<div class="col-xs-2">
<button>data</button>
</div>
<div class="col-xs-2" style="padding: 0">
<button>data</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</code></pre>
<p>I want to create DOMs that represent each object, and style them using bootstrap and css. How do I put the corresponding data in the corresponding places on the template above?</p>
<p>Also, there are buttons inside the root div that associate with the unique id with the root div. The buttons has comments function. When the button is onclick, the article id (unique) will be sent to the API and thus the corresponding comments will be displayed. </p>
<p>Thanks in advance.</p>
| 0debug |
Geopandas ImportError: The descartes package is required for plotting polygons in geopandas : <p>I'am trying to run a simple geopandas code using ANACONDA spyder. However, I'am encountering an error.</p>
<p>I have included the code and the error as below:</p>
<p>--</p>
<p>here is the code:</p>
<pre><code>import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.plot()
import matplotlib.pyplot as plt
plt.show()
</code></pre>
<p>--</p>
<p>here is the error:</p>
<p>File "C:\Users\usr\Anaconda3\lib\site-packages\geopandas\plotting.py", line 90, in plot_polygon_collection
"The descartes package is required for plotting polygons in geopandas."</p>
<p>ImportError: The descartes package is required for plotting polygons in geopandas.</p>
<p>--</p>
<p>I checked online and I couldn't find troubleshooting solution for this problem. Can anyone please help and advise?</p>
<p>appreciated.</p>
| 0debug |
Python module workday() : The python module workday() has an inconvenient input format:
workday(date(year=2009,month=12,day=28),10,[date(year=2009,month=12,day=29)])
I would prefer to input the dates as 2009,12,28.
My holiday.xlsx list is read in as entries with: datetime.datetime(2016, 5, 1, 0, 0).
Thus I am trying to figure out how to align this format to work with the workday()
Any advice would be well received. | 0debug |
void qerror_print(QError *qerror)
{
QString *qstring = qerror_human(qerror);
loc_push_restore(&qerror->loc);
error_report("%s", qstring_get_str(qstring));
loc_pop(&qerror->loc);
QDECREF(qstring);
}
| 1threat |
query = 'SELECT * FROM customers WHERE email = ' + email_input | 1threat |
how to convert date in the format (2017-10-05) to the format in which date is saved in mongodb using java (spring ) : @GetMapping("/{dateFrom}/{dateTo}")
public List<com.example.demo.attendance> getRange(@PathVariable("dateFrom") String dateFrom,@PathVariable("dateTo") String dateTo) throws ParseException{
Date date1= new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(dateFrom);
Date date2= new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(dateTo);
System.out.println(date1);
System.out.println(date2);
List<com.example.demo.attendance> att = this.attRepo.findDateBetween(date1,date2);
return att;
} ` | 0debug |
Is This A Single Page Website or Separate Web Pages : I am wondering if this is a single page website or 3 separate web pages. The urls are, index.aspx?page=home, index.aspx?page=about, index.aspx?page=team. I need to know for google analytics purposes. Thank you. | 0debug |
static inline void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc)
{
int addr_reg, data_reg, data_reg2, bswap;
#ifdef CONFIG_SOFTMMU
int mem_index, s_bits;
# if TARGET_LONG_BITS == 64
int addr_reg2;
# endif
uint32_t *label_ptr;
#endif
#ifdef TARGET_WORDS_BIGENDIAN
bswap = 1;
#else
bswap = 0;
#endif
data_reg = *args++;
if (opc == 3)
data_reg2 = *args++;
else
data_reg2 = 0;
addr_reg = *args++;
#ifdef CONFIG_SOFTMMU
# if TARGET_LONG_BITS == 64
addr_reg2 = *args++;
# endif
mem_index = *args;
s_bits = opc & 3;
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
TCG_REG_R8, 0, addr_reg, SHIFT_IMM_LSR(TARGET_PAGE_BITS));
tcg_out_dat_imm(s, COND_AL, ARITH_AND,
TCG_REG_R0, TCG_REG_R8, CPU_TLB_SIZE - 1);
tcg_out_dat_reg(s, COND_AL, ARITH_ADD, TCG_REG_R0,
TCG_AREG0, TCG_REG_R0, SHIFT_IMM_LSL(CPU_TLB_ENTRY_BITS));
if (mem_index)
tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R0, TCG_REG_R0,
(mem_index << (TLB_SHIFT & 1)) |
((16 - (TLB_SHIFT >> 1)) << 8));
tcg_out_ld32_12(s, COND_AL, TCG_REG_R1, TCG_REG_R0,
offsetof(CPUState, tlb_table[0][0].addr_write));
tcg_out_dat_reg(s, COND_AL, ARITH_CMP, 0, TCG_REG_R1,
TCG_REG_R8, SHIFT_IMM_LSL(TARGET_PAGE_BITS));
if (s_bits)
tcg_out_dat_imm(s, COND_EQ, ARITH_TST,
0, addr_reg, (1 << s_bits) - 1);
# if TARGET_LONG_BITS == 64
tcg_out_ld32_12(s, COND_EQ, TCG_REG_R1, TCG_REG_R0,
offsetof(CPUState, tlb_table[0][0].addr_write) + 4);
tcg_out_dat_reg(s, COND_EQ, ARITH_CMP, 0,
TCG_REG_R1, addr_reg2, SHIFT_IMM_LSL(0));
# endif
tcg_out_ld32_12(s, COND_EQ, TCG_REG_R1, TCG_REG_R0,
offsetof(CPUState, tlb_table[0][0].addend));
switch (opc) {
case 0:
tcg_out_st8_r(s, COND_EQ, data_reg, addr_reg, TCG_REG_R1);
break;
case 1:
if (bswap) {
tcg_out_bswap16(s, COND_EQ, TCG_REG_R0, data_reg);
tcg_out_st16_r(s, COND_EQ, TCG_REG_R0, addr_reg, TCG_REG_R1);
} else {
tcg_out_st16_r(s, COND_EQ, data_reg, addr_reg, TCG_REG_R1);
}
break;
case 2:
default:
if (bswap) {
tcg_out_bswap32(s, COND_EQ, TCG_REG_R0, data_reg);
tcg_out_st32_r(s, COND_EQ, TCG_REG_R0, addr_reg, TCG_REG_R1);
} else {
tcg_out_st32_r(s, COND_EQ, data_reg, addr_reg, TCG_REG_R1);
}
break;
case 3:
if (bswap) {
tcg_out_bswap32(s, COND_EQ, TCG_REG_R0, data_reg2);
tcg_out_st32_rwb(s, COND_EQ, TCG_REG_R0, TCG_REG_R1, addr_reg);
tcg_out_bswap32(s, COND_EQ, TCG_REG_R0, data_reg);
tcg_out_st32_12(s, COND_EQ, data_reg, TCG_REG_R1, 4);
} else {
tcg_out_st32_rwb(s, COND_EQ, data_reg, TCG_REG_R1, addr_reg);
tcg_out_st32_12(s, COND_EQ, data_reg2, TCG_REG_R1, 4);
}
break;
}
label_ptr = (void *) s->code_ptr;
tcg_out_b(s, COND_EQ, 8);
if (addr_reg != TCG_REG_R0) {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
TCG_REG_R0, 0, addr_reg, SHIFT_IMM_LSL(0));
}
# if TARGET_LONG_BITS == 32
switch (opc) {
case 0:
tcg_out_ext8u(s, COND_AL, TCG_REG_R1, data_reg);
tcg_out_dat_imm(s, COND_AL, ARITH_MOV, TCG_REG_R2, 0, mem_index);
break;
case 1:
tcg_out_ext16u(s, COND_AL, TCG_REG_R1, data_reg);
tcg_out_dat_imm(s, COND_AL, ARITH_MOV, TCG_REG_R2, 0, mem_index);
break;
case 2:
if (data_reg != TCG_REG_R1) {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
TCG_REG_R1, 0, data_reg, SHIFT_IMM_LSL(0));
}
tcg_out_dat_imm(s, COND_AL, ARITH_MOV, TCG_REG_R2, 0, mem_index);
break;
case 3:
if (data_reg != TCG_REG_R1) {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
TCG_REG_R1, 0, data_reg, SHIFT_IMM_LSL(0));
}
if (data_reg2 != TCG_REG_R2) {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
TCG_REG_R2, 0, data_reg2, SHIFT_IMM_LSL(0));
}
tcg_out_dat_imm(s, COND_AL, ARITH_MOV, TCG_REG_R3, 0, mem_index);
break;
}
# else
if (addr_reg2 != TCG_REG_R1) {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
TCG_REG_R1, 0, addr_reg2, SHIFT_IMM_LSL(0));
}
switch (opc) {
case 0:
tcg_out_ext8u(s, COND_AL, TCG_REG_R2, data_reg);
tcg_out_dat_imm(s, COND_AL, ARITH_MOV, TCG_REG_R3, 0, mem_index);
break;
case 1:
tcg_out_ext16u(s, COND_AL, TCG_REG_R2, data_reg);
tcg_out_dat_imm(s, COND_AL, ARITH_MOV, TCG_REG_R3, 0, mem_index);
break;
case 2:
if (data_reg != TCG_REG_R2) {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
TCG_REG_R2, 0, data_reg, SHIFT_IMM_LSL(0));
}
tcg_out_dat_imm(s, COND_AL, ARITH_MOV, TCG_REG_R3, 0, mem_index);
break;
case 3:
tcg_out_dat_imm(s, COND_AL, ARITH_MOV, TCG_REG_R8, 0, mem_index);
tcg_out32(s, (COND_AL << 28) | 0x052d8010);
if (data_reg != TCG_REG_R2) {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
TCG_REG_R2, 0, data_reg, SHIFT_IMM_LSL(0));
}
if (data_reg2 != TCG_REG_R3) {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV,
TCG_REG_R3, 0, data_reg2, SHIFT_IMM_LSL(0));
}
break;
}
# endif
tcg_out_bl(s, COND_AL, (tcg_target_long) qemu_st_helpers[s_bits] -
(tcg_target_long) s->code_ptr);
# if TARGET_LONG_BITS == 64
if (opc == 3)
tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R13, TCG_REG_R13, 0x10);
# endif
*label_ptr += ((void *) s->code_ptr - (void *) label_ptr - 8) >> 2;
#else
if (GUEST_BASE) {
uint32_t offset = GUEST_BASE;
int i;
int rot;
while (offset) {
i = ctz32(offset) & ~1;
rot = ((32 - i) << 7) & 0xf00;
tcg_out_dat_imm(s, COND_AL, ARITH_ADD, TCG_REG_R1, addr_reg,
((offset >> i) & 0xff) | rot);
addr_reg = TCG_REG_R1;
offset &= ~(0xff << i);
}
}
switch (opc) {
case 0:
tcg_out_st8_12(s, COND_AL, data_reg, addr_reg, 0);
break;
case 1:
if (bswap) {
tcg_out_bswap16(s, COND_AL, TCG_REG_R0, data_reg);
tcg_out_st16_8(s, COND_AL, TCG_REG_R0, addr_reg, 0);
} else {
tcg_out_st16_8(s, COND_AL, data_reg, addr_reg, 0);
}
break;
case 2:
default:
if (bswap) {
tcg_out_bswap32(s, COND_AL, TCG_REG_R0, data_reg);
tcg_out_st32_12(s, COND_AL, TCG_REG_R0, addr_reg, 0);
} else {
tcg_out_st32_12(s, COND_AL, data_reg, addr_reg, 0);
}
break;
case 3:
if (bswap) {
tcg_out_bswap32(s, COND_AL, TCG_REG_R0, data_reg2);
tcg_out_st32_12(s, COND_AL, TCG_REG_R0, addr_reg, 0);
tcg_out_bswap32(s, COND_AL, TCG_REG_R0, data_reg);
tcg_out_st32_12(s, COND_AL, TCG_REG_R0, addr_reg, 4);
} else {
tcg_out_st32_12(s, COND_AL, data_reg, addr_reg, 0);
tcg_out_st32_12(s, COND_AL, data_reg2, addr_reg, 4);
}
break;
}
#endif
}
| 1threat |
What is the real alternative of read_stream to read facebook news feeds? : <p>What is the real alternative of read_stream to read the news feeds from Facebook ?
The answer is usually users_posts , but can the latter fetch the news feeds ? - for instance like the suggested posts on the timeline -</p>
<p>In other words I am trying to know if there is a way through the new Graph API to pull ads like what we used to do with FQL and read_stream.</p>
| 0debug |
PHP Get last increment of five minutes : <p>I am looking to get the previous increment of five minutes from the current time...</p>
<p>Lets say that the current time is 12:07pm UTC</p>
<p>I want to put into a variable 12:05pm UTC</p>
<p>What would be an easy way of going about this?</p>
| 0debug |
Warning in install.packages: cannot open UR HTTP status was '404 Not Found' : <p>When running <code>install.packages</code> in the latest R (3.4) and RStudio 1.0.143 I get the following warning</p>
<pre><code>Warning in install.packages :
cannot open URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.4/PACKAGES.rds': HTTP status was '404 Not Found'
</code></pre>
<p>This appears no matter what package(s) I select, however this does not appear to effect package installation. I tried clearing my <code>~/.rstudio-desktop</code>, <code>/Library/Frameworks/R.framework/Versions/3.4/Resources/library</code> and reinstalling R and this warning still persists. Evening changing CRAN mirrors appears to have no effect as a similar warning appears. Below is my session information.</p>
<pre><code>R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.4
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] datasets stats graphics grDevices utils methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.0 tools_3.4.0
</code></pre>
| 0debug |
What is the relationship between System Class and PrintStream Class? : **System class** is situated at 'java.lang.System' and **PrintStream class** is situated at 'java.io.PrintStream' .They are at different packages.But How System Class uses PrintStream class to declare Object 'Out' of type PrintStream ?. Does System class imports PrintStream class to use it . | 0debug |
What is "Keys" in Certificates, Identifiers & Profiles section of Apple Dev center : <p>Today I noticed a new section named "Keys." I don't know which services uses this? Anybody have any idea? Or I'm the beta user to see this?</p>
<p><a href="https://i.stack.imgur.com/5tqZJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5tqZJ.png" alt="Screenshot of Dev Center"></a></p>
| 0debug |
Why does calling n^2 for numbers in a range produce the results out of order? : <pre><code>>>> nums = {n**2 for n in range(10)}
>>> nums
{0, 1, 64, 4, 36, 9, 16, 49, 81, 25}
</code></pre>
<p>I dont get why the numbers are out of order? Should it not be {0, 1, 4, 9...}?</p>
| 0debug |
How to install packages in Linux (CentOS) without root user with automatic dependency handling? : <p>Is it possible to use RPM or YUM or any other package manager in Linux, specifically CentOS, to install a package either already downloaded or from repo to a custom location without admin/root access?</p>
<p>I tried building from sources, using cmake, configure, make, make install etc, but, it ended up having so many dependencies one after other.</p>
<p>Or are there any better alternatives?</p>
| 0debug |
CreateThread() does not work : <p>I am trying to create a thread using the winapi's CreateThread() function, but it doesnt work. No errors at all</p>
<pre><code>void Inc::init() {
DWORD id;
HANDLE hnd = CreateThread(NULL,0,asd,this,0,&id);
}
DWORD Inc::asd(LPVOID lparam) {
Inc* g = (Inc*)lparam;
printf("asd");
}
</code></pre>
<p>asd() doesn't get executed at all</p>
| 0debug |
How to split Redux actions into multiple files : <p>I have an actions folder with the usual types.js file for my action type constants, plus an index.js file that does the following</p>
<pre><code>import axios from 'axios';
import { browserHistory } from 'react-router';
import {
AUTH_USER,
UNAUTH_USER,
AUTH_ERROR,
FETCH_MESSAGE
} from './types';
</code></pre>
<p>and also exports functions for all my actions. I'm wondering, is there a way I can create multiple files for defining my actions so index.js doesn't become too long, then import those into my index.js so in my components I can still just do for example <code>import { loginUser } from '../../actions';</code> and not have to worry about which file the action is coming from?</p>
| 0debug |
How to Find Neighboring States through State Zip code information in R : <p>I want to find the neighboring states for a given particular state in US through its zip code information in R, can anyone please help me on how to go ahead with it?</p>
<p>thanks in advance!</p>
| 0debug |
SQL query ORDER BY with DESC LIMIT 1 and WHERE clause : Trying to create a query that gets the most recent record related to the user. Here's my attempt
"SELECT *
FROM (
SELECT *
FROM simplex_list
ORDER BY id
DESC LIMIT 1)
WHERE userid = $userID"; | 0debug |
print all the permutaions using recursion : I coded as below to print all the permutaions of three number :1,2,3.
<i><b>But the output is:</b></i><br>
1,1,1<br>
1,1,2<br>
1,1,3<br>
1,2,1<br>
1,2,2<br>
1,2,3<br>
<b><i>the code is as follows:</i></b>
#include<stdio.h>
#include<conio.h>
void perm(int);
int a[10],l=2;
int main()
{int k;
k=0;
perm(k);
getch();
return 0;}
void perm(int k)
{
int i;
for(a[k]=1;a[k]<=3;a[k]++)
{
if(k==2)
{
for(i=0;i<3;i++)
{
printf("%d ",a[i]);
}
printf("\n");
}
else
{
k++;
perm(k);
}
}
}
Pl. give the correct code:) | 0debug |
Regex repating string : i need a Regex for the following Text.
I already tried many stuff, but always it only match the last two groups or it match 'someText 1 & someText 2 & someText 3 &' as one group...
someText 1 & someText 2 & someText 3
someText 1 & someText 2 & someText 3 & someText 4
What i expect are two matches :
Match 1:
- someText 1
- someText 2
- someText 3
and
Match 2:
- someText 1
- someText 2
- someText 3
- someText 4
greetings,
False
| 0debug |
How to check if folder is empty with Python? : <p>I am trying to check if a folder is empty and do the following:</p>
<pre><code>import os
downloadsFolder = '../../Downloads/'
if not os.listdir(downloadsFolder):
print "empty"
else:
print "not empty"
</code></pre>
<p>Unfortunately, I always get "not empty" no matter if I have any files in that folder or not. Is it because there might be some hidden system files? Is there a way to modify the above code to check just for not hidden files?</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.