problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static int aio_write_f(int argc, char **argv)
{
int nr_iov, c;
int pattern = 0xcd;
struct aio_ctx *ctx = calloc(1, sizeof(struct aio_ctx));
while ((c = getopt(argc, argv, "CqP:")) != EOF) {
switch (c) {
case 'C':
ctx->Cflag = 1;
break;
case 'q':
ctx->qflag = 1;
break;
case 'P':
pattern = parse_pattern(optarg);
if (pattern < 0) {
free(ctx);
return 0;
}
break;
default:
free(ctx);
return command_usage(&aio_write_cmd);
}
}
if (optind > argc - 2) {
free(ctx);
return command_usage(&aio_write_cmd);
}
ctx->offset = cvtnum(argv[optind]);
if (ctx->offset < 0) {
printf("non-numeric length argument -- %s\n", argv[optind]);
free(ctx);
return 0;
}
optind++;
if (ctx->offset & 0x1ff) {
printf("offset %" PRId64 " is not sector aligned\n",
ctx->offset);
free(ctx);
return 0;
}
nr_iov = argc - optind;
ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, pattern);
if (ctx->buf == NULL) {
free(ctx);
return 0;
}
gettimeofday(&ctx->t1, NULL);
bdrv_aio_writev(bs, ctx->offset >> 9, &ctx->qiov,
ctx->qiov.size >> 9, aio_write_done, ctx);
return 0;
}
| 1threat
|
Show Exact Value Using Formula Field in Crystal Repory : I am trying to show value using formula field in crystal report.
Such as "7209.9462" which datatype is Decimal(18,4).
But now I want show value only with three digit after decimal .... like "7209.946" with out rounding it.
So how can I achieve this ?
| 0debug
|
if we change the date in sql where clause it is not giving correct output, why? : select * from emp where hiredate > '15-11-81' this query is executing and giving correct output , but this select * from emp where hiredate > '01-01-11' query is not giving correct output .Y?
| 0debug
|
static int mmu_translate_region(CPUS390XState *env, target_ulong vaddr,
uint64_t asc, uint64_t entry, int level,
target_ulong *raddr, int *flags, int rw,
bool exc)
{
CPUState *cs = CPU(s390_env_get_cpu(env));
uint64_t origin, offs, new_entry;
const int pchks[4] = {
PGM_SEGMENT_TRANS, PGM_REG_THIRD_TRANS,
PGM_REG_SEC_TRANS, PGM_REG_FIRST_TRANS
};
PTE_DPRINTF("%s: 0x%" PRIx64 "\n", __func__, entry);
origin = entry & _REGION_ENTRY_ORIGIN;
offs = (vaddr >> (17 + 11 * level / 4)) & 0x3ff8;
new_entry = ldq_phys(cs->as, origin + offs);
PTE_DPRINTF("%s: 0x%" PRIx64 " + 0x%" PRIx64 " => 0x%016" PRIx64 "\n",
__func__, origin, offs, new_entry);
if ((new_entry & _REGION_ENTRY_INV) != 0) {
DPRINTF("%s: invalid region\n", __func__);
trigger_page_fault(env, vaddr, PGM_SEGMENT_TRANS, asc, rw, exc);
return -1;
}
if ((new_entry & _REGION_ENTRY_TYPE_MASK) != level) {
trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw, exc);
return -1;
}
if (level == _ASCE_TYPE_SEGMENT) {
return mmu_translate_segment(env, vaddr, asc, new_entry, raddr, flags,
rw, exc);
}
offs = (vaddr >> (28 + 11 * (level - 4) / 4)) & 3;
if (offs < ((new_entry & _REGION_ENTRY_TF) >> 6)
|| offs > (new_entry & _REGION_ENTRY_LENGTH)) {
DPRINTF("%s: invalid offset or len (%lx)\n", __func__, new_entry);
trigger_page_fault(env, vaddr, pchks[level / 4 - 1], asc, rw, exc);
return -1;
}
return mmu_translate_region(env, vaddr, asc, new_entry, level - 4,
raddr, flags, rw, exc);
}
| 1threat
|
Using self and parameters in a Python Script : <p>I'd like to use self (for global variables) and the parameters from the command-line in my Python Script but can't really get them to work.</p>
<pre><code>def otherFunction(self)
print self.tecE
def main(argv,self):
self.tecE = 'test'
otherFunction()
if __name__ == "__main__":
main(sys.argv[1:],self)
</code></pre>
<p>This gives me an error:</p>
<pre><code> main(sys.argv[1:],self)
NameError: name 'self' is not defined
</code></pre>
<p>So how and where to define <code>self</code>? </p>
| 0debug
|
static struct omap_mpu_timer_s *omap_mpu_timer_init(MemoryRegion *system_memory,
hwaddr base,
qemu_irq irq, omap_clk clk)
{
struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *)
g_malloc0(sizeof(struct omap_mpu_timer_s));
s->irq = irq;
s->clk = clk;
s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_timer_tick, s);
s->tick = qemu_bh_new(omap_timer_fire, s);
omap_mpu_timer_reset(s);
omap_timer_clk_setup(s);
memory_region_init_io(&s->iomem, NULL, &omap_mpu_timer_ops, s,
"omap-mpu-timer", 0x100);
memory_region_add_subregion(system_memory, base, &s->iomem);
return s;
}
| 1threat
|
Find Numbers with eight digits starting with specific number ranges : <p>I need a regex to find all eight digit Numbers that starts wit any number in the following ranges:
20-31
40-42
50-53
60-61
71
81
91-93</p>
<p>How is that done?</p>
<p>/Therese</p>
| 0debug
|
Separate lines in a text file : <p>I have a .txt file. Containing INSERT Scripts. </p>
<pre><code>INSERT INTO TABLE (COL1, COL2, COL3) VALUES (1, 2, 3)
INSERT INTO TABLE (COL1, COL2, COL3) VALUES (1, 2, 3)
INSERT INTO TABLE (COL1, COL2, COL3) VALUES (1, 2, 3)
INSERT INTO TABLE (COL1, COL2, COL3) VALUES (1, 2, 3)
INSERT INTO TABLE (COL1, COL2, COL3) VALUES (1, 2, 3) INSERT INTO TABLE (COL1, COL2, COL3) VALUES (1, 2, 3)
and so on...
</code></pre>
<p>I want to read this file and output each INSERT statement separately.
There could be a possibility that a INSERT script is not separated by a new line. it could be continued in the same line. As it can be seen for the last INSERT script. </p>
<p>So I wanted to know if I can read this text file and separate each line whenever I find a new 'INSERT' word ? </p>
| 0debug
|
Why does my program repeat forever instead of giving the maximum integer value? : <p>I am currently learning C, and I made a program that I thought would give me the maximum integer value, but it just loops forever. I can't find an answer as to why it won't end.</p>
<pre><code>#include <stdio.h>
int main()
{
unsigned int i = 0;
signed int j = i;
for(; i+1 == ++j; i++);
printf(i);
return 0;
}
</code></pre>
<p>Any help would be appreciated, thank you!</p>
| 0debug
|
How to truncate a decimal to 2 places? : <p>I have a value 100.0000. I need truncate it to only two decimal places like 100.00 I need to do it when it have 00's in 3rd and 4 places. How to do it??</p>
| 0debug
|
Difference between scope and authority in UAA : <p>In UAA There are two Concepts, Authority and Scope.</p>
<p>These concepts seems to overlap. I would like to know exact difference and purpose</p>
<p>For example , oauth.login</p>
| 0debug
|
In C++, why check negative number with "&1" : just ran into this question when I tried to refactor my code for a LeetCode problem. It's basically checking the sum of two integers is negative or not:
if(A+B<0)
This is how I would do it, where **A** is a positive integer no exceeding 1000 and **B** can be any 32-bit integer. However, I saw others whose performance is faster than mine does this:
if(A+B &1)
I could not explain this to myself and switching to the second version does bring a little improvement to my solution.
Can anyone explain a little bit? Any help would be appreciated.
Thanks
| 0debug
|
void ff_h264_v_lpf_chroma_inter_msa(uint8_t *data, int img_width,
int alpha, int beta, int8_t *tc)
{
uint8_t bs0 = 1;
uint8_t bs1 = 1;
uint8_t bs2 = 1;
uint8_t bs3 = 1;
if (tc[0] < 0)
bs0 = 0;
if (tc[1] < 0)
bs1 = 0;
if (tc[2] < 0)
bs2 = 0;
if (tc[3] < 0)
bs3 = 0;
avc_loopfilter_cb_or_cr_inter_edge_hor_msa(data,
bs0, bs1, bs2, bs3,
tc[0], tc[1], tc[2], tc[3],
alpha, beta,
img_width);
}
| 1threat
|
static void pcnet_transmit(PCNetState *s)
{
target_phys_addr_t xmit_cxda = 0;
int count = CSR_XMTRL(s)-1;
s->xmit_pos = -1;
if (!CSR_TXON(s)) {
s->csr[0] &= ~0x0008;
return;
}
s->tx_busy = 1;
txagain:
if (pcnet_tdte_poll(s)) {
struct pcnet_TMD tmd;
TMDLOAD(&tmd, PHYSADDR(s,CSR_CXDA(s)));
#ifdef PCNET_DEBUG_TMD
printf(" TMDLOAD 0x%08x\n", PHYSADDR(s,CSR_CXDA(s)));
PRINT_TMD(&tmd);
#endif
if (GET_FIELD(tmd.status, TMDS, STP)) {
s->xmit_pos = 0;
xmit_cxda = PHYSADDR(s,CSR_CXDA(s));
}
if (!GET_FIELD(tmd.status, TMDS, ENP)) {
int bcnt = 4096 - GET_FIELD(tmd.length, TMDL, BCNT);
s->phys_mem_read(s->dma_opaque, PHYSADDR(s, tmd.tbadr),
s->buffer + s->xmit_pos, bcnt, CSR_BSWP(s));
s->xmit_pos += bcnt;
} else if (s->xmit_pos >= 0) {
int bcnt = 4096 - GET_FIELD(tmd.length, TMDL, BCNT);
s->phys_mem_read(s->dma_opaque, PHYSADDR(s, tmd.tbadr),
s->buffer + s->xmit_pos, bcnt, CSR_BSWP(s));
s->xmit_pos += bcnt;
#ifdef PCNET_DEBUG
printf("pcnet_transmit size=%d\n", s->xmit_pos);
#endif
if (CSR_LOOP(s))
pcnet_receive(s, s->buffer, s->xmit_pos);
else
if (s->vc)
qemu_send_packet(s->vc, s->buffer, s->xmit_pos);
s->csr[0] &= ~0x0008;
s->csr[4] |= 0x0004;
s->xmit_pos = -1;
}
SET_FIELD(&tmd.status, TMDS, OWN, 0);
TMDSTORE(&tmd, PHYSADDR(s,CSR_CXDA(s)));
if (!CSR_TOKINTD(s) || (CSR_LTINTEN(s) && GET_FIELD(tmd.status, TMDS, LTINT)))
s->csr[0] |= 0x0200;
if (CSR_XMTRC(s)<=1)
CSR_XMTRC(s) = CSR_XMTRL(s);
else
CSR_XMTRC(s)--;
if (count--)
goto txagain;
} else
if (s->xmit_pos >= 0) {
struct pcnet_TMD tmd;
TMDLOAD(&tmd, PHYSADDR(s,xmit_cxda));
SET_FIELD(&tmd.misc, TMDM, BUFF, 1);
SET_FIELD(&tmd.misc, TMDM, UFLO, 1);
SET_FIELD(&tmd.status, TMDS, ERR, 1);
SET_FIELD(&tmd.status, TMDS, OWN, 0);
TMDSTORE(&tmd, PHYSADDR(s,xmit_cxda));
s->csr[0] |= 0x0200;
if (!CSR_DXSUFLO(s)) {
s->csr[0] &= ~0x0010;
} else
if (count--)
goto txagain;
}
s->tx_busy = 0;
}
| 1threat
|
Vue - check if you are on the last prop of a v-for loop : <p>If I have the following data property:</p>
<pre><code>person: {name: 'Joe', age: 35, department: 'IT'}
</code></pre>
<p>And wanted to loop through and output it as follows:</p>
<pre><code>name: Joe, age: 35, department: IT
</code></pre>
<p>So far I have:</p>
<pre><code><span v-for="(val, key) in person">{{key}}: {{val}}, </span>
</code></pre>
<p>But this displays:</p>
<pre><code>name: Joe, age: 35, department: IT,
</code></pre>
<p>with an extra comma on the end, how can I have it detect that it's the last prop and not show the comma? I thoughta v-show or v-if may be the solution but can't quite figure out how to make it work.</p>
| 0debug
|
How should I install Bootstrap? : <p>I learned two ways: Putting some links directly into your html file and installing a Bootstrap app using a terminal. What’s the difference between these two ways and witch is better?</p>
| 0debug
|
static void qvirtio_pci_set_status(QVirtioDevice *d, uint8_t status)
{
QVirtioPCIDevice *dev = (QVirtioPCIDevice *)d;
qpci_io_writeb(dev->pdev, dev->addr + VIRTIO_PCI_STATUS, status);
}
| 1threat
|
Programming language R: Create a function. This Function converts one matrix to another matrix such that every odd number are 3 times of that number : <p>[1 2] -->[3 2]<br>
[3 5] -->[9 15]</p>
<p>Please help me solve it. The above is an example(both are 2*2 matrices)</p>
| 0debug
|
No resource found that matches the given name: attr 'android:windowElevation : i instal new windows and then instal eclipse but when i create a new project its get error and i dont know what is it
workspace\appcompat_v7\res\values-v21\themes_base.xml:129: error: Error: No resource found that matches the given name: attr 'android:colorControlNormal'.
workspace\appcompat_v7\res\values-v21\themes_base.xml:130: error: Error: No resource found that matches the given name: attr 'android:colorControlActivated'.
\workspace\appcompat_v7\res\values-v21\themes_base.xml:81: error: Error: No resource found that matches the given name: attr 'android:colorPrimary'.
and all of theme in them_base .xml.
i several times change windows or instal eclipse into new labtop and it(eclipse) work fine. im not instal graphic driver is it important for this error?
| 0debug
|
How to open an external webpage on af:commandButton click in Oracle ADF? : How to open an external webpage on click of afcommandButton .
I need , on click of a button, a new tab will be opened with a pre-defined webpage address from database.
| 0debug
|
Phyton 3.5 "for loop" "enumerate()” Select Word from List : Hi I'm new here I've just started learning python
Individual words in wordList will be referred to as “word” as a variable.
who would I set this up this for a python english grammar gen program by the way.
also I wanna try to Enter a loop that repeats once for each word in wordList. Trying to use a for loop with “enumerate()” function but I keep getting stuck. Any help would be great.
print('Welcome to my English Test App')
# Import the random module to allow us to select the word list and questions at random.
import random
candidateWords = ['HELLO', 'GOODBYE', 'NAME', 'DAY', 'NIGHT', 'HOUR', 'POTATO', 'BIG', 'SMALL', 'GOOD', 'BAD', 'YES', 'NO', 'HOUSE', 'QUESTION', 'BALLOON', 'CAT', 'DUCK', 'PIGEON', 'POSTER', 'TELEVISION', 'SPY', 'RHYTHM', 'SUBSTANTIAL', 'SNOW', 'MAGNET', 'TOWEL', 'WALKING', 'SPEAKER', 'UNCHARACTERISTICALLY']
print (random.sample (candidateWords, 5))
# This function receives a word as a parameter and should return the number of vowels in the word.
def countVowels(word):
pass #
| 0debug
|
int vfio_spapr_create_window(VFIOContainer *container,
MemoryRegionSection *section,
hwaddr *pgsize)
{
int ret;
IOMMUMemoryRegion *iommu_mr = IOMMU_MEMORY_REGION(section->mr);
unsigned pagesize = memory_region_iommu_get_min_page_size(iommu_mr);
unsigned entries, pages;
struct vfio_iommu_spapr_tce_create create = { .argsz = sizeof(create) };
create.window_size = int128_get64(section->size);
create.page_shift = ctz64(pagesize);
entries = create.window_size >> create.page_shift;
pages = MAX((entries * sizeof(uint64_t)) / getpagesize(), 1);
pages = MAX(pow2ceil(pages) - 1, 1);
create.levels = ctz64(pages) / 6 + 1;
ret = ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &create);
if (ret) {
error_report("Failed to create a window, ret = %d (%m)", ret);
return -errno;
}
if (create.start_addr != section->offset_within_address_space) {
vfio_spapr_remove_window(container, create.start_addr);
error_report("Host doesn't support DMA window at %"HWADDR_PRIx", must be %"PRIx64,
section->offset_within_address_space,
(uint64_t)create.start_addr);
return -EINVAL;
}
trace_vfio_spapr_create_window(create.page_shift,
create.window_size,
create.start_addr);
*pgsize = pagesize;
return 0;
}
| 1threat
|
Conflicting type in C but no clear difference between lines : <p>I am trying to run a model written by someone else. When running the make file, I get the following error regarding one of the fonctions: </p>
<pre><code>ground_layer.c:4391:6: error: conflicting types for 'func_'
real func_(R_fp funk, real *x)
^
ground_layer.c:4360:17: note: previous declaration is here
extern real func_(U_fp, real *);
</code></pre>
<p>I feel like it must be a silly mistake, bu my C is really rusty at this point, and I just can't identify the error. I've tried removing all the differences: adding an <code>x</code> in the first definition, removing the <code>funk</code>, but those changes seem to only make things worse. </p>
<p>For info, I am on MacOSX 10.11. Here is the code from the definition till the end:</p>
<pre><code>/* Local variables */
static real a, b;
static integer j;
static real x;
static integer it;
static real del, tnm, sum, ddel;
extern real func_(U_fp, real *);
/* ********************************************************************** */
b = exp(-(*aa));
a = 0.f;
if (*n == 1) {
r__1 = (a + b) * .5f;
*s = (b - a) * func_((U_fp)funk, &r__1);
it = 1;
} else {
tnm = (real) it;
del = (b - a) / (tnm * 3.f);
ddel = del + del;
x = a + del * .5f;
sum = 0.f;
i__1 = it;
for (j = 1; j <= i__1; ++j) {
sum += func_((U_fp)funk, &x);
x += ddel;
sum += func_((U_fp)funk, &x);
x += del;
/* L11: */
}
*s = (*s + (b - a) * sum / tnm) / 3.f;
it *= 3;
}
return 0;
} /* midexp_ */
/* ********************************************************************** */
/* ********************************************************************** */
real func_(R_fp funk, real *x)
{
/* System generated locals */
real ret_val, r__1;
/* Builtin functions */
double log(doublereal);
/* ********************************************************************** */
r__1 = -log(*x);
ret_val = (*funk)(&r__1) / *x;
return ret_val;
} /* func_ */
</code></pre>
| 0debug
|
How to clarify whether the user's input was a binary number? : <p>I was required to make a code that accepted a binary number (1's and 0's) and then counted how many ones were in that binary number. My code fulfills this purpose. </p>
<p>The second part of the exercise is this: if the user enters a number that is NOT binary, I must output that there is an error and keep prompting the user until they give a binary number. </p>
<p>Can someone show me how to incorporate this? I have tried several times but cannot make it click. Thanks! Here is my code.</p>
<pre><code>import java.util.Scanner;
public class NewClass
{
public static void main( String [] args )
{
Scanner scan = new Scanner( System.in);
int i = 0, count = 0;
String number;
System.out.println("Please enter a binary number.");
number = scan.next();
String number1 = "1";
while ((i = number.indexOf(number1, i++)) != -1) {
count++;
i += number1.length();
}
System.out.println("There are "+ count + " ones in the binary number.");
}
</code></pre>
<p>}</p>
| 0debug
|
Gson custom deserializer just on field : <p>I use Volley with Gson.
I have a person object, I'd like to set gender, not a string, but an enum.
So I'd like to write a custom deserializer for just this field, and let Gson to do the rest.
How can I do that?</p>
| 0debug
|
static int dmg_open(BlockDriverState *bs, QDict *options, int flags,
Error **errp)
{
BDRVDMGState *s = bs->opaque;
uint64_t info_begin, info_end, last_in_offset, last_out_offset;
uint32_t count, tmp;
uint32_t max_compressed_size = 1, max_sectors_per_chunk = 1, i;
int64_t offset;
int ret;
bs->read_only = 1;
s->n_chunks = 0;
s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;
offset = bdrv_getlength(bs->file);
if (offset < 0) {
ret = offset;
offset -= 0x1d8;
ret = read_uint64(bs, offset, &info_begin);
if (ret < 0) {
} else if (info_begin == 0) {
ret = read_uint32(bs, info_begin, &tmp);
if (ret < 0) {
} else if (tmp != 0x100) {
ret = read_uint32(bs, info_begin + 4, &count);
if (ret < 0) {
} else if (count == 0) {
info_end = info_begin + count;
offset = info_begin + 0x100;
last_in_offset = last_out_offset = 0;
while (offset < info_end) {
uint32_t type;
ret = read_uint32(bs, offset, &count);
if (ret < 0) {
} else if (count == 0) {
offset += 4;
ret = read_uint32(bs, offset, &type);
if (ret < 0) {
if (type == 0x6d697368 && count >= 244) {
size_t new_size;
uint32_t chunk_count;
offset += 4;
offset += 200;
chunk_count = (count - 204) / 40;
new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count);
s->types = g_realloc(s->types, new_size / 2);
s->offsets = g_realloc(s->offsets, new_size);
s->lengths = g_realloc(s->lengths, new_size);
s->sectors = g_realloc(s->sectors, new_size);
s->sectorcounts = g_realloc(s->sectorcounts, new_size);
for (i = s->n_chunks; i < s->n_chunks + chunk_count; i++) {
ret = read_uint32(bs, offset, &s->types[i]);
if (ret < 0) {
offset += 4;
if (s->types[i] != 0x80000005 && s->types[i] != 1 &&
s->types[i] != 2) {
if (s->types[i] == 0xffffffff && i > 0) {
last_in_offset = s->offsets[i - 1] + s->lengths[i - 1];
last_out_offset = s->sectors[i - 1] +
s->sectorcounts[i - 1];
chunk_count--;
i--;
offset += 36;
continue;
offset += 4;
ret = read_uint64(bs, offset, &s->sectors[i]);
if (ret < 0) {
s->sectors[i] += last_out_offset;
offset += 8;
ret = read_uint64(bs, offset, &s->sectorcounts[i]);
if (ret < 0) {
offset += 8;
if (s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {
error_report("sector count %" PRIu64 " for chunk %u is "
"larger than max (%u)",
s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX);
ret = read_uint64(bs, offset, &s->offsets[i]);
if (ret < 0) {
s->offsets[i] += last_in_offset;
offset += 8;
ret = read_uint64(bs, offset, &s->lengths[i]);
if (ret < 0) {
offset += 8;
if (s->lengths[i] > max_compressed_size) {
max_compressed_size = s->lengths[i];
if (s->sectorcounts[i] > max_sectors_per_chunk) {
max_sectors_per_chunk = s->sectorcounts[i];
s->n_chunks += chunk_count;
s->compressed_chunk = g_malloc(max_compressed_size + 1);
s->uncompressed_chunk = g_malloc(512 * max_sectors_per_chunk);
if (inflateInit(&s->zstream) != Z_OK) {
s->current_chunk = s->n_chunks;
qemu_co_mutex_init(&s->lock);
return 0;
fail:
g_free(s->types);
g_free(s->offsets);
g_free(s->lengths);
g_free(s->sectors);
g_free(s->sectorcounts);
g_free(s->compressed_chunk);
g_free(s->uncompressed_chunk);
return ret;
| 1threat
|
get all occurence of substring between two chracters in java : <p>I have String Path like this </p>
<pre><code> "/Math/Math1/Algerbra/node"
</code></pre>
<p>how I can get all the occurence of substring between "/" and "/" to get (Math-Math1-Algerbra)</p>
<p>Thanks in advance</p>
| 0debug
|
Android Studio test between two emulators : <p>Okay so, I have two emulators running. I want to write a test where one device calls the other device using VOIP. My goal is to automate VOIP testing.</p>
<p>A <code>successCount</code> variable is defined inside the test class to validate whether the test was successful or not.</p>
<p>Steps I need to take in my test class:</p>
<ol>
<li>Login into the SIP server with device A.</li>
<li>Login into the SIP server with device B.</li>
<li>Device A calls device B (increase success count by 1).</li>
<li>Device B answers the call (increase success count by 1).</li>
<li>Device B hangsup after 5 seconds (increase success count by 1).</li>
<li>Assert that success count is equal to 3.</li>
</ol>
<p>Now the issue I have is the sequence of the steps on the devices. I need to tell device A to call device B after that device B has been logged into the SIP server for example. Currently I'm unable to accomplish this in an instrumented or unit test.</p>
<p>Does anyone know a solution to sequentially execute (unit/instrumented) test code in two device emulators in Android Studio? Is this even possible?</p>
| 0debug
|
passing a null password during exection of query in linux : how to pass a password during the execution of a query in Linux if the password is null;`MySQL -u root -p`
this asks the entry of the password every time while execution of the query
| 0debug
|
Android - set all lint warnings as errors except for certain ones : <p>I am trying to make my continuous integration fail the build when new lint warnings that aren't in the <code>lint-baseline.xml</code> file are introduced. I want to have all lint warnings treated as errors (so the build is aborted), but I'd like a way to specify certain lint checks to be treated as informational or warning level so that they still appear in the lint results, but don't cause the build to be aborted.</p>
<p>Here is an example of basically what I'd like to do (except this doesn't work, the build fails if any non-ignored warnings exist):</p>
<pre><code>lintOptions {
lintConfig file("lint.xml")
baseline file("lint-baseline.xml")
checkAllWarnings true
warningsAsErrors true
abortOnError true
informational 'MissingTranslation, ...' // don't fail the build for these
}
</code></pre>
<p>Is there an easy way to treat all lint checks as errors, excluding certain ones? I thought about manually setting all 200+ lint checks to the error level, but that wouldn't be very future proof, since I'd have to update the list every time new lint checks were added.</p>
| 0debug
|
static int qemu_rbd_snap_remove(BlockDriverState *bs,
const char *snapshot_name)
{
BDRVRBDState *s = bs->opaque;
int r;
r = rbd_snap_remove(s->image, snapshot_name);
return r;
}
| 1threat
|
static void vnc_dpy_update(DisplayChangeListener *dcl,
DisplayState *ds,
int x, int y, int w, int h)
{
int i;
VncDisplay *vd = ds->opaque;
struct VncSurface *s = &vd->guest;
int width = ds_get_width(ds);
int height = ds_get_height(ds);
h += y;
w += (x % 16);
x -= (x % 16);
x = MIN(x, width);
y = MIN(y, height);
w = MIN(x + w, width) - x;
h = MIN(h, height);
for (; y < h; y++)
for (i = 0; i < w; i += 16)
set_bit((x + i) / 16, s->dirty[y]);
}
| 1threat
|
Automating file Download from HTTPS server using CMD : So we have a client who has files placed on an HTTPS server. These are files are updated at least 2 times a day and will be a hectic process to manually download these files so our client wants us to automate this process. We had already automated files download from an ftp server using cmd but due to access restrictions our client can only use https. So are there any CMD commands that can help in automating this process?
| 0debug
|
segmantaion fault (core dumped) programming c : I was solving hackerrank problem given here : -- https://www.hackerrank.com/challenges/bigger-is-greater
Program statement is as follow :
" Given a word , rearrange the letters of to construct another word in such a way that is lexicographically greater than original one . In case of multiple possible answers, find the lexicographically smallest one among them. "
If you don't understand then just go to the link, they have explained with examples.
I made the program as given below. In this program i have made two dimensional array. And variable 't' decides number of row and column number is fix.
Code is running as it should be when t = 1;
But when t is greater than 1 or some large number it gives "segmentation error"
Code is as below :
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int i,j,n,rot;
int t;
scanf("%d",&t);
char c[t][100];
char temp;
for(int i=0;i<t;i++)
{
scanf(" %s",c[i]);
}
rot=t;
for(int t=0;t<rot;t++)
{
n = strlen(c[t]);
//printf("%d\n",n);
for(i=n-1;i>=0;i--)
{
for(j=i-1;j>=0;j--)
{
//printf("comparint %c and %c\n",c[t][i],c[t][j]); //FOR DEBUG
if(c[t][i]>c[t][j]) goto gotit;
}
}
printf("no answer\n");
continue;
gotit:
temp = c[t][i];
c[t][i]=c[t][j];
c[t][j]=temp;
n = (n-1)-j;
//printf("%s\n",c[t]); //FOR DEBUG
//printf("%d %d %d\n",i,j,n); //FOR DEBUG
for(i=0;i<n-1;i++)
{
for(int k=0;k<n-1;k++)
{
// printf("comparint %c and %c\n",c[t][j+k+1],c[t][j+k+2]);
if(c[t][j+k+1]>c[t][j+k+2] )
{
temp = c[t][j+k+1];
c[t][j+k+1]=c[t][j+k+2];
c[t][j+k+2]=temp;
}
}
}
printf("%s\n",c[t]);
}
return 0;
}
| 0debug
|
static void xen_pt_region_update(XenPCIPassthroughState *s,
MemoryRegionSection *sec, bool adding)
{
PCIDevice *d = &s->dev;
MemoryRegion *mr = sec->mr;
int bar = -1;
int rc;
int op = adding ? DPCI_ADD_MAPPING : DPCI_REMOVE_MAPPING;
struct CheckBarArgs args = {
.s = s,
.addr = sec->offset_within_address_space,
.size = int128_get64(sec->size),
.rc = false,
};
bar = xen_pt_bar_from_region(s, mr);
if (bar == -1 && (!s->msix || &s->msix->mmio != mr)) {
return;
}
if (s->msix && &s->msix->mmio == mr) {
if (adding) {
s->msix->mmio_base_addr = sec->offset_within_address_space;
rc = xen_pt_msix_update_remap(s, s->msix->bar_index);
}
return;
}
args.type = d->io_regions[bar].type;
pci_for_each_device(d->bus, pci_bus_num(d->bus),
xen_pt_check_bar_overlap, &args);
if (args.rc) {
XEN_PT_WARN(d, "Region: %d (addr: %#"FMT_PCIBUS
", len: %#"FMT_PCIBUS") is overlapped.\n",
bar, sec->offset_within_address_space,
int128_get64(sec->size));
}
if (d->io_regions[bar].type & PCI_BASE_ADDRESS_SPACE_IO) {
uint32_t guest_port = sec->offset_within_address_space;
uint32_t machine_port = s->bases[bar].access.pio_base;
uint32_t size = int128_get64(sec->size);
rc = xc_domain_ioport_mapping(xen_xc, xen_domid,
guest_port, machine_port, size,
op);
if (rc) {
XEN_PT_ERR(d, "%s ioport mapping failed! (err: %i)\n",
adding ? "create new" : "remove old", errno);
}
} else {
pcibus_t guest_addr = sec->offset_within_address_space;
pcibus_t machine_addr = s->bases[bar].access.maddr
+ sec->offset_within_region;
pcibus_t size = int128_get64(sec->size);
rc = xc_domain_memory_mapping(xen_xc, xen_domid,
XEN_PFN(guest_addr + XC_PAGE_SIZE - 1),
XEN_PFN(machine_addr + XC_PAGE_SIZE - 1),
XEN_PFN(size + XC_PAGE_SIZE - 1),
op);
if (rc) {
XEN_PT_ERR(d, "%s mem mapping failed! (err: %i)\n",
adding ? "create new" : "remove old", errno);
}
}
}
| 1threat
|
document.location = 'http://evil.com?username=' + user_input;
| 1threat
|
No Idea what the c# code for this is... can anyone help me with this? : Hey guys I got some homework a couple of weeks ago from school and most of the class didn't know how to do it... The teacher said he would go over it but he never ended up doing so even though I asked him a couple of times. I guess the class just moved on and forgot about it -- However we have a test tomorrow and I bet a question like this (question 4 and 5 in the picture) will be on the test. Someone please help me with the codes?
I managed to figure out the code for question four but It looks wrong:
private void button1_Click(object sender, EventArgs e)
{
string msg = "";
int i = 1;
while (i < 6)
{
int col = 0;
while (col < i)
{
msg += i;
col++;
}
msg += "\n";
i++;
}
MessageBox.Show(msg);
}
is there a simpler way to do it by using for and if statements? Question 5 I am completely lost.
[Homework Picture][1]
[1]: https://i.stack.imgur.com/pzFLe.png
| 0debug
|
IDE for ironpython on windows anno 2017 : <br>
I've developed stuff in Python in the past few years. Mostly I have used regular Python and tried Jython too but missed some important libraries. Eclipse has been my favourite IDE (version 4.3) all along with plugin PyDev (version 3.5).<br>
I now have reason to try IronPython. I tried using this combination also to develop for IronPython but windows keep popping up stating "IronPython Console has stopped working". Is my conclusion right that Eclipse is not the right tool for IronPython? BTW, my OS is Windows 7.
I had a look at this question and at the answers given there:
http://stackoverflow.com/questions/755883/ide-for-ironpython-on-windows
I fear that the answers given there are outdated or will soon be outdated, because they date back to 2009. I have Visual Studio 2008 (only) and I installed the shell integrated mode redistributable as well as IronPython Studio, but it was a bit rather complicated for me to get it to work, with too many things to download and install. Eventually I tried to run a "hello world" program in the IronPython Studio but got "FileLoadException was unhandled" error. Aaarg! Maybe I made a mistake somewhere?<br>
I also came across CodePlex websites that state that they will be shut down soon. So my question is: is IronPython also about to die? Or is it going to survive? If so, what IDEs are available in 2017 for developing against IronPython - preferably an open source IDE?
| 0debug
|
static double bessel(double x){
double lastv=0;
double t, v;
int i;
static const double inv[100]={
1.0/( 1* 1), 1.0/( 2* 2), 1.0/( 3* 3), 1.0/( 4* 4), 1.0/( 5* 5), 1.0/( 6* 6), 1.0/( 7* 7), 1.0/( 8* 8), 1.0/( 9* 9), 1.0/(10*10),
1.0/(11*11), 1.0/(12*12), 1.0/(13*13), 1.0/(14*14), 1.0/(15*15), 1.0/(16*16), 1.0/(17*17), 1.0/(18*18), 1.0/(19*19), 1.0/(20*20),
1.0/(21*21), 1.0/(22*22), 1.0/(23*23), 1.0/(24*24), 1.0/(25*25), 1.0/(26*26), 1.0/(27*27), 1.0/(28*28), 1.0/(29*29), 1.0/(30*30),
1.0/(31*31), 1.0/(32*32), 1.0/(33*33), 1.0/(34*34), 1.0/(35*35), 1.0/(36*36), 1.0/(37*37), 1.0/(38*38), 1.0/(39*39), 1.0/(40*40),
1.0/(41*41), 1.0/(42*42), 1.0/(43*43), 1.0/(44*44), 1.0/(45*45), 1.0/(46*46), 1.0/(47*47), 1.0/(48*48), 1.0/(49*49), 1.0/(50*50),
1.0/(51*51), 1.0/(52*52), 1.0/(53*53), 1.0/(54*54), 1.0/(55*55), 1.0/(56*56), 1.0/(57*57), 1.0/(58*58), 1.0/(59*59), 1.0/(60*60),
1.0/(61*61), 1.0/(62*62), 1.0/(63*63), 1.0/(64*64), 1.0/(65*65), 1.0/(66*66), 1.0/(67*67), 1.0/(68*68), 1.0/(69*69), 1.0/(70*70),
1.0/(71*71), 1.0/(72*72), 1.0/(73*73), 1.0/(74*74), 1.0/(75*75), 1.0/(76*76), 1.0/(77*77), 1.0/(78*78), 1.0/(79*79), 1.0/(80*80),
1.0/(81*81), 1.0/(82*82), 1.0/(83*83), 1.0/(84*84), 1.0/(85*85), 1.0/(86*86), 1.0/(87*87), 1.0/(88*88), 1.0/(89*89), 1.0/(90*90),
1.0/(91*91), 1.0/(92*92), 1.0/(93*93), 1.0/(94*94), 1.0/(95*95), 1.0/(96*96), 1.0/(97*97), 1.0/(98*98), 1.0/(99*99), 1.0/(10000)
};
x= x*x/4;
t = x;
v = 1 + x;
for(i=1; v != lastv; i+=2){
t *= x*inv[i];
v += t;
lastv=v;
t *= x*inv[i + 1];
v += t;
av_assert2(i<98);
}
return v;
}
| 1threat
|
What is the 'safe region' for iPhone X (in pixels) that factors the top notch and bottom bar? : <p>I have read the <a href="https://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x/" rel="noreferrer">Human Interface Guidelines for iPhone X</a> and it doesn't specifically state the 'safe region' (area which caters for both top notch and bottom bar on the iPhone X). I would like to know the pixel dimensions of this region, including the dimensions removed from the top and bottom.</p>
| 0debug
|
How to remove 'Warning: Async Storage has been extracted from react-native core...'? : <p>I've already tried what's recommended in this screenshot</p>
<p><a href="https://postimg.cc/3WvPFHc5" rel="noreferrer"><img src="https://i.postimg.cc/xjxnYfGC/Screenshot-20190323-081232.png" alt="Screenshot-20190323-081232.png"></a></p>
<p>by using this line of code
<code>import AsyncStorage from '../../../node_modules/@react-native-community/async-storage';</code> in the file where I'm importing <code>async-storage</code> from <code>react-native</code>
but this path is unresolved, i.e. <code>async-storage</code> doesn't exist in this directory. I also tried installing <code>async-storage</code> (even though it's already installed) by running <code>yarn add async-storage</code>, but nothing appeared in the previously mentioned directory</p>
| 0debug
|
How to execute a SQL script in DBeaver? : <p>I have a number of <code>.sql</code> files that I wish to execute through DBeaver. Traditional database development programmes allow the user to edit and run SQL scripts (totally or partially) in the same window, but this is not obvious with DBeaver.</p>
<p>When I open a <code>.sql</code> script some drop down boxes in the button bar appear, that seem to serve as connection selectors. But none of the connections I have defined appear in these drop down boxes. It is possible to open a SQL console on database objects in the Database Navigation view, but not on SQL scripts. </p>
<p>How can I execute a SQL script, totally or partially, against a particular database connection with DBeaver?</p>
| 0debug
|
Combining must_not in ElasticSearch Query : <p>I'm currently struggling with an ElastSearch query which currently looks the following:</p>
<pre><code>...
"query": {
"bool": {
"must_not": [
{
"term": {
"bool-facet.criteria1": {
"value": false
}
}
},
{
"term": {
"bool-facet.criteria2": {
"value": false
}
}
}
]
}
}
...
</code></pre>
<p>So now when either criteria1 OR criteria2 matches, the documents are ignored. How must the query look like so that only documents that match criteria1 AND criteria2 are ignored?</p>
| 0debug
|
How to add no of Days to given Date? : #Problem:
Given a Date.Add specified number of days to endDate.
Below is the **addDate** function that I need to define.
public static Date addDate(Date endDate,int noOFDays){
}
>Can anyone guide me which method should I use to add the given endDate with noOFDays?
| 0debug
|
Lottie Android: add color overlay to animation : <p>I'm using <a href="https://github.com/airbnb/lottie-android" rel="noreferrer">Lottie for Android</a> to add some animations in an app. In this app the primary and accent color can be chosen via the settings. I'm using an animation with a transparent background. To make the animation fit the chosen colors I'd like to add a color overlay to the animation, this way I can have one animation file but I can set the color programmatically. </p>
<p>Does anyone have an idea how I can manipulate the animation by adding a color overlay? </p>
| 0debug
|
remove part of name of multiple files in linux :
I have several fastq.gz files in a directory. I want to delete parts of each file name. Here are the file names
RES_1448_001_S289_L001_R1_001.fastq.gz
RES_1448_001_S289_L001_R2_001.fastq.gz
RES_1448_012_S300_L001_R1_001.fastq.gz
RES_1448_012_S300_L001_R2_001.fastq.gz
I want to remove S and 3 digits after it. I expect this after removing
RES_1448_001_R1_001.fastq.gz
RES_1448_001_R2_001.fastq.gz
RES_1448_012_R1_001.fastq.gz`enter code here`
RES_1448_012_R2_001.fastq.gz
Thank you
| 0debug
|
void hmp_chardev_add(Monitor *mon, const QDict *qdict)
{
const char *args = qdict_get_str(qdict, "args");
Error *err = NULL;
QemuOpts *opts;
opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"), args, true);
if (opts == NULL) {
error_setg(&err, "Parsing chardev args failed");
} else {
qemu_chr_new_from_opts(opts, NULL, &err);
}
hmp_handle_error(mon, &err);
}
| 1threat
|
how to always execute AsyncTask in android? : <p>my <code>AsyncTask</code> is detect devices connected to my device</p>
<p>recently, asynctask execute only <code>onCreate</code>.</p>
<p>so, when app started, only 1 execute.</p>
<p>I want always execute.</p>
<p>how to always execute Asynctask in android?</p>
<p>Is there a way to use a timer?</p>
<p>thanks.</p>
| 0debug
|
Python case sensetive removal : I'm making a small bot for twitch . tv and I have a small issue that I don't know how to fix it.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
user = getUser(line)
message = getMessage(line)
if "Pls Work" in message.lower():
sendMessage(s, "Okay I will work :)")
break
<!-- end snippet -->
I don't want to put loads of different combinations for one text, so how do I make it so it converts the input into lower cases so the bot understands it? I tried to put lower() in many places but didn't seem to work.
I am very new to python so please be easy on me :)
| 0debug
|
creating a wcf program to fetch data from Oracle database (12c) and will be hosted in IIS : <p>I am using System.Data.OracleClient which has been deprecated. Any suggestion will be appreciated on how and what should I do to replace System.Data.OracleClient.
I have tried to Add Oracle.DataAccess by going to solution explorer , add reference. Oracle.DataAccess is not shoiwing in my avaialble options (I do not have the .NET tab).
Thanks in advance.</p>
| 0debug
|
static int vhost_virtqueue_start(struct vhost_dev *dev,
struct VirtIODevice *vdev,
struct vhost_virtqueue *vq,
unsigned idx)
{
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
VirtioBusState *vbus = VIRTIO_BUS(qbus);
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
hwaddr s, l, a;
int r;
int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx);
struct vhost_vring_file file = {
.index = vhost_vq_index
};
struct vhost_vring_state state = {
.index = vhost_vq_index
};
struct VirtQueue *vvq = virtio_get_queue(vdev, idx);
vq->num = state.num = virtio_queue_get_num(vdev, idx);
r = dev->vhost_ops->vhost_set_vring_num(dev, &state);
if (r) {
VHOST_OPS_DEBUG("vhost_set_vring_num failed");
return -errno;
}
state.num = virtio_queue_get_last_avail_idx(vdev, idx);
r = dev->vhost_ops->vhost_set_vring_base(dev, &state);
if (r) {
VHOST_OPS_DEBUG("vhost_set_vring_base failed");
return -errno;
}
if (vhost_needs_vring_endian(vdev)) {
r = vhost_virtqueue_set_vring_endian_legacy(dev,
virtio_is_big_endian(vdev),
vhost_vq_index);
if (r) {
return -errno;
}
}
s = l = virtio_queue_get_desc_size(vdev, idx);
a = virtio_queue_get_desc_addr(vdev, idx);
vq->desc = cpu_physical_memory_map(a, &l, 0);
if (!vq->desc || l != s) {
r = -ENOMEM;
goto fail_alloc_desc;
}
s = l = virtio_queue_get_avail_size(vdev, idx);
a = virtio_queue_get_avail_addr(vdev, idx);
vq->avail = cpu_physical_memory_map(a, &l, 0);
if (!vq->avail || l != s) {
r = -ENOMEM;
goto fail_alloc_avail;
}
vq->used_size = s = l = virtio_queue_get_used_size(vdev, idx);
vq->used_phys = a = virtio_queue_get_used_addr(vdev, idx);
vq->used = cpu_physical_memory_map(a, &l, 1);
if (!vq->used || l != s) {
r = -ENOMEM;
goto fail_alloc_used;
}
vq->ring_size = s = l = virtio_queue_get_ring_size(vdev, idx);
vq->ring_phys = a = virtio_queue_get_ring_addr(vdev, idx);
vq->ring = cpu_physical_memory_map(a, &l, 1);
if (!vq->ring || l != s) {
r = -ENOMEM;
goto fail_alloc_ring;
}
r = vhost_virtqueue_set_addr(dev, vq, vhost_vq_index, dev->log_enabled);
if (r < 0) {
r = -errno;
goto fail_alloc;
}
file.fd = event_notifier_get_fd(virtio_queue_get_host_notifier(vvq));
r = dev->vhost_ops->vhost_set_vring_kick(dev, &file);
if (r) {
VHOST_OPS_DEBUG("vhost_set_vring_kick failed");
r = -errno;
goto fail_kick;
}
event_notifier_test_and_clear(&vq->masked_notifier);
if (!vdev->use_guest_notifier_mask) {
vhost_virtqueue_mask(dev, vdev, idx, false);
}
if (k->query_guest_notifiers &&
k->query_guest_notifiers(qbus->parent) &&
virtio_queue_vector(vdev, idx) == VIRTIO_NO_VECTOR) {
file.fd = -1;
r = dev->vhost_ops->vhost_set_vring_call(dev, &file);
if (r) {
goto fail_vector;
}
}
return 0;
fail_vector:
fail_kick:
fail_alloc:
cpu_physical_memory_unmap(vq->ring, virtio_queue_get_ring_size(vdev, idx),
0, 0);
fail_alloc_ring:
cpu_physical_memory_unmap(vq->used, virtio_queue_get_used_size(vdev, idx),
0, 0);
fail_alloc_used:
cpu_physical_memory_unmap(vq->avail, virtio_queue_get_avail_size(vdev, idx),
0, 0);
fail_alloc_avail:
cpu_physical_memory_unmap(vq->desc, virtio_queue_get_desc_size(vdev, idx),
0, 0);
fail_alloc_desc:
return r;
}
| 1threat
|
static int cin_read_frame_header(CinDemuxContext *cin, AVIOContext *pb) {
CinFrameHeader *hdr = &cin->frame_header;
hdr->video_frame_type = avio_r8(pb);
hdr->audio_frame_type = avio_r8(pb);
hdr->pal_colors_count = avio_rl16(pb);
hdr->video_frame_size = avio_rl32(pb);
hdr->audio_frame_size = avio_rl32(pb);
if (pb->eof_reached || pb->error)
return AVERROR(EIO);
if (avio_rl32(pb) != 0xAA55AA55)
return 0;
}
| 1threat
|
Kotlin, something wrong with class references? : I'm porting [bullet][1] to [kotlin][2] and I wrote all the necessary stuff to run the HelloWorld sample.
I'm in debugging phase right now and I'm having problems with objects references.
At the very begin, I do enter `collideTTpersistentStack` a first time:
fun collideTTpersistentStack(root0: DbvtNode?, root1: DbvtNode?, collider: DbvtTreeCollider) {
if (root0 != null && root1 != null) {
var depth = 1
var treshold = DOUBLE_STACKSIZE - 4
val element = StkNN(root0, root1)
if (stkStack.isNotEmpty()) stkStack[0] = element
else stkStack += element
stkStack resize DOUBLE_STACKSIZE
do {
val p = stkStack[--depth]
if (depth > treshold) {
stkStack resize (stkStack.size * 2)
treshold = stkStack.size - 4
}
val pa = p.a!!
val pb = p.b!!
if (pa === pb) {
if (pa.isInternal) {
stkStack[depth++] = StkNN(pa.childs[0], pa.childs[0])
stkStack[depth++] = StkNN(pa.childs[1], pa.childs[1])
stkStack[depth++] = StkNN(pa.childs[0], pa.childs[1])
}
} else if (pa.volume intersect pb.volume)
if (pa.isInternal)
if (pb.isInternal) {
stkStack[depth++] = StkNN(pa.childs[0], pb.childs[0])
stkStack[depth++] = StkNN(pa.childs[1], pb.childs[0])
stkStack[depth++] = StkNN(pa.childs[0], pb.childs[1])
stkStack[depth++] = StkNN(pa.childs[1], pb.childs[1])
} else {
stkStack[depth++] = StkNN(pa.childs[0], pb)
stkStack[depth++] = StkNN(pa.childs[1], pb)
}
else
if (pb.isInternal) {
stkStack[depth++] = StkNN(pa, pb.childs[0])
stkStack[depth++] = StkNN(pa, pb.childs[1])
} else
collider.process(pa, pb)
} while (depth != 0)
}
}
but since `root0` is `null` I'll quit right away.
At the next time I enter the function, both `root0` and `root1` are valid objects, and their references are the following
root0 = Dbvt@708
root1 = Dbvt@656
Then I create the first element to add to `stkStack`, that is still empty and is defined as:
val stkStack = ArrayList<StkNN>()
`element` is a `StkNN` Class so defined:
class StkNN(var a: DbvtNode? = null, var b: DbvtNode? = null)
After the insertion, I get:
[![enter image description here][3]][3]
Which makes sense.
`stkStack resize DOUBLE_STACKSIZE` simply create some dummy StkNN instances
Then I enter the `do` and I grab the first element on the `stkStack`, which is basically the element we just inserted:
p = {Dbvt$StkNN@731}
a = {DbvtNode@708}
b = {DbvtNode@656}
then we skip the next `if`, I save the variables `p.a` and `p.b` as immutable checking against nullability
val pa = p.a!!
val pb = p.b!!
Both `pa` and `pb` are consistent in terms of references:
pa = @708
pb = @656
And now we land directly [here][4]:
} else {
stkStack[depth++] = StkNN(pa.childs[0], pb)
stkStack[depth++] = StkNN(pa.childs[1], pb)
}
`depth` now is `0` and `stkStack` contains one element, the one we inserted at the begin, so it should replace it with a new instance
Well, `pa` childs are the following
pa = {DbvtNode@708}
childs = {DbvtNode[2]@748}
0 = {DbvtNode@759}
1 = {DbvtNode@656}
But after I jump over the assignments, `stkStack` will contain the following:
stkStack = {ArrayList@709} size = 128
0 = {Dbvt$StkNN@772}
a = {DbvtNode@708} // this is wrong, it should be @759
b = {DbvtNode@656}
1 = {Dbvt$StkNN@781}
a = {DbvtNode@656} // right
b = {DbvtNode@656} // right
C++ code uses pointers, and I double check the execution and its `stkStack[0].a` pointer is actually as it should be, that is, it corresponds to the `p.a->childs[0]` pointer
What is happening?
[1]: http://bulletphysics.org/
[2]: https://github.com/kotlin-graphics/bullet
[3]: https://i.stack.imgur.com/ZOrL9.png
[4]: https://github.com/kotlin-graphics/bullet/blob/master/src/main/kotlin/bullet/collision/broadphaseCollision/Dbvt.kt#L417
| 0debug
|
Ignoring Certain String Characters : Let's say I write some code to print out "Hello World."
Could I use some sort of character to ignore the r in hello world so that the output is "Hello Wold?"
I have a value that I am using. I have the following characters:
&, \, and *.
I think one of these characters is causing me to have some of my values ignored.
Normally I would just test this myself, but I am not able to do this at this time.
| 0debug
|
static void usb_uas_unrealize(USBDevice *dev, Error **errp)
{
UASDevice *uas = USB_UAS(dev);
qemu_bh_delete(uas->status_bh);
}
| 1threat
|
Floating navigation anchor points without reversing their order? : <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.topNav {
overflow: hidden;
background-color: #5e9da1;
}
/* Style the links inside the navigation bar */
.topNav a {
float: right;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/* Change the color of links on hover */
.topNav a:hover {
background-color: #ddd;
color: #000000;
}
/* Add a color to the active/current link */
.topNav a.active {
background-color: #4CAF50;
color: #ffffff;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="topNav">
<a class="active" href="#home">Home</a>
<a href="#About">About</a>
<a href="#Gallery">Gallery</a>
<a href="#Contact">Contact</a>
</div></code></pre>
</div>
</div>
</p>
<p>How do I float the anchor points to the right without reversing the order among themselves? </p>
<p>Note: I was able to solve this problem by manually reversing the anchor point order in the HTML file, but I'm not sure if this is a proper solution (good practice) to the issue:
Example:</p>
<pre><code> <a href="#Contact">Contact</a>
<a href="#Gallery">Gallery</a>
<a href="#About">About</a>
<a class="active" href="#Home">Home</a>
</code></pre>
| 0debug
|
Is it possible to match the # part of a route in React Router 4 : <p>In my app, I'd like to match both the path and the hash to different components. For example:</p>
<pre><code>/pageA#modalB
</code></pre>
<p>Would show PageA as the main page, with modalB over the top.
I've tried the following, with many variations of the path property:</p>
<pre><code><Route path="#modalB" component={modalB}/>
</code></pre>
<p>But nothing works.</p>
<p>In React Router 2 inside a modal 'controller' component, I would use:</p>
<pre><code>browserHistory.listen( (location) => { //do something with loction.hash })
</code></pre>
<p>I was hoping for something a little more elegant in V4</p>
| 0debug
|
Python adding unwanted double quotes to a dictionary : <p>After passing a string into a function, Python is generating additional double quotes. For example:</p>
<pre><code>def main():
...
foo("string1", "'string2','string3'")
...
def foo(var1, var2):
dictionary = {
'a' : var1,
'b' : [var2]
}
print(dictionary)
</code></pre>
<p>I need var2 to be in square brackets for what comes next. The following is the output:</p>
<pre><code>{'a': 'string1', 'b': ["'string2','string3'"]}
</code></pre>
<p>How can the additional double quotes be removed so that <code>'b': ['string2','string3']</code>?</p>
| 0debug
|
how to block user ip if user tried to access website scouce code : <p>is it possible to block IP address if any user tried to access your WordPress website source code? </p>
<p>and i found this Wordpress plugin which does some sort of a activity like that.</p>
<p><a href="https://codecanyon.net/item/hide-my-wp-amazing-security-plugin-for-wordpress/4177158" rel="nofollow noreferrer">https://codecanyon.net/item/hide-my-wp-amazing-security-plugin-for-wordpress/4177158</a> this plugin Notify you when someone is mousing about your WordPress site (included with visitor details like IP, user agent, referrer and even username!)</p>
| 0debug
|
Azure SQL Server database with visual studio subscription : <p>I wanted to learn Azure SQL Server database and I created pay as you go account with Microsoft but I ended up with subscription to Visual studio premium edition with MSDN also
My question is do I need to have visual studio premium subscription? in order to learn Azure SQL server data</p>
| 0debug
|
static int decode_header_trees(SmackVContext *smk) {
GetBitContext gb;
int mmap_size, mclr_size, full_size, type_size, ret;
mmap_size = AV_RL32(smk->avctx->extradata);
mclr_size = AV_RL32(smk->avctx->extradata + 4);
full_size = AV_RL32(smk->avctx->extradata + 8);
type_size = AV_RL32(smk->avctx->extradata + 12);
init_get_bits8(&gb, smk->avctx->extradata + 16, smk->avctx->extradata_size - 16);
if(!get_bits1(&gb)) {
av_log(smk->avctx, AV_LOG_INFO, "Skipping MMAP tree\n");
smk->mmap_tbl = av_malloc(sizeof(int) * 2);
if (!smk->mmap_tbl)
return AVERROR(ENOMEM);
smk->mmap_tbl[0] = 0;
smk->mmap_last[0] = smk->mmap_last[1] = smk->mmap_last[2] = 1;
} else {
ret = smacker_decode_header_tree(smk, &gb, &smk->mmap_tbl, smk->mmap_last, mmap_size);
if (ret < 0)
return ret;
}
if(!get_bits1(&gb)) {
av_log(smk->avctx, AV_LOG_INFO, "Skipping MCLR tree\n");
smk->mclr_tbl = av_malloc(sizeof(int) * 2);
if (!smk->mclr_tbl)
return AVERROR(ENOMEM);
smk->mclr_tbl[0] = 0;
smk->mclr_last[0] = smk->mclr_last[1] = smk->mclr_last[2] = 1;
} else {
ret = smacker_decode_header_tree(smk, &gb, &smk->mclr_tbl, smk->mclr_last, mclr_size);
if (ret < 0)
return ret;
}
if(!get_bits1(&gb)) {
av_log(smk->avctx, AV_LOG_INFO, "Skipping FULL tree\n");
smk->full_tbl = av_malloc(sizeof(int) * 2);
if (!smk->full_tbl)
return AVERROR(ENOMEM);
smk->full_tbl[0] = 0;
smk->full_last[0] = smk->full_last[1] = smk->full_last[2] = 1;
} else {
ret = smacker_decode_header_tree(smk, &gb, &smk->full_tbl, smk->full_last, full_size);
if (ret < 0)
return ret;
}
if(!get_bits1(&gb)) {
av_log(smk->avctx, AV_LOG_INFO, "Skipping TYPE tree\n");
smk->type_tbl = av_malloc(sizeof(int) * 2);
if (!smk->type_tbl)
return AVERROR(ENOMEM);
smk->type_tbl[0] = 0;
smk->type_last[0] = smk->type_last[1] = smk->type_last[2] = 1;
} else {
ret = smacker_decode_header_tree(smk, &gb, &smk->type_tbl, smk->type_last, type_size);
if (ret < 0)
return ret;
}
return 0;
}
| 1threat
|
Pointers in C#, when are they used? : I am trying to implement a simple counter for a game. I want to be able to increment the fire, water and earth attributes using a method which takes a string and an int as arguments.
I am however not sure whether the following would work. I am not sure the ints within the elements array would point to the original attribute of the same name or if it would just make a copy of it in the array.
class TypeCounter{
int fire = 0;
int water = 0;
int earth = 0;
string[] elementNames = {“fire”,”water”, “earth”};
int[] elements = {fire, water, earth};
public void AddTo(string element, int val){
int keyIndex = Array.FindIndex(elementNames , element);
elements[keyIndex] += val;
}
}
I want to be able to do the following:
TypeCounter counter = new TypeCounter();
public Run(){
print counter.fire;
counter.AddTo("fire", 1);
print counter.fire;
}
I would expect an output of `0` for the first print statement and `1` for the second, when I execute the Run() method.
| 0debug
|
static int do_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,
int64_t count, int flags, int64_t *total)
{
Coroutine *co;
CoWriteZeroes data = {
.blk = blk,
.offset = offset,
.count = count,
.total = total,
.flags = flags,
.done = false,
};
if (count >> BDRV_SECTOR_BITS > INT_MAX) {
return -ERANGE;
}
co = qemu_coroutine_create(co_pwrite_zeroes_entry, &data);
qemu_coroutine_enter(co);
while (!data.done) {
aio_poll(blk_get_aio_context(blk), true);
}
if (data.ret < 0) {
return data.ret;
} else {
return 1;
}
}
| 1threat
|
unable to match regex pattern in python : <p>I am trying to match a regex from an email. If the e-mail says "need update on SRT1000" the regex needs to match. I have my code as below, but it is not working. Can someone look at this and let me know what is wrong here?</p>
<pre><code>def status_update_regex(email):
email = email.lower()
need_sr_update_regex = re.compile('(looking|want|need|seek|seeking|request|requesting)([^/./!/?/,/"]{0,10})(status|update)(^.{0,6})(^srt[0-9]{4})')
if need_sr_update_regex.search(email) != None:
return 1
else:
return 0
</code></pre>
| 0debug
|
Read a file and put specific values to an array : <p>I am a newbie to bash scripting. I have a file containing some values. I want to put all the values of a specific key into an array in bash. The file looks like this.</p>
<pre><code>file.properties
name=val1
name=val2
name=val3
age=val4
</code></pre>
<p>I want to read this file and get all the name values into one array in bash.</p>
| 0debug
|
Soundpool load sound A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one : <p>I have implemented load all sounds in Application onCreate method in background. But when i load sound it gives error like this: </p>
<blockquote>
<p>E/OMXMaster: A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.</p>
</blockquote>
<p>What is problem here? Anybody have any idea? Thanks in advance</p>
<pre><code>private void loadAllSounds() {
new Thread(new Runnable() {
@Override
public void run() {
soundPool.load(appContext, R.raw.compose_sound_0, 1);
soundPool.load(appContext, R.raw.compose_sound_1, 1);
soundPool.load(appContext, R.raw.compose_sound_2, 1);
soundPool.load(appContext, R.raw.compose_sound_3, 1);
}
}).start();
}
</code></pre>
| 0debug
|
static av_cold int atrac1_decode_end(AVCodecContext * avctx) {
AT1Ctx *q = avctx->priv_data;
av_freep(&q->out_samples[0]);
ff_mdct_end(&q->mdct_ctx[0]);
ff_mdct_end(&q->mdct_ctx[1]);
ff_mdct_end(&q->mdct_ctx[2]);
return 0;
}
| 1threat
|
struct omap_gp_timer_s *omap_gp_timer_init(struct omap_target_agent_s *ta,
qemu_irq irq, omap_clk fclk, omap_clk iclk)
{
struct omap_gp_timer_s *s = (struct omap_gp_timer_s *)
g_malloc0(sizeof(struct omap_gp_timer_s));
s->ta = ta;
s->irq = irq;
s->clk = fclk;
s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_gp_timer_tick, s);
s->match = timer_new_ns(QEMU_CLOCK_VIRTUAL, omap_gp_timer_match, s);
s->in = qemu_allocate_irq(omap_gp_timer_input, s, 0);
omap_gp_timer_reset(s);
omap_gp_timer_clk_setup(s);
memory_region_init_io(&s->iomem, NULL, &omap_gp_timer_ops, s, "omap.gptimer",
omap_l4_region_size(ta, 0));
omap_l4_attach(ta, 0, &s->iomem);
return s;
}
| 1threat
|
how to make 2 arraylist on an adapter, adapted to one API? : <p>how to make 2 arraylist on an adapter, adapted to one API. I have given a list of cases here metadataList; but it doesn't work because the activity.java part must have a Metadata List implementation. How to retrieve data with different getter setters (2 getter setters) but can be combined in one adapter?</p>
<p>API Result</p>
<pre><code>{
"status": 200,
"reason": "OK",
"success": true,
"message": null,
"result": [
{
"id": "1",
"id_product_category": "2",
"id_currency": "58",
"name": "PlayStation 4 500GB Console - Refurbished",
"slug": "playstation-4-500gb-console-refurbished",
"image": "https://demo.xxxx.com/images/products/product-1.png",
"images": [
{
"name": "main",
"image": "https://demo.xxxx.com/storage/images/products/product-1.png"
}
],
"metadata": {
"weight_value": "1",
"weight": "KG",
}
}
</code></pre>
<p>ResultItem.java</p>
<pre><code>public class ResultItem{
@SerializedName("image")
private String image;
@SerializedName("images")
private ImagesItem[] images;
@SerializedName("metadata")
private Metadata metadata;
@SerializedName("id_product_category")
private String idProductCategory;
@SerializedName("price_capital")
private String priceCapital;
@SerializedName("name")
private String name;
@SerializedName("id")
private String id;
@SerializedName("id_currency")
private String idCurrency;
@SerializedName("slug")
private String slug;
public void setImage(String image){
this.image = image;
}
public String getImage(){
return image;
}
public void setImages(ImagesItem[] images){
this.images = images;
}
public ImagesItem[] getImages(){
return images;
}
public void setMetadata(Metadata metadata){
this.metadata = metadata;
}
public Metadata getMetadata(){
return metadata;
}
public void setIdProductCategory(String idProductCategory){
this.idProductCategory = idProductCategory;
}
public String getIdProductCategory(){
return idProductCategory;
}
public void setPriceCapital(String priceCapital){
this.priceCapital = priceCapital;
}
public String getPriceCapital(){
return priceCapital;
}
public void setPriceSale(String priceSale){
this.priceSale = priceSale;
}
public String getPriceSale(){
return priceSale;
}
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setId(String id){
this.id = id;
}
public String getId(){
return id;
}
public void setIdCurrency(String idCurrency){
this.idCurrency = idCurrency;
}
public String getIdCurrency(){
return idCurrency;
}
}
</code></pre>
<p>Metadata.java</p>
<pre><code>public class Metadata{
@SerializedName("weight_value")
private String weightValue;
@SerializedName("weight")
private String weight;
public void setWeightValue(String weightValue){
this.weightValue = weightValue;
}
public String getWeightValue(){
return weightValue;
}
public void setWeight(String weight){
this.weight = weight;
}
public String getWeight(){
return weight;
}
}
</code></pre>
<p>Adapter.java</p>
<pre><code>public class AdapterAllProduct extends RecyclerView.Adapter<AdapterAllProduct.AllproductHolder> {
List<ResultItem> resultItemList;
//// List<Metadata> metadataList;
Context mContext;
public AdapterAllProduct(Context context, List<ResultItem> resulList){
this.mContext = context;
resultItemList = resulList;
}
@NonNull
@Override
public AllproductHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.adapter_product, parent,false);
return new AllproductHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull AllproductHolder holder, int position) {
final ResultItem resultItem = resultItemList.get(position);
///final Metadata metadataItem = metadataList.get(position);
holder.txt_id.setText(resultItem.getId());
holder.txt_id_currency.setText(resultItem.getIdCurrency());
holder.txt_id_product_category.setText(resultItem.getIdCurrency());
holder.txt_name_product.setText(resultItem.getName());
holder.txt_price_capital.setText(resultItem.getPriceCapital());
// Locale localeID = new Locale("in", "ID");
// NumberFormat formatRupiah = NumberFormat.getCurrencyInstance(localeID);
// holder.txt_price_capital.setText(formatRupiah.format(resultItem.getPriceCapital()));
holder.txt_price_sale.setText(resultItem.getPriceSale());
holder.txt_description.setText(resultItem.getDescription());
holder.txt_sku.setText(resultItem.getSku());
holder.txt_stock.setText(resultItem.getStock());
//holder.image.setText(resultItem.getImage());
holder.txt_condition.setText(resultItem.getCondition());
holder.txt_deliverable.setText(resultItem.getDeliverable());
holder.txt_downloadable.setText(resultItem.getDownloadable());
holder.txt_target_gender.setText(resultItem.getTargetGender());
holder.txt_target_age.setText(resultItem.getTargetAge());
holder.txt_visibility.setText(resultItem.getVisibility());
holder.txt_image.setText(resultItem.getImage());
Glide.with(mContext)
.load(resultItem.getImage())
.placeholder(R.drawable.no_image)
.error(R.drawable.no_image)
.into(holder.image);
// holder.txt_weight_value.setText(metadataItem.getWeightValue());
// holder.txt_weight.setText(metadataItem.getWeight());
final String id = resultItem.getId();
final String id_currency = resultItem.getIdCurrency();
final String id_product_category = resultItem.getIdProductCategory();
final String name = resultItem.getName();
final String description = resultItem.getDescription();
final String stock = resultItem.getStock();
final String price_capital = resultItem.getPriceCapital();
final String price_sale = resultItem.getPriceSale();
final String condition = resultItem.getCondition();
final String image = resultItem.getImage();
// final String weight_value = metadataItem.getWeightValue();
// final String weight = metadataItem.getWeight();
holder.btnclick.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent detailproduct = new Intent(v.getContext(), DetailProduct.class);
detailproduct.putExtra("id", id);
detailproduct.putExtra("id_product_category", id_product_category);
detailproduct.putExtra("id_currency", id_currency);
detailproduct.putExtra("name", name);
detailproduct.putExtra("price_capital", price_capital);
detailproduct.putExtra("price_sale", price_sale);
detailproduct.putExtra("description", description);
detailproduct.putExtra("stock", stock);
detailproduct.putExtra("condition", condition);
detailproduct.putExtra("image", image);
// detailproduct.putExtra("weight_value", weight_value);
// detailproduct.putExtra("weight", weight);
v.getContext().startActivity(detailproduct);
}
});
}
</code></pre>
| 0debug
|
static inline void RENAME(nv12ToUV)(uint8_t *dstU, uint8_t *dstV,
const uint8_t *src1, const uint8_t *src2,
int width, uint32_t *unused)
{
RENAME(nvXXtoUV)(dstU, dstV, src1, width);
}
| 1threat
|
How do magrittr %>% pipes work exactly? : <p>So for the life of me I can’t understand this extremely simple concept. </p>
<p><a href="https://i.stack.imgur.com/a10jC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/a10jC.jpg" alt="take this code for example in this image. "></a></p>
<p>This code looks to me like the code from hell. I was told the pipes are like Russian nesting dolls. Each statement before the pipes apparently feeds into the statement after the pipe. That’s what I was told. So what I don’t understand is first how can this continue to chain on endlessly and second, how does the pipe know where in the next statement the previous statement goes??</p>
<p>Let me take an example... read.csv2 ... %>% select(-x..otu) </p>
<p>And it keeps going on and on from there… How does it know where to put the previous statement or function in the next statement?</p>
| 0debug
|
Java FilePath folder find : <p>Is there any solution for my problem? I want work with files, which i add to my program by every run, for example folder1, folder2 and this folders contains .txt files. How can i make it with Java language?</p>
<p>Next problem is, how to set Uni for my program, when some files are named FileInfo and some FileInformations.</p>
<pre><code> pdfManager.setFilePath("D:\\virusTotal\\FileInfo.pdf");
</code></pre>
<p>Thanks for help guys.</p>
| 0debug
|
How to Move the files from one directory to another directory? directory file name should append with current date (yyyy-mm-dd) : import shutil
import os
source = '/path/to/source_folder'
dest1 = '/path/to/dest_folder'
files = os.listdir(source)
for f in files:
shutil.move(source+f, dest1)
| 0debug
|
What's the difference between * and html in css selector : <p>In css, what's the difference of two selector: * and html?</p>
<pre><code>*{
}
</code></pre>
<p>and</p>
<pre><code>html{
}
</code></pre>
<p>Do these two work differently?</p>
| 0debug
|
How to make changes in the ListView fetching data directly from Server : I have made a live score app.
I want to make changes after every match, update matches played, won lost etc.
How to make this changes
Can someone pls help me.
| 0debug
|
static int coroutine_fn raw_co_writev(BlockDriverState *bs, int64_t sector_num,
int nb_sectors, QEMUIOVector *qiov)
{
BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO);
return bdrv_co_writev(bs->file, sector_num, nb_sectors, qiov);
}
| 1threat
|
Django REST Framework: using TokenAuthentication with browsable API : <p>I'm following the DRF docs to setup TokenAuthentication, and can't get it working with the browsable API. I believe I've added the proper lines in <code>settings.py</code>:</p>
<pre><code>REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
),
INSTALLED_APPS = (
...
'rest_framework',
'rest_framework.authtoken',
...
</code></pre>
<p>As well as generated tokens for existing users with the code snippet from the docs. I can see tokens for each user if I query the <code>authtoken_token</code> table, so I know they exist.</p>
<p>Everytime I try to log in to the browsable API, I get the following content returned:</p>
<pre><code>HTTP 401 Unauthorized
Allow: GET, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept
WWW-Authenticate: Token
{
"detail": "Authentication credentials were not provided."
}
</code></pre>
<p>So it appears to be attempting Token authentication, but this message is a little odd. When I enter an incorrect password, I get the 'enter a correct password' message on the login form. When I enter the correct password, it appears to login, but takes me to the API root with the above message, and displays "Log In" on the top menu, rather than the username.</p>
<p>Could this be related to my custom user model somehow? Or could it be due to the fact that I'm currently developing with the dev server, which doesn't support https- the DRF docs mention needing HTTPS with TokenAuthentication, though I wasn't sure if that was a best practice or actually required.</p>
| 0debug
|
static int xen_pt_byte_reg_read(XenPCIPassthroughState *s, XenPTReg *cfg_entry,
uint8_t *value, uint8_t valid_mask)
{
XenPTRegInfo *reg = cfg_entry->reg;
uint8_t valid_emu_mask = 0;
valid_emu_mask = reg->emu_mask & valid_mask;
*value = XEN_PT_MERGE_VALUE(*value, cfg_entry->data, ~valid_emu_mask);
return 0;
}
| 1threat
|
c++ std::string '==' operator and Compare method is return 1 to equal string : [the data of str1 and str2][1]
[1]: http://i.stack.imgur.com/TeVzJ.png
motion->bone_frames[0].name == model->bones[0].bone_name// return 0 . it should be 1
motion->bone_frames[0].name.Compare(model->bones[0].bone_name)// return 1 . it should be 0
wcscmp(motion->bone_frames[0].name.c_str(), model->bones[0].bone_name.c_str()) // return 0 . it should be 0
I cant understand std::string compare function why have different result to wcscmp.
Can i know why these results are different?
Is it cause of different is length?
| 0debug
|
static void virtio_net_device_realize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIONet *n = VIRTIO_NET(dev);
NetClientState *nc;
int i;
virtio_init(vdev, "virtio-net", VIRTIO_ID_NET, n->config_size);
n->max_queues = MAX(n->nic_conf.queues, 1);
n->vqs = g_malloc0(sizeof(VirtIONetQueue) * n->max_queues);
n->vqs[0].rx_vq = virtio_add_queue(vdev, 256, virtio_net_handle_rx);
n->curr_queues = 1;
n->vqs[0].n = n;
n->tx_timeout = n->net_conf.txtimer;
if (n->net_conf.tx && strcmp(n->net_conf.tx, "timer")
&& strcmp(n->net_conf.tx, "bh")) {
error_report("virtio-net: "
"Unknown option tx=%s, valid options: \"timer\" \"bh\"",
n->net_conf.tx);
error_report("Defaulting to \"bh\"");
}
if (n->net_conf.tx && !strcmp(n->net_conf.tx, "timer")) {
n->vqs[0].tx_vq = virtio_add_queue(vdev, 256,
virtio_net_handle_tx_timer);
n->vqs[0].tx_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, virtio_net_tx_timer,
&n->vqs[0]);
} else {
n->vqs[0].tx_vq = virtio_add_queue(vdev, 256,
virtio_net_handle_tx_bh);
n->vqs[0].tx_bh = qemu_bh_new(virtio_net_tx_bh, &n->vqs[0]);
}
n->ctrl_vq = virtio_add_queue(vdev, 64, virtio_net_handle_ctrl);
qemu_macaddr_default_if_unset(&n->nic_conf.macaddr);
memcpy(&n->mac[0], &n->nic_conf.macaddr, sizeof(n->mac));
n->status = VIRTIO_NET_S_LINK_UP;
if (n->netclient_type) {
n->nic = qemu_new_nic(&net_virtio_info, &n->nic_conf,
n->netclient_type, n->netclient_name, n);
} else {
n->nic = qemu_new_nic(&net_virtio_info, &n->nic_conf,
object_get_typename(OBJECT(dev)), dev->id, n);
}
peer_test_vnet_hdr(n);
if (peer_has_vnet_hdr(n)) {
for (i = 0; i < n->max_queues; i++) {
qemu_peer_using_vnet_hdr(qemu_get_subqueue(n->nic, i), true);
}
n->host_hdr_len = sizeof(struct virtio_net_hdr);
} else {
n->host_hdr_len = 0;
}
qemu_format_nic_info_str(qemu_get_queue(n->nic), n->nic_conf.macaddr.a);
n->vqs[0].tx_waiting = 0;
n->tx_burst = n->net_conf.txburst;
virtio_net_set_mrg_rx_bufs(n, 0);
n->promisc = 1;
n->mac_table.macs = g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN);
n->vlans = g_malloc0(MAX_VLAN >> 3);
nc = qemu_get_queue(n->nic);
nc->rxfilter_notify_enabled = 1;
n->qdev = dev;
register_savevm(dev, "virtio-net", -1, VIRTIO_NET_VM_VERSION,
virtio_net_save, virtio_net_load, n);
add_boot_device_path(n->nic_conf.bootindex, dev, "/ethernet-phy@0");
}
| 1threat
|
open file dialog return multiple file names (Visual Basic 2010 C#) : <p>How to make a OpenFileDialog1 object return multiple paths of the selected files to a multi-line textbox?</p>
| 0debug
|
What is this syntax in java? : <p>I find a syntax <strong>String[]::new</strong> in <a href="https://stackoverflow.com/a/24112752">this</a> answer.
but I search this in google can't find useful information.</p>
| 0debug
|
Can array lengths be inferred in Rust? : <p>I can do this:</p>
<pre><code>let a: [f32; 3] = [0.0, 1.0, 2.0];
</code></pre>
<p>But why doesn't this work?</p>
<pre><code>let a: [f32; _] = [0.0, 1.0, 2.0];
</code></pre>
<p>It seems to me that the length is redundant and trivial to infer. Is there a way to avoid having to specify it explicitly? (And without having to append <code>f32</code> to all the literals.)</p>
| 0debug
|
static int xen_pt_msixctrl_reg_write(XenPCIPassthroughState *s,
XenPTReg *cfg_entry, uint16_t *val,
uint16_t dev_value, uint16_t valid_mask)
{
XenPTRegInfo *reg = cfg_entry->reg;
uint16_t writable_mask = 0;
uint16_t throughable_mask = get_throughable_mask(s, reg, valid_mask);
int debug_msix_enabled_old;
writable_mask = reg->emu_mask & ~reg->ro_mask & valid_mask;
cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask);
*val = XEN_PT_MERGE_VALUE(*val, dev_value, throughable_mask);
if ((*val & PCI_MSIX_FLAGS_ENABLE)
&& !(*val & PCI_MSIX_FLAGS_MASKALL)) {
xen_pt_msix_update(s);
} else if (!(*val & PCI_MSIX_FLAGS_ENABLE) && s->msix->enabled) {
xen_pt_msix_disable(s);
}
debug_msix_enabled_old = s->msix->enabled;
s->msix->enabled = !!(*val & PCI_MSIX_FLAGS_ENABLE);
if (s->msix->enabled != debug_msix_enabled_old) {
XEN_PT_LOG(&s->dev, "%s MSI-X\n",
s->msix->enabled ? "enable" : "disable");
}
return 0;
}
| 1threat
|
static uint64_t omap_id_read(void *opaque, hwaddr addr,
unsigned size)
{
struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
if (size != 4) {
return omap_badwidth_read32(opaque, addr);
}
switch (addr) {
case 0xfffe1800:
return 0xc9581f0e;
case 0xfffe1804:
return 0xa8858bfa;
case 0xfffe2000:
return 0x00aaaafc;
case 0xfffe2004:
return 0xcafeb574;
case 0xfffed400:
switch (s->mpu_model) {
case omap310:
return 0x03310315;
case omap1510:
return 0x03310115;
default:
hw_error("%s: bad mpu model\n", __FUNCTION__);
}
break;
case 0xfffed404:
switch (s->mpu_model) {
case omap310:
return 0xfb57402f;
case omap1510:
return 0xfb47002f;
default:
hw_error("%s: bad mpu model\n", __FUNCTION__);
}
break;
}
OMAP_BAD_REG(addr);
return 0;
}
| 1threat
|
Where i am wrong on code web service php : <p>Where the code is wrong its giving me an error on mysql_assoc;</p>
<pre><code>if($_SERVER['REQUEST_METHOD'] == "POST"){
$sql=mysql_query("SELECT * FROM users");
$query = mysql_query($sql);
$json = array(); // create empty array
$i = 0; // start a counter
while($result=mysql_fetch_assoc($query)){
$json[$i]['name'] = $result['name'];
$json[$i]['email'] = $result['email'];
$i++;
}
if(count($json)>0){
}else{
$json = array( "msg" => "No infomations Found");
}
header('Content-type: application/json');
}
</code></pre>
<p>this an error after running the service;</p>
<pre><code><br />
<b>Warning</b>: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in <b>C:\xampp\htdocs\satyam\services\select.php</b> on line <b>11</b><br />
</code></pre>
| 0debug
|
static void xtensa_cpu_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
CPUClass *cc = CPU_CLASS(oc);
XtensaCPUClass *xcc = XTENSA_CPU_CLASS(cc);
xcc->parent_realize = dc->realize;
dc->realize = xtensa_cpu_realizefn;
xcc->parent_reset = cc->reset;
cc->reset = xtensa_cpu_reset;
cc->class_by_name = xtensa_cpu_class_by_name;
cc->has_work = xtensa_cpu_has_work;
cc->do_interrupt = xtensa_cpu_do_interrupt;
cc->cpu_exec_interrupt = xtensa_cpu_exec_interrupt;
cc->dump_state = xtensa_cpu_dump_state;
cc->set_pc = xtensa_cpu_set_pc;
cc->gdb_read_register = xtensa_cpu_gdb_read_register;
cc->gdb_write_register = xtensa_cpu_gdb_write_register;
cc->gdb_stop_before_watchpoint = true;
#ifndef CONFIG_USER_ONLY
cc->do_unaligned_access = xtensa_cpu_do_unaligned_access;
cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug;
cc->do_unassigned_access = xtensa_cpu_do_unassigned_access;
#endif
cc->debug_excp_handler = xtensa_breakpoint_handler;
dc->vmsd = &vmstate_xtensa_cpu;
dc->cannot_destroy_with_object_finalize_yet = true;
}
| 1threat
|
static void do_mchk_interrupt(CPUS390XState *env)
{
S390CPU *cpu = s390_env_get_cpu(env);
uint64_t mask, addr;
LowCore *lowcore;
MchkQueue *q;
int i;
if (!(env->psw.mask & PSW_MASK_MCHECK)) {
cpu_abort(CPU(cpu), "Machine check w/o mchk mask\n");
}
if (env->mchk_index < 0 || env->mchk_index >= MAX_MCHK_QUEUE) {
cpu_abort(CPU(cpu), "Mchk queue overrun: %d\n", env->mchk_index);
}
q = &env->mchk_queue[env->mchk_index];
if (q->type != 1) {
cpu_abort(CPU(cpu), "Unknown machine check type %d\n", q->type);
}
if (!(env->cregs[14] & (1 << 28))) {
return;
}
lowcore = cpu_map_lowcore(env);
for (i = 0; i < 16; i++) {
lowcore->floating_pt_save_area[i] = cpu_to_be64(get_freg(env, i)->ll);
lowcore->gpregs_save_area[i] = cpu_to_be64(env->regs[i]);
lowcore->access_regs_save_area[i] = cpu_to_be32(env->aregs[i]);
lowcore->cregs_save_area[i] = cpu_to_be64(env->cregs[i]);
}
lowcore->prefixreg_save_area = cpu_to_be32(env->psa);
lowcore->fpt_creg_save_area = cpu_to_be32(env->fpc);
lowcore->tod_progreg_save_area = cpu_to_be32(env->todpr);
lowcore->cpu_timer_save_area[0] = cpu_to_be32(env->cputm >> 32);
lowcore->cpu_timer_save_area[1] = cpu_to_be32((uint32_t)env->cputm);
lowcore->clock_comp_save_area[0] = cpu_to_be32(env->ckc >> 32);
lowcore->clock_comp_save_area[1] = cpu_to_be32((uint32_t)env->ckc);
lowcore->mcck_interruption_code[0] = cpu_to_be32(0x00400f1d);
lowcore->mcck_interruption_code[1] = cpu_to_be32(0x40330000);
lowcore->mcck_old_psw.mask = cpu_to_be64(get_psw_mask(env));
lowcore->mcck_old_psw.addr = cpu_to_be64(env->psw.addr);
mask = be64_to_cpu(lowcore->mcck_new_psw.mask);
addr = be64_to_cpu(lowcore->mcck_new_psw.addr);
cpu_unmap_lowcore(lowcore);
env->mchk_index--;
if (env->mchk_index == -1) {
env->pending_int &= ~INTERRUPT_MCHK;
}
DPRINTF("%s: %" PRIx64 " %" PRIx64 "\n", __func__,
env->psw.mask, env->psw.addr);
load_psw(env, mask, addr);
}
| 1threat
|
static int usb_host_handle_data(USBDevice *dev, USBPacket *p)
{
USBHostDevice *s = DO_UPCAST(USBHostDevice, dev, dev);
struct usbdevfs_urb *urb;
AsyncURB *aurb;
int ret, rem, prem, v;
uint8_t *pbuf;
uint8_t ep;
trace_usb_host_req_data(s->bus_num, s->addr,
p->pid == USB_TOKEN_IN,
p->devep, p->iov.size);
if (!is_valid(s, p->pid, p->devep)) {
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);
return USB_RET_NAK;
}
if (p->pid == USB_TOKEN_IN) {
ep = p->devep | 0x80;
} else {
ep = p->devep;
}
if (is_halted(s, p->pid, p->devep)) {
unsigned int arg = ep;
ret = ioctl(s->fd, USBDEVFS_CLEAR_HALT, &arg);
if (ret < 0) {
perror("USBDEVFS_CLEAR_HALT");
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);
return USB_RET_NAK;
}
clear_halt(s, p->pid, p->devep);
}
if (is_isoc(s, p->pid, p->devep)) {
return usb_host_handle_iso_data(s, p, p->pid == USB_TOKEN_IN);
}
v = 0;
prem = p->iov.iov[v].iov_len;
pbuf = p->iov.iov[v].iov_base;
rem = p->iov.size;
while (rem) {
if (prem == 0) {
v++;
assert(v < p->iov.niov);
prem = p->iov.iov[v].iov_len;
pbuf = p->iov.iov[v].iov_base;
assert(prem <= rem);
}
aurb = async_alloc(s);
aurb->packet = p;
urb = &aurb->urb;
urb->endpoint = ep;
urb->type = usb_host_usbfs_type(s, p);
urb->usercontext = s;
urb->buffer = pbuf;
urb->buffer_length = prem;
if (urb->buffer_length > MAX_USBFS_BUFFER_SIZE) {
urb->buffer_length = MAX_USBFS_BUFFER_SIZE;
}
pbuf += urb->buffer_length;
prem -= urb->buffer_length;
rem -= urb->buffer_length;
if (rem) {
aurb->more = 1;
}
trace_usb_host_urb_submit(s->bus_num, s->addr, aurb,
urb->buffer_length, aurb->more);
ret = ioctl(s->fd, USBDEVFS_SUBMITURB, urb);
DPRINTF("husb: data submit: ep 0x%x, len %u, more %d, packet %p, aurb %p\n",
urb->endpoint, urb->buffer_length, aurb->more, p, aurb);
if (ret < 0) {
perror("USBDEVFS_SUBMITURB");
async_free(aurb);
switch(errno) {
case ETIMEDOUT:
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_NAK);
return USB_RET_NAK;
case EPIPE:
default:
trace_usb_host_req_complete(s->bus_num, s->addr, USB_RET_STALL);
return USB_RET_STALL;
}
}
}
return USB_RET_ASYNC;
}
| 1threat
|
I would like to use a UNIX command-line program (Berkeleys SPICE) in an iOS app. What is the process to compile it into a usable library? : <p>I am trying to use <a href="https://bwrcs.eecs.berkeley.edu/Classes/IcBook/SPICE/" rel="noreferrer">Berkeley's SPICE</a> tool in an iOS app, but am having trouble compiling it for iOS.</p>
<p>It is a command-line program that I can call from a terminal like:</p>
<pre><code>./spice3f5 <arguments>
</code></pre>
<p>Which works well, and I would like this functionality in my iOS app, but I don't think I can just copy the executable over to Xcode and call it from Swift.</p>
<p>I've done some research and found the following:</p>
<ul>
<li>There is an updated version of SPICE called <a href="http://ngspice.sourceforge.net/" rel="noreferrer">ngspice</a>, which is relatively new (2014 release)</li>
<li>I'm fairly sure there are apps out there than have used either SPICE or ngspice, so I'm sure it can be done somehow.</li>
<li>I have read an article about a guy who says that <a href="http://alexandria.ucsb.edu/downloads/7m01bk898" rel="noreferrer">ngspice has been compiled as a shared library</a>(ctrl+f "ngspice"), and he made an app with it. I have emailed him but he unfortunately he has not responded.</li>
</ul>
<p>The reason I am asking here is because when googling for "ngspice iOS", I came across <a href="https://sourceforge.net/p/ngspice/discussion/127605/thread/4d8b0a0c/" rel="noreferrer">this thread</a> which has a lot of smart people trying to compile a <em>static</em> library, which seems way out of my scope. I learned that <em>dynamic</em> libraries are allowed as of iOS8. So would it be easier to compile a *.dylib than it is a static library?</p>
<p>How would I goabout using ngspice or SPICE in an iOS app?</p>
<p>Thanks</p>
| 0debug
|
Why does the initial p close automatically? : <p><code>p1</code> appears to be an empty <code>p</code> and the rest is displayed separately when I inspect in Google Chrome. Why would the initial automatically close? I've checked whether the tags are closed right.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><p id=p1 style="display:none">
<p>
<b>You have French (8a) on:</b>
<ul>
<li>
<b>Monday</b> at 09:45:00 for 01:30:00
</li>
<li>
<b>Thursday</b> at 12:00:00 for 01:30:00
</li>
</ul> and have a grade of 8/10.
</p>
</p></code></pre>
</div>
</div>
</p>
| 0debug
|
Request.Files in ASP.NET CORE : <p>I am trying to upload files using aspnet core using ajax request .
In previous versions of .net i used to handle this using </p>
<pre><code> foreach (string fileName in Request.Files)
{
HttpPostedFileBase file = Request.Files[fileName];
//Save file content goes here
fName = file.FileName;
(...)
</code></pre>
<p>but now its showing error at request.files how can i get it to work ? i searched and found that httppostedfile has been changed to iformfile but how to handle request.files?</p>
| 0debug
|
how can I detect an cell content color? : <p>I have an excel cell.
In the cell, I have few paragraphs, each paragraph using different font color.
How can I get the font color value for each paragraph using VBA?</p>
| 0debug
|
Value of a for loop in Ruby : I understand that, in Ruby, a for loop is an expression and therefore has a value which can be assigned to a variable. For example, `x = for i in 0..3 do end` sets `x` to `0..3` - the range over which the loop iterates.
Is the value of a for loop always the range as above, or can it differ depending on the body of the loop?
| 0debug
|
What is "^" operation in Java Program? : <pre><code> for(int i = 0; i < n; i++) {
num += digits[i]*(10^(n-1-i));
System.out.println(10^(n-1-i));
}
</code></pre>
<p>My purpose is to change a array representation of a number into Integer representation. For example, [9,9] is 9*(10^1) + 9*(10^0) = 90+9 = 99.
However, the output of <code>10^(n-1-i)</code> is:</p>
<pre><code>11
10
</code></pre>
<p>Is anything wrong with my code, or there is the other way to operate "^"?
Thank you.</p>
| 0debug
|
add custom layout in menu item android : I want to add custom layout to the menuitem in menu.xml file.
LinearLayout actionItemLayout = (LinearLayout) menu.findItem(R.id.itemMenu).getActionView();
TextView txtNumber = (TextView)actionItemLayout.findViewById(R.id.txt_vehicleNumber);
TextView txtName = (TextView)actionItemLayout.findViewById(R.id.txt_vehicleName);
I havedone like this but everytime actionItemLayout is giving null.
Please help
| 0debug
|
document.getElementById('input').innerHTML = user_input;
| 1threat
|
void do_info_roms(Monitor *mon)
{
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
if (!rom->fw_file) {
monitor_printf(mon, "addr=" TARGET_FMT_plx
" size=0x%06zx mem=%s name=\"%s\" \n",
rom->addr, rom->romsize,
rom->isrom ? "rom" : "ram",
rom->name);
} else {
monitor_printf(mon, "fw=%s%s%s"
" size=0x%06zx name=\"%s\" \n",
rom->fw_dir ? rom->fw_dir : "",
rom->fw_dir ? "/" : "",
rom->fw_file,
rom->romsize,
rom->name);
}
}
}
| 1threat
|
document.location = 'http://evil.com?username=' + user_input;
| 1threat
|
QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename)
{
char host[65], port[33], width[8], height[8];
int pos;
const char *p;
QemuOpts *opts;
Error *local_err = NULL;
opts = qemu_opts_create(qemu_find_opts("chardev"), label, 1, &local_err);
if (local_err) {
error_report_err(local_err);
return NULL;
}
if (strstart(filename, "mon:", &p)) {
filename = p;
qemu_opt_set(opts, "mux", "on", &error_abort);
if (strcmp(filename, "stdio") == 0) {
qemu_opt_set(opts, "signal", "off", &error_abort);
}
}
if (strcmp(filename, "null") == 0 ||
strcmp(filename, "pty") == 0 ||
strcmp(filename, "msmouse") == 0 ||
strcmp(filename, "braille") == 0 ||
strcmp(filename, "testdev") == 0 ||
strcmp(filename, "stdio") == 0) {
qemu_opt_set(opts, "backend", filename, &error_abort);
return opts;
}
if (strstart(filename, "vc", &p)) {
qemu_opt_set(opts, "backend", "vc", &error_abort);
if (*p == ':') {
if (sscanf(p+1, "%7[0-9]x%7[0-9]", width, height) == 2) {
qemu_opt_set(opts, "width", width, &error_abort);
qemu_opt_set(opts, "height", height, &error_abort);
} else if (sscanf(p+1, "%7[0-9]Cx%7[0-9]C", width, height) == 2) {
qemu_opt_set(opts, "cols", width, &error_abort);
qemu_opt_set(opts, "rows", height, &error_abort);
} else {
goto fail;
}
}
return opts;
}
if (strcmp(filename, "con:") == 0) {
qemu_opt_set(opts, "backend", "console", &error_abort);
return opts;
}
if (strstart(filename, "COM", NULL)) {
qemu_opt_set(opts, "backend", "serial", &error_abort);
qemu_opt_set(opts, "path", filename, &error_abort);
return opts;
}
if (strstart(filename, "file:", &p)) {
qemu_opt_set(opts, "backend", "file", &error_abort);
qemu_opt_set(opts, "path", p, &error_abort);
return opts;
}
if (strstart(filename, "pipe:", &p)) {
qemu_opt_set(opts, "backend", "pipe", &error_abort);
qemu_opt_set(opts, "path", p, &error_abort);
return opts;
}
if (strstart(filename, "tcp:", &p) ||
strstart(filename, "telnet:", &p)) {
if (sscanf(p, "%64[^:]:%32[^,]%n", host, port, &pos) < 2) {
host[0] = 0;
if (sscanf(p, ":%32[^,]%n", port, &pos) < 1)
goto fail;
}
qemu_opt_set(opts, "backend", "socket", &error_abort);
qemu_opt_set(opts, "host", host, &error_abort);
qemu_opt_set(opts, "port", port, &error_abort);
if (p[pos] == ',') {
if (qemu_opts_do_parse(opts, p+pos+1, NULL) != 0)
goto fail;
}
if (strstart(filename, "telnet:", &p))
qemu_opt_set(opts, "telnet", "on", &error_abort);
return opts;
}
if (strstart(filename, "udp:", &p)) {
qemu_opt_set(opts, "backend", "udp", &error_abort);
if (sscanf(p, "%64[^:]:%32[^@,]%n", host, port, &pos) < 2) {
host[0] = 0;
if (sscanf(p, ":%32[^@,]%n", port, &pos) < 1) {
goto fail;
}
}
qemu_opt_set(opts, "host", host, &error_abort);
qemu_opt_set(opts, "port", port, &error_abort);
if (p[pos] == '@') {
p += pos + 1;
if (sscanf(p, "%64[^:]:%32[^,]%n", host, port, &pos) < 2) {
host[0] = 0;
if (sscanf(p, ":%32[^,]%n", port, &pos) < 1) {
goto fail;
}
}
qemu_opt_set(opts, "localaddr", host, &error_abort);
qemu_opt_set(opts, "localport", port, &error_abort);
}
return opts;
}
if (strstart(filename, "unix:", &p)) {
qemu_opt_set(opts, "backend", "socket", &error_abort);
if (qemu_opts_do_parse(opts, p, "path") != 0)
goto fail;
return opts;
}
if (strstart(filename, "/dev/parport", NULL) ||
strstart(filename, "/dev/ppi", NULL)) {
qemu_opt_set(opts, "backend", "parport", &error_abort);
qemu_opt_set(opts, "path", filename, &error_abort);
return opts;
}
if (strstart(filename, "/dev/", NULL)) {
qemu_opt_set(opts, "backend", "tty", &error_abort);
qemu_opt_set(opts, "path", filename, &error_abort);
return opts;
}
fail:
qemu_opts_del(opts);
return NULL;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.